diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php
index e00ab114..235d897a 100644
--- a/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php
+++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php
@@ -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);
}
}
diff --git a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue
index b684d64e..5356070b 100644
--- a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue
+++ b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue
@@ -39,7 +39,7 @@
-
@@ -63,6 +63,16 @@
diff --git a/resources/views/pages/pdfs/deliver_order.blade.php b/resources/views/pages/pdfs/deliver_order.blade.php
index c45d27f7..a2c77a66 100644
--- a/resources/views/pages/pdfs/deliver_order.blade.php
+++ b/resources/views/pages/pdfs/deliver_order.blade.php
@@ -34,7 +34,7 @@
REF: {{ $invoice_transaction->payment_reference ?? '-' }}
-
Date: {{ $invoice_transaction->created_at }}
+
Date: {{ $po_order_transaction->created_at }}
@@ -77,18 +77,22 @@
Stock Code |
Description |
Quantity |
- Unit Price (RM) |
+ Unit Price (RM) |
Total Amount (RM) |
+ @php
+ $subtotal = 0;
+ @endphp
+
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
| {{ $key + 1 }} |
{{ $transaction_detail->product_code }} |
{{ $transaction_detail->product_name }} |
{{ $transaction_detail->quantity }} |
-
+ |
@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 @@
|
@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
|
@@ -110,11 +123,7 @@
|
Subtotal |
- @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) }}
|
@@ -124,6 +133,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
+
+ |
+ Adjustment |
+
+ @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
+ |
+
@if($invoice_transaction->tax > 0)
|
diff --git a/resources/views/pages/pdfs/invoice.blade.php b/resources/views/pages/pdfs/invoice.blade.php
index 3bad3ac0..611d4362 100644
--- a/resources/views/pages/pdfs/invoice.blade.php
+++ b/resources/views/pages/pdfs/invoice.blade.php
@@ -33,7 +33,7 @@
Ref# {{ $invoice_transaction->payment_reference ?? '-' }}
- Date: {{ $invoice_transaction->created_at }}
+ Date: {{ $po_order_transaction->created_at }}
@@ -76,18 +76,22 @@
Stock Code |
Description |
Quantity |
- Unit Price (RM) |
+ Unit Price (RM) |
Total Amount (RM) |
+ @php
+ $subtotal = 0;
+ @endphp
+
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
| {{ $key + 1 }} |
{{ $transaction_detail->product_code }} |
{{ $transaction_detail->product_name }} |
{{ $transaction_detail->quantity }} |
-
+ |
@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 @@
|
@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
|
@@ -109,11 +122,7 @@
|
Subtotal |
- @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) }}
|
@@ -123,6 +132,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
+
+ |
+ Adjustment |
+
+ @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
+ |
+
@if($invoice_transaction->tax > 0)
|
diff --git a/resources/views/pages/pdfs/purchase_order.blade.php b/resources/views/pages/pdfs/purchase_order.blade.php
index 2d1327cd..c2c17481 100644
--- a/resources/views/pages/pdfs/purchase_order.blade.php
+++ b/resources/views/pages/pdfs/purchase_order.blade.php
@@ -81,18 +81,22 @@
Stock Code |
Description |
Quantity |
- Unit Price (RM) |
+ Unit Price (RM) |
Total Amount (RM) |
+ @php
+ $subtotal = 0;
+ @endphp
+
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
| {{ $key + 1 }} |
{{ $transaction_detail->product_code }} |
{{ $transaction_detail->product_name }} |
{{ $transaction_detail->quantity }} |
-
+ |
@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 @@
|
@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
|
@@ -112,13 +125,9 @@
|
- Subtotal |
+ Subtotal |
- @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) }}
|
@@ -128,6 +137,17 @@
{{ number_format($invoice_transaction->service_charge, 2) }}
+
+ |
+ Adjustment |
+
+ @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
+ |
+
@if($invoice_transaction->tax > 0)
|
diff --git a/resources/views/pages/pdfs/supplier_deliver_order.blade.php b/resources/views/pages/pdfs/supplier_deliver_order.blade.php
index 5b736e39..22de6719 100644
--- a/resources/views/pages/pdfs/supplier_deliver_order.blade.php
+++ b/resources/views/pages/pdfs/supplier_deliver_order.blade.php
@@ -20,7 +20,7 @@
PO#: {{ $supplier_deliver_order_transaction->bill_no }}
Ref#: {{ $supplier_deliver_order_transaction->payment_reference ?? '-' }}
- Date: {{ $supplier_deliver_order_transaction->created_at }}
+ Date: {{ $po_order_transaction->created_at }}
|
@@ -66,18 +66,22 @@
Stock Code |
Description |
Quantity |
- Unit Price (RM) |
+ Unit Price (RM) |
Total Amount (RM) |
+ @php
+ $subtotal = 0;
+ @endphp
+
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
| {{ $key + 1 }} |
{{ $transaction_detail->product_code }} |
{{ $transaction_detail->product_name }} |
{{ $transaction_detail->quantity }} |
-
+ |
@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 @@
|
@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
|
@@ -99,10 +112,17 @@
|
Subtotal |
- @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) }}
+ |
+
+
+ |
+ Adjustment |
+
+ @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
|