unwind route hash

This commit is contained in:
David Bomba 2024-07-19 08:53:30 +10:00
parent 8fb08ea786
commit d930202147
3 changed files with 44 additions and 29 deletions

View File

@ -164,18 +164,19 @@ class Peppol extends AbstractService
$type_id = $this->invoice->line_items[0]->type_id; $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 = new TaxAmount();
$tax_amount->currencyID = $this->invoice->client->currency()->code; $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 = new TaxSubtotal();
$tax_subtotal->TaxAmount = $tax_amount; $tax_subtotal->TaxAmount = $tax_amount;
$taxable_amount = new TaxableAmount(); $taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code; $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; $tax_subtotal->TaxableAmount = $taxable_amount;
$tc = new TaxCategory(); $tc = new TaxCategory();
@ -188,10 +189,10 @@ class Peppol extends AbstractService
$tax_total = new TaxTotal(); $tax_total = new TaxTotal();
$tax_total->TaxAmount = $tax_amount; $tax_total->TaxAmount = $tax_amount;
$tax_total->TaxSubtotal = $tax_subtotal; $tax_total->TaxSubtotal[] = $tax_subtotal;
$taxes[] = $tax_total; $taxes[] = $tax_total;
} // }
if(strlen($this->invoice->tax_name2 ?? '') > 1) { if(strlen($this->invoice->tax_name2 ?? '') > 1) {
@ -206,7 +207,7 @@ class Peppol extends AbstractService
$taxable_amount = new TaxableAmount(); $taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code; $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; $tax_subtotal->TaxableAmount = $taxable_amount;
@ -238,7 +239,7 @@ class Peppol extends AbstractService
$taxable_amount = new TaxableAmount(); $taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code; $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; $tax_subtotal->TaxableAmount = $taxable_amount;
@ -280,7 +281,7 @@ class Peppol extends AbstractService
$lea = new LineExtensionAmount(); $lea = new LineExtensionAmount();
$lea->currencyID = $this->invoice->client->currency()->code; $lea->currencyID = $this->invoice->client->currency()->code;
// $lea->amount = $item->line_total; // $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->LineExtensionAmount = $lea;
$line->Item = $_item; $line->Item = $_item;
@ -293,7 +294,7 @@ class Peppol extends AbstractService
$price = new Price(); $price = new Price();
$pa = new PriceAmount(); $pa = new PriceAmount();
$pa->currencyID = $this->invoice->client->currency()->code; $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; $price->PriceAmount = $pa;
$line->Price = $price; $line->Price = $price;
@ -333,7 +334,7 @@ class Peppol extends AbstractService
$taxable_amount = new TaxableAmount(); $taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code; $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; $tax_subtotal->TaxableAmount = $taxable_amount;
$tc = new TaxCategory(); $tc = new TaxCategory();
$tc->ID = $item->type_id == '2' ? 'HUR' : 'C62'; $tc->ID = $item->type_id == '2' ? 'HUR' : 'C62';
@ -356,14 +357,15 @@ class Peppol extends AbstractService
$tax_amount = new TaxAmount(); $tax_amount = new TaxAmount();
$tax_amount->currencyID = $this->invoice->client->currency()->code; $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 = new TaxSubtotal();
$tax_subtotal->TaxAmount = $tax_amount; $tax_subtotal->TaxAmount = $tax_amount;
$taxable_amount = new TaxableAmount(); $taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code; $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; $tax_subtotal->TaxableAmount = $taxable_amount;
@ -389,14 +391,15 @@ class Peppol extends AbstractService
$tax_amount = new TaxAmount(); $tax_amount = new TaxAmount();
$tax_amount->currencyID = $this->invoice->client->currency()->code; $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 = new TaxSubtotal();
$tax_subtotal->TaxAmount = $tax_amount; $tax_subtotal->TaxAmount = $tax_amount;
$taxable_amount = new TaxableAmount(); $taxable_amount = new TaxableAmount();
$taxable_amount->currencyID = $this->invoice->client->currency()->code; $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; $tax_subtotal->TaxableAmount = $taxable_amount;

View File

@ -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('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 { // try {
$route = decrypt($hash); // $route = decrypt($hash);
} // }
catch (\Exception $e) { // catch (\Exception $e) {
abort(404); // 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('phantom/{entity}/{invitation_key}', [Phantom::class, 'displayInvitation'])->middleware(['invite_db', 'phantom_secret'])->name('phantom_view');
Route::get('blade/', [Phantom::class, 'blade'])->name('blade'); Route::get('blade/', [Phantom::class, 'blade'])->name('blade');

View File

@ -218,13 +218,12 @@ class StorecoveTest extends TestCase
'; ';
//inclusive //inclusive
$x = ' $x = '<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Invoice <Invoice
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"> xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:ID>DE-10515</cbc:ID> <cbc:ID>DE-93090</cbc:ID>
<cbc:IssueDate>2024-07-18</cbc:IssueDate> <cbc:IssueDate>2024-07-18</cbc:IssueDate>
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode> <cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
<cac:AccountingSupplierParty> <cac:AccountingSupplierParty>
@ -297,7 +296,20 @@ $x = '
</FinancialInstitutionBranch> </FinancialInstitutionBranch>
</PayeeFinancialAccount> </PayeeFinancialAccount>
</cac:PaymentMeans> </cac:PaymentMeans>
<cac:TaxTotal/> <cac:TaxTotal>
<cbc:TaxAmount currencyID="EUR">15.97</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="EUR">84.03</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="EUR">15.97</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>C62</cbc:ID>
<cbc:Percent>0</cbc:Percent>
<cac:TaxScheme>
<cbc:ID></cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal> <cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="EUR">84.03</cbc:LineExtensionAmount> <cbc:LineExtensionAmount currencyID="EUR">84.03</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="EUR">84.03</cbc:TaxExclusiveAmount> <cbc:TaxExclusiveAmount currencyID="EUR">84.03</cbc:TaxExclusiveAmount>
@ -327,7 +339,7 @@ $x = '
<cbc:Name>Product Key</cbc:Name> <cbc:Name>Product Key</cbc:Name>
</cac:Item> </cac:Item>
<cac:Price> <cac:Price>
<cbc:PriceAmount currencyID="EUR">10</cbc:PriceAmount> <cbc:PriceAmount currencyID="EUR">8.403</cbc:PriceAmount>
</cac:Price> </cac:Price>
</cac:InvoiceLine> </cac:InvoiceLine>
'; ';