From d9302021472c3e7e23bac8c3d5fbec57a5f38f0c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 19 Jul 2024 08:53:30 +1000 Subject: [PATCH] unwind route hash --- app/Services/EDocument/Standards/Peppol.php | 31 ++++++++++--------- routes/client.php | 20 ++++++------ .../Einvoice/Storecove/StorecoveTest.php | 22 ++++++++++--- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/app/Services/EDocument/Standards/Peppol.php b/app/Services/EDocument/Standards/Peppol.php index 83174ca0c051..8387a799e4ad 100644 --- a/app/Services/EDocument/Standards/Peppol.php +++ b/app/Services/EDocument/Standards/Peppol.php @@ -164,18 +164,19 @@ class Peppol extends AbstractService $type_id = $this->invoice->line_items[0]->type_id; - if(strlen($this->invoice->tax_name1 ?? '') > 1) { + // if(strlen($this->invoice->tax_name1 ?? '') > 1) { $tax_amount = new TaxAmount(); $tax_amount->currencyID = $this->invoice->client->currency()->code; - $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($this->invoice->tax_rate1, $this->invoice->amount) : $this->calcAmountLineTax($this->invoice->tax_rate1, $this->invoice->amount); + // $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($this->invoice->tax_rate1, $this->invoice->amount) : $this->calcAmountLineTax($this->invoice->tax_rate1, $this->invoice->amount); + $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->invoice->total_taxes : $this->calcAmountLineTax($this->invoice->tax_rate1, $this->invoice->amount); $tax_subtotal = new TaxSubtotal(); $tax_subtotal->TaxAmount = $tax_amount; $taxable_amount = new TaxableAmount(); $taxable_amount->currencyID = $this->invoice->client->currency()->code; - $taxable_amount->amount = $this->invoice->amount; + $taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->invoice->amount - $this->invoice->total_taxes : $this->invoice->amount; $tax_subtotal->TaxableAmount = $taxable_amount; $tc = new TaxCategory(); @@ -188,10 +189,10 @@ class Peppol extends AbstractService $tax_total = new TaxTotal(); $tax_total->TaxAmount = $tax_amount; - $tax_total->TaxSubtotal = $tax_subtotal; + $tax_total->TaxSubtotal[] = $tax_subtotal; $taxes[] = $tax_total; - } + // } if(strlen($this->invoice->tax_name2 ?? '') > 1) { @@ -206,7 +207,7 @@ class Peppol extends AbstractService $taxable_amount = new TaxableAmount(); $taxable_amount->currencyID = $this->invoice->client->currency()->code; - $taxable_amount->amount = $this->invoice->amount; + $taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->invoice->amount- $this->invoice->total_taxes : $this->invoice->amount; $tax_subtotal->TaxableAmount = $taxable_amount; @@ -238,7 +239,7 @@ class Peppol extends AbstractService $taxable_amount = new TaxableAmount(); $taxable_amount->currencyID = $this->invoice->client->currency()->code; - $taxable_amount->amount = $this->invoice->amount; + $taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->invoice->amount - $this->invoice->total_taxes : $this->invoice->amount; $tax_subtotal->TaxableAmount = $taxable_amount; @@ -280,7 +281,7 @@ class Peppol extends AbstractService $lea = new LineExtensionAmount(); $lea->currencyID = $this->invoice->client->currency()->code; // $lea->amount = $item->line_total; - $lea->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $this->calcInclusiveLineTax($item->tax_rate1, $item->line_total), 2) : $item->line_total; + $lea->amount = $this->invoice->uses_inclusive_taxes ? $item->line_total - $this->calcInclusiveLineTax($item->tax_rate1, $item->line_total) : $item->line_total; $line->LineExtensionAmount = $lea; $line->Item = $_item; @@ -293,7 +294,7 @@ class Peppol extends AbstractService $price = new Price(); $pa = new PriceAmount(); $pa->currencyID = $this->invoice->client->currency()->code; - $pa->amount = $this->costWithDiscount($item); + $pa->amount = $this->costWithDiscount($item) - ( $this->invoice->uses_inclusive_taxes ? ($this->calcInclusiveLineTax($item->tax_rate1, $item->line_total)/$item->quantity) : 0); $price->PriceAmount = $pa; $line->Price = $price; @@ -333,7 +334,7 @@ class Peppol extends AbstractService $taxable_amount = new TaxableAmount(); $taxable_amount->currencyID = $this->invoice->client->currency()->code; - $taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $tax_amount->amount,2) : $item->line_total; + $taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? $item->line_total - $tax_amount->amount : $item->line_total; $tax_subtotal->TaxableAmount = $taxable_amount; $tc = new TaxCategory(); $tc->ID = $item->type_id == '2' ? 'HUR' : 'C62'; @@ -356,14 +357,15 @@ class Peppol extends AbstractService $tax_amount = new TaxAmount(); $tax_amount->currencyID = $this->invoice->client->currency()->code; - $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate2, $item->line_total) : $this->calcAmountLineTax($item->tax_rate2, $item->line_total); + +$tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate2, $item->line_total) : $this->calcAmountLineTax($item->tax_rate2, $item->line_total); $tax_subtotal = new TaxSubtotal(); $tax_subtotal->TaxAmount = $tax_amount; $taxable_amount = new TaxableAmount(); $taxable_amount->currencyID = $this->invoice->client->currency()->code; - $taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $tax_amount->amount, 2) : $item->line_total; + $taxable_amount->amount = $item->line_total; $tax_subtotal->TaxableAmount = $taxable_amount; @@ -389,14 +391,15 @@ class Peppol extends AbstractService $tax_amount = new TaxAmount(); $tax_amount->currencyID = $this->invoice->client->currency()->code; - $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate3, $item->line_total) : $this->calcAmountLineTax($item->tax_rate3, $item->line_total); + +$tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate3, $item->line_total) : $this->calcAmountLineTax($item->tax_rate3, $item->line_total); $tax_subtotal = new TaxSubtotal(); $tax_subtotal->TaxAmount = $tax_amount; $taxable_amount = new TaxableAmount(); $taxable_amount->currencyID = $this->invoice->client->currency()->code; - $taxable_amount->amount = $this->invoice->uses_inclusive_taxes ? round($item->line_total - $tax_amount->amount, 2) : $item->line_total; + $taxable_amount->amount = $item->line_total; $tax_subtotal->TaxableAmount = $taxable_amount; diff --git a/routes/client.php b/routes/client.php index 8b29dc956c17..7f9d4614f0e0 100644 --- a/routes/client.php +++ b/routes/client.php @@ -144,20 +144,20 @@ Route::group(['middleware' => ['invite_db'], 'prefix' => 'client', 'as' => 'clie Route::get('unsubscribe/{entity}/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'unsubscribe'])->name('unsubscribe'); }); -Route::get('route/{hash}', function ($hash) { +// Route::get('route/{hash}', function ($hash) { - $route = '/'; +// $route = '/'; - try { - $route = decrypt($hash); - } - catch (\Exception $e) { - abort(404); - } +// try { +// $route = decrypt($hash); +// } +// catch (\Exception $e) { +// abort(404); +// } - return redirect($route); +// return redirect($route); -})->middleware('throttle:404'); +// })->middleware('throttle:404'); Route::get('phantom/{entity}/{invitation_key}', [Phantom::class, 'displayInvitation'])->middleware(['invite_db', 'phantom_secret'])->name('phantom_view'); Route::get('blade/', [Phantom::class, 'blade'])->name('blade'); diff --git a/tests/Integration/Einvoice/Storecove/StorecoveTest.php b/tests/Integration/Einvoice/Storecove/StorecoveTest.php index 1c4b353cc794..e121caf0ba5c 100644 --- a/tests/Integration/Einvoice/Storecove/StorecoveTest.php +++ b/tests/Integration/Einvoice/Storecove/StorecoveTest.php @@ -218,13 +218,12 @@ class StorecoveTest extends TestCase '; //inclusive -$x = ' - +$x = ' -DE-10515 +DE-93090 2024-07-18 380 @@ -297,7 +296,20 @@ $x = ' - + + 15.97 + + 84.03 + 15.97 + + C62 + 0 + + + + + + 84.03 84.03 @@ -327,7 +339,7 @@ $x = ' Product Key - 10 + 8.403 ';