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;
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,6 +357,7 @@ 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_subtotal = new TaxSubtotal();
@ -363,7 +365,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 = $item->line_total;
$tax_subtotal->TaxableAmount = $taxable_amount;
@ -389,6 +391,7 @@ 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_subtotal = new TaxSubtotal();
@ -396,7 +399,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 = $item->line_total;
$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('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');

View File

@ -218,13 +218,12 @@ class StorecoveTest extends TestCase
';
//inclusive
$x = '
<?xml version="1.0" encoding="utf-8"?>
$x = '<?xml version="1.0" encoding="utf-8"?>
<Invoice
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
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:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
<cac:AccountingSupplierParty>
@ -297,7 +296,20 @@ $x = '
</FinancialInstitutionBranch>
</PayeeFinancialAccount>
</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>
<cbc:LineExtensionAmount currencyID="EUR">84.03</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="EUR">84.03</cbc:TaxExclusiveAmount>
@ -327,7 +339,7 @@ $x = '
<cbc:Name>Product Key</cbc:Name>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="EUR">10</cbc:PriceAmount>
<cbc:PriceAmount currencyID="EUR">8.403</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
';