Steuerstatus und Steuersatz in Kostenkarte wiederherstellen

This commit is contained in:
gitea_admin committed 2026-09-20 12:57:09 +02:00
1 parent bae293ad94
commit af235987ea
5 files changed
+39 -22

No files matched your search

+2 -2
View File
@@ -40,7 +40,7 @@ function market_management_mcp_tools(): array
'payment_status' => ['type' => ['string', 'null'], 'enum' => ['paid', 'unpaid']],
'payment_date' => ['type' => ['string', 'null'], 'format' => 'date'], 'paid_amount' => ['type' => ['number', 'null']],
'payment_method_code' => ['type' => ['string', 'null']], 'stand_size' => ['type' => ['string', 'null']],
'gross_cost' => ['type' => ['number', 'null'], 'minimum' => 0], 'cost_items_text' => ['type' => ['string', 'null']],
'gross_cost' => ['type' => ['number', 'null'], 'minimum' => 0], 'tax_status' => ['type' => ['string', 'null'], 'enum' => ['tax_free', 'taxable']], 'tax_rate' => ['type' => ['number', 'null'], 'minimum' => 0], 'cost_items_text' => ['type' => ['string', 'null']],
'table_available' => ['type' => ['boolean', 'null']], 'table_rentable' => ['type' => ['boolean', 'null']],
'own_table_required' => ['type' => ['boolean', 'null']], 'shelter_available' => ['type' => ['boolean', 'null']],
'power_available' => ['type' => ['boolean', 'null']], 'water_available' => ['type' => ['boolean', 'null']],
@@ -216,7 +216,7 @@ function market_management_mcp_get_market(PDO $pdo, int $marketId, bool $include
function market_management_mcp_update_occurrence(PDO $pdo, int $occurrenceId, array $input): array
{
$simpleCostFields = [];
foreach (['gross_cost', 'cost_items_text'] as $field) {
foreach (['gross_cost', 'cost_items_text', 'tax_status', 'tax_rate'] as $field) {
if (array_key_exists($field, $input)) {
$simpleCostFields[$field] = $input[$field];
unset($input[$field]);
+28 -17
View File
@@ -1358,34 +1358,45 @@ function market_management_update_cost_item(PDO $pdo, int $costItemId, array $in
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
'SELECT id, gross_amount, tax_status, tax_rate, description 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) {
$existingItem = $itemStmt->fetch();
if (!is_array($existingItem)) {
$grossAmount = market_management_optional_number($input, 'gross_cost') ?? '0.00';
$taxStatus = trim((string) ($input['tax_status'] ?? 'taxable'));
$taxRate = market_management_optional_number($input, 'tax_rate') ?? ($taxStatus === 'tax_free' ? '0.00' : '8.10');
$item = market_management_create_cost_item($pdo, [
'occurrence_id' => $occurrenceId,
'cost_type_id' => market_management_get_cost_type_id($pdo, 'stand_fee'),
'description' => $description,
'description' => array_key_exists('cost_items_text', $input) ? market_management_optional_string($input, 'cost_items_text') : null,
'gross_amount' => $grossAmount,
'tax_status' => 'taxable',
'tax_rate' => 8.10,
'tax_status' => $taxStatus,
'tax_rate' => $taxRate,
]);
} else {
$item = market_management_update_cost_item($pdo, (int) $itemId, [
'description' => $description,
'gross_amount' => $grossAmount,
]);
$costFields = [];
if (array_key_exists('gross_cost', $input)) {
$costFields['gross_amount'] = market_management_optional_number($input, 'gross_cost');
}
if (array_key_exists('cost_items_text', $input)) {
$costFields['description'] = market_management_optional_string($input, 'cost_items_text');
}
if (array_key_exists('tax_status', $input)) {
$costFields['tax_status'] = trim((string) $input['tax_status']);
if ($costFields['tax_status'] === 'tax_free' && !array_key_exists('tax_rate', $input)) {
$costFields['tax_rate'] = '0.00';
}
}
if (array_key_exists('tax_rate', $input)) {
$costFields['tax_rate'] = market_management_optional_number($input, 'tax_rate');
}
$item = $costFields === []
? (array) $existingItem
: market_management_update_cost_item($pdo, (int) $existingItem['id'], $costFields);
}
return $item;
}