@php
use Illuminate\Support\Str;
$outputTrans = collect($trans)->filter(function ($tran) {
return strtolower($tran->Source) === 'customer' || strtolower($tran->Source) === 'tenant';
});
$inputTrans = collect($trans)->filter(function ($tran) {
return strtolower($tran->Source) === 'supplier';
});
function calculateTotals($transactions) {
$totals = [
'invoice' => 0,
'tax' => 0,
'incl' => 0,
'rate' => 0,
];
foreach ($transactions as $tran) {
$invoiceAmount = $tran->Price * $tran->Qnty;
$taxAmount = $invoiceAmount * ($tran->Tax / 100);
$amountIncl = $invoiceAmount - $taxAmount;
$totals['invoice'] += $invoiceAmount;
$totals['tax'] += $taxAmount;
$totals['incl'] += $amountIncl;
$totals['rate'] += $tran->Tax;
}
return $totals;
}
$outputTotals = calculateTotals($outputTrans);
$inputTotals = calculateTotals($inputTrans);
@endphp
Output Tax [Tenants]
Date |
Name |
Inv No |
Inv Amount(USD) |
Tax% |
Tax Amount(USD) |
Total(incl) |
@foreach ($outputTrans as $tran)
@php
$invoiceAmount = $tran->Price * $tran->Qnty;
$taxAmount = $invoiceAmount * ($tran->Tax / 100);
$amountIncl = $invoiceAmount - $taxAmount;
@endphp
{{ $tran->EntryDate }} |
{{ \App\Http\Controllers\StatementsController::getAccountName($tran->Source, $tran->AccSubCode) }} |
{{ $tran->Batch }} |
{{ number_format($invoiceAmount, 2) }} |
{{ $tran->Tax }} |
{{ number_format($taxAmount, 2) }} |
{{ number_format($amountIncl, 2) }} |
@endforeach
|
Total Output Tax |
{{ number_format($outputTotals['invoice'], 2) }}
|
|
{{ number_format($outputTotals['tax'], 2) }}
|
{{ number_format($outputTotals['incl'], 2) }}
|
Input Tax [Suppliers]
Date |
Name |
Inv No |
Inv Amount(USD) |
Tax% |
Tax Amount(USD) |
Total(incl) |
@foreach ($inputTrans as $tran)
@php
$invoiceAmount = $tran->Price * $tran->Qnty;
$taxAmount = $invoiceAmount * ($tran->Tax / 100);
$amountIncl = $invoiceAmount - $taxAmount;
@endphp
{{ $tran->EntryDate }} |
{{ \App\Http\Controllers\StatementsController::getAccountName($tran->Source, $tran->AccSubCode) }} |
{{ $tran->Batch }} |
{{ number_format($invoiceAmount, 2) }} |
{{ $tran->Tax }} |
{{ number_format($taxAmount, 2) }} |
{{ number_format($amountIncl, 2) }} |
@endforeach
|
Total Input Tax |
{{ number_format($inputTotals['invoice'], 2) }}
|
|
{{ number_format($inputTotals['tax'], 2) }}
|
{{ number_format($inputTotals['incl'], 2) }}
|
|
Net Tax |
USD{{ number_format($outputTotals['invoice'] - $inputTotals['invoice'], 2) }} |
|
USD{{ number_format($outputTotals['tax'] - $inputTotals['tax'], 2) }} |
USD{{ number_format($outputTotals['incl'] - $inputTotals['incl'], 2) }} |
`