diff --git a/modules/market_management/mcp.php b/modules/market_management/mcp.php index 28006e6..4b751c2 100644 --- a/modules/market_management/mcp.php +++ b/modules/market_management/mcp.php @@ -215,6 +215,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 { + unset($input['occurrence_id']); $simpleCostFields = []; foreach (['gross_cost', 'cost_items_text', 'tax_status', 'tax_rate'] as $field) { if (array_key_exists($field, $input)) { diff --git a/modules/market_management/service.php b/modules/market_management/service.php index b3a1698..c4ef701 100644 --- a/modules/market_management/service.php +++ b/modules/market_management/service.php @@ -775,16 +775,21 @@ function market_management_create_occurrence(PDO $pdo, array $input): array } market_management_set_occurrence_contact($pdo, [ 'occurrence_id' => (int) $occurrence['id'], - 'contact_person_name' => null, - 'contact_email' => null, - 'contact_phone' => null, + 'contact_person_name' => $input['contact_person_name'] ?? null, + 'contact_email' => $input['contact_email'] ?? null, + 'contact_phone' => $input['contact_phone'] ?? null, ]); + $grossCost = 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'); market_management_create_cost_item($pdo, [ 'occurrence_id' => (int) $occurrence['id'], 'cost_type_id' => market_management_get_cost_type_id($pdo, 'stand_fee'), - 'gross_amount' => 0, - 'tax_status' => 'taxable', - 'tax_rate' => 8.10, + 'description' => market_management_optional_string($input, 'cost_items_text'), + 'gross_amount' => $grossCost, + 'tax_status' => $taxStatus, + 'tax_rate' => $taxRate, ]); if ($startedTransaction) { $pdo->commit();