Kostenpositionen durch einfache Gesamtkosten ersetzen
This commit is contained in:
1 parent
c0c3c2600f
commit
1ad35cdcfd
9 files changed
+81
-146
No files matched your search
@@ -1355,3 +1355,37 @@ function market_management_update_cost_item(PDO $pdo, int $costItemId, array $in
|
||||
$item['cost_type'] = market_management_get_cost_type($pdo, (int) $item['cost_type_id'])['name'];
|
||||
return $item;
|
||||
}
|
||||
|
||||
function market_management_update_occurrence_simple_costs(PDO $pdo, int $occurrenceId, array $input): array
|
||||
{
|
||||
$grossAmount = market_management_optional_number($input, 'gross_cost');
|
||||
if ($grossAmount === null) {
|
||||
throw new InvalidArgumentException('Gesamtkosten sind erforderlich.');
|
||||
}
|
||||
$itemStmt = $pdo->prepare(
|
||||
'SELECT id FROM market_occurrence_cost_item
|
||||
WHERE occurrence_id = :occurrence_id
|
||||
ORDER BY id ASC LIMIT 1'
|
||||
);
|
||||
$itemStmt->execute([':occurrence_id' => $occurrenceId]);
|
||||
$itemId = $itemStmt->fetchColumn();
|
||||
$description = array_key_exists('cost_items_text', $input)
|
||||
? market_management_optional_string($input, 'cost_items_text')
|
||||
: null;
|
||||
if ($itemId === false) {
|
||||
$item = market_management_create_cost_item($pdo, [
|
||||
'occurrence_id' => $occurrenceId,
|
||||
'cost_type_id' => market_management_get_cost_type_id($pdo, 'stand_fee'),
|
||||
'description' => $description,
|
||||
'gross_amount' => $grossAmount,
|
||||
'tax_status' => 'taxable',
|
||||
'tax_rate' => 8.10,
|
||||
]);
|
||||
} else {
|
||||
$item = market_management_update_cost_item($pdo, (int) $itemId, [
|
||||
'description' => $description,
|
||||
'gross_amount' => $grossAmount,
|
||||
]);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
Reference in new issue
Block a user