Signed-off-by: fuadzaidan7 <fuadzaidan7@gmail.com>

This commit is contained in:
fuadzaidan7
2021-09-06 13:34:14 +08:00
parent f2ae778a8e
commit 165d80537e
5 changed files with 132 additions and 44 deletions
@@ -12,16 +12,24 @@ class CalculatesBookingCurrencyAverageRate
public function execute(Booking $booking, $type){
if ($type == TransactionType::PAYMENT) {
return $booking->transactions()
$amount_without_service = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->avg('currency_rate');
->selectRaw('ROUND(amount,2)-ROUND(service_charge,2) AS amount_without_service')
->get()->sum('amount_without_service');
return number_format($booking->fix_amount/$amount_without_service,2);
}
else if ($type == TransactionType::BILL) {
return $booking->transactions()
$amount_without_service = $booking->transactions()
->where('type', TransactionType::BILL)
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->avg('currency_rate');
->selectRaw('ROUND(amount,2)-ROUND(service_charge,2) AS amount_without_service')
->get()->sum('amount_without_service');
return number_format($booking->fix_amount/$amount_without_service,2);
}
}
@@ -77,18 +77,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -97,9 +101,18 @@
</td>
<td width="20%" class="right top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -110,11 +123,7 @@
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2) }}
@else
{{ number_format($invoice_transaction->amount, 2) }}
@endif
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
@@ -124,6 +133,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>
@if($invoice_transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
+30 -10
View File
@@ -76,18 +76,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -96,9 +100,18 @@
</td>
<td width="20%" class="right top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -109,11 +122,7 @@
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2) }}
@else
{{ number_format($invoice_transaction->amount, 2) }}
@endif
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
@@ -123,6 +132,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>
@if($invoice_transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -81,18 +81,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -101,9 +105,18 @@
</td>
<td width="20%" class="right top">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -112,13 +125,9 @@
<tfoot>
<tr class="subtotal">
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2) }}
@else
{{ number_format($invoice_transaction->amount, 2) }}
@endif
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
@@ -128,6 +137,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>
@if($invoice_transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -66,18 +66,22 @@
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@php
$subtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="12%" class="center top">
<td width="15%" class="center top">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->price, 2) }}
@else
@@ -86,9 +90,18 @@
</td>
<td width="20%" class="right top">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->amount, 2) }}
@else
{{ number_format($transaction_detail->amount, 2) }}
{{ number_format((float)number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@else
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
@php
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
@endphp
@endif
</td>
</tr>
@@ -99,10 +112,17 @@
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
<td class="right middle">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $supplier_deliver_order_transaction->amount, 2) }}
@else
{{ number_format($supplier_deliver_order_transaction->amount, 2) }}
{{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@if($supplier_deliver_order_transaction->booking()->first()->fix_currency_id !== 1)
{{ number_format((float)number_format( (1/$supplier_deliver_order_transaction->currency_rate) * $supplier_deliver_order_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@else
{{ number_format((float)number_format($supplier_deliver_order_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
@endif
</td>
</tr>