## What changed - enforce EAN draft delivery wiring by setting `recipient.nemHandelType=ean` when customer EAN is present - copy existing e-conomic customer metadata into draft payload: `recipient.attention`, `references.customerContact`, `references.salesPerson`, and `deliveryLocation` - keep `references.other` external-id mapping intact - remove legacy explicit `Rabat:` text-line injection and use line-level `discountPercentage` instead - add/update unit tests for helper extraction and discount/EAN wiring ## Tests - `vendor/bin/pest tests/Unit/Invoicing/EconomicCustomerEanHelperTest.php tests/Unit/Invoicing/EconomicInvoiceDraftRecipientEanWiringTest.php tests/Unit/Invoicing/EconomicLegacyDraftDiscountWiringTest.php tests/Unit/Invoicing/EconomicInvoiceDraftDiscountLineModeWiringTest.php tests/Unit/Invoicing/CollectedInvoiceEconomicBatchTransferWiringTest.php tests/Unit/Invoicing/EconomicInvoiceDraftItemizedDiscountTest.php --colors=never` ## Notes - full unit suite in this environment still has an unrelated pre-existing failure in `Tests\\Unit\\Bird\\BirdControlPlaneActivationTest` requiring `PLENO_REPO_ROOT_FOR_TESTS`. - live manual verification against customer `12345679` remains environment-blocked due missing e-conomic credentials. --------- Co-authored-by: Jeppe Bundgaard <jb@truckwash.dk> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
20 lines
787 B
PHP
20 lines
787 B
PHP
<?php
|
|
|
|
it('only adds TotDiscount aggregate line when itemized discounts are disabled', function (): void {
|
|
$content = file_get_contents(app_path('modules/economic/helpers/economic_invoice_draft.php'));
|
|
|
|
expect($content)->not->toBeFalse();
|
|
$content = (string)$content;
|
|
|
|
$start = strpos($content, 'public function addOrderItemLines');
|
|
$end = strpos($content, 'public function addOrderItemLine(', (int)$start + 1);
|
|
expect($start)->not->toBeFalse();
|
|
expect($end)->not->toBeFalse();
|
|
expect($end)->toBeGreaterThan($start);
|
|
|
|
$block = substr($content, (int)$start, (int)$end - (int)$start);
|
|
expect($block)
|
|
->toContain('if (!$use_itemized_discounts && $total_discount > 0)')
|
|
->toContain('self::addProductDiscountLine($total_discount');
|
|
});
|