mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'vapor/production' into dillon/90-e-invoice-f-2
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Modules\Bookings\Services;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CalculatesBookingOutstanding
|
||||
{
|
||||
@@ -31,10 +32,17 @@ class CalculatesBookingOutstanding
|
||||
|
||||
|
||||
public function execute(Booking $booking){
|
||||
return $booking->fix_amount - $this->calculatesBookingFloatingAmount->execute($booking, $booking->fix_currency_id) - $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) + $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id);
|
||||
$originalBookingAmount = $booking->fix_amount;
|
||||
$refundedAmount = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id);
|
||||
if($originalBookingAmount === $refundedAmount){
|
||||
return $originalBookingAmount - $this->calculatesBookingFloatingAmount->execute($booking, $booking->fix_currency_id) - $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id);
|
||||
}
|
||||
else{
|
||||
return $originalBookingAmount - $this->calculatesBookingFloatingAmount->execute($booking, $booking->fix_currency_id) - $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) + $refundedAmount;
|
||||
}
|
||||
}
|
||||
|
||||
public function executeWithoutFloatingAmount(Booking $booking){
|
||||
return $booking->fix_amount - $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) + $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CalculatesBookingPayableAmount
|
||||
{
|
||||
@@ -19,10 +20,21 @@ class CalculatesBookingPayableAmount
|
||||
->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') :
|
||||
$booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->sum('original_amount');
|
||||
}
|
||||
return $type === 1 ?
|
||||
$booking->transactions()->payments()->complete()
|
||||
->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') :
|
||||
$booking->transactions()->payments()->complete()->sum('original_amount');
|
||||
else{
|
||||
$returnAmount = $type === 1 ?
|
||||
$booking->transactions()->payments()->complete()
|
||||
->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') :
|
||||
$booking->transactions()->payments()->complete()->sum('original_amount');
|
||||
|
||||
if($returnAmount === 0){
|
||||
$returnAmount = $type === 1 ?
|
||||
$booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)
|
||||
->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total') :
|
||||
$booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->sum('original_amount');
|
||||
}
|
||||
|
||||
return $returnAmount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,12 @@ class CalculatesBookingRefundAmount
|
||||
return $this->calculateRefundAmount($payment, $type);
|
||||
});
|
||||
|
||||
if ($refundAmounts->isEmpty()) {
|
||||
$refundAmounts = $booking->transactions()->payments()->whereIn('status', [ApprovalStatus::REFUNDED])->get()->map(function ($payment) use ($type) {
|
||||
return $this->calculateRefundAmount($payment, $type);
|
||||
});
|
||||
}
|
||||
|
||||
$totalRefundAmount = $refundAmounts->sum();
|
||||
|
||||
return $totalRefundAmount;
|
||||
|
||||
@@ -68,7 +68,8 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
return Booking::with([
|
||||
'company',
|
||||
'transactions.transactionDetails',
|
||||
'transactions.voucherRedemption'
|
||||
'transactions.voucherRedemption',
|
||||
'transactions.voucherRedemption.voucher.campaign'
|
||||
])
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->whereHas('transactions', function ($query) use ($startDate, $endDate) {
|
||||
@@ -138,10 +139,12 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->count();
|
||||
|
||||
$refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1);
|
||||
$refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1);
|
||||
// $refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1);
|
||||
// $refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1);
|
||||
|
||||
$totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge;
|
||||
// $totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge;
|
||||
|
||||
$totalPayment = $paymentSum;
|
||||
}
|
||||
|
||||
$formattedDocumentDate = Carbon::parse($documentDate)->format('m/d/Y');
|
||||
@@ -194,6 +197,30 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
}
|
||||
}
|
||||
|
||||
// Voucherify - Starts
|
||||
$voucherRedemption = $lastPaymentTransaction->voucherRedemption;
|
||||
if($voucherRedemption){
|
||||
$voucherDiscount = $voucherRedemption ? bcmul((string)$voucherRedemption->value, "-1", 2) : "0";
|
||||
$voucher = $voucherRedemption->voucher;
|
||||
$category = $voucher->campaign ? $voucher->campaign->category : null;
|
||||
$records[] = [
|
||||
'',
|
||||
$formattedDocumentDate,
|
||||
$company->debtor,
|
||||
$invoiceTransaction ? $invoiceTransaction->bill_no : '',
|
||||
$booking->marking,
|
||||
$category === 'Compensation Voucher' ? '1000-000' : '949-2000',
|
||||
'PRODUCT NAME :',
|
||||
$voucher->code,
|
||||
'022',
|
||||
'C',
|
||||
'1',
|
||||
$voucherDiscount ? number_format($voucherDiscount, 2): '0',
|
||||
'',
|
||||
''
|
||||
];
|
||||
}
|
||||
// Voucherify - Ends
|
||||
|
||||
// Service Charge - Starts
|
||||
$serviceCharge = 0;
|
||||
@@ -229,7 +256,7 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
|
||||
// Adjustment - Starts
|
||||
$adjustment = 0;
|
||||
$voucherRedemption = $invoiceTransaction->voucherRedemption;
|
||||
$voucherRedemption = $lastPaymentTransaction->voucherRedemption;
|
||||
$voucherDiscount = $voucherRedemption ? bcmul((string)$voucherRedemption->value, "-1", 2) : "0";
|
||||
|
||||
$displayedSubtotal = is_numeric($displayedSubtotal) ? sprintf('%F', $displayedSubtotal) : '0';
|
||||
|
||||
@@ -146,10 +146,11 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->count();
|
||||
|
||||
$refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1);
|
||||
$refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1);
|
||||
// $refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1);
|
||||
// $refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1);
|
||||
// $totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge;
|
||||
|
||||
$totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge;
|
||||
$totalPayment = $paymentSum;
|
||||
}
|
||||
|
||||
$formattedDocumentDate = Carbon::parse($documentDate)->format('m/d/Y');
|
||||
@@ -203,6 +204,31 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi
|
||||
}
|
||||
}
|
||||
|
||||
// Voucherify - Starts
|
||||
$voucherRedemption = $lastPaymentTransaction->voucherRedemption;
|
||||
if($voucherRedemption){
|
||||
$voucherDiscount = $voucherRedemption ? bcmul((string)$voucherRedemption->value, "-1", 2) : "0";
|
||||
$voucher = $voucherRedemption->voucher;
|
||||
$category = $voucher->campaign ? $voucher->campaign->category : null;
|
||||
$records[] = [
|
||||
'',
|
||||
$formattedDocumentDate,
|
||||
$company->debtor,
|
||||
$invoiceTransaction ? $invoiceTransaction->bill_no : '',
|
||||
$booking->marking,
|
||||
$category === 'Compensation Voucher' ? '1000-000' : '949-2000',
|
||||
'PRODUCT NAME :',
|
||||
$voucher->code,
|
||||
'022',
|
||||
'C',
|
||||
'1',
|
||||
$voucherDiscount ? number_format($voucherDiscount, 2): '0',
|
||||
'',
|
||||
''
|
||||
];
|
||||
}
|
||||
// Voucherify - Ends
|
||||
|
||||
// Service Charge - Starts
|
||||
$serviceCharge = 0;
|
||||
if (!$totalPayment && $invoiceTransaction) {
|
||||
@@ -239,7 +265,7 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi
|
||||
// Adjustment - Starts
|
||||
if($invoiceTransaction){
|
||||
$adjustment = 0;
|
||||
$voucherRedemption = $invoiceTransaction->voucherRedemption;
|
||||
$voucherRedemption = $lastPaymentTransaction->voucherRedemption;
|
||||
$voucherDiscount = $voucherRedemption ? bcmul((string)$voucherRedemption->value, "-1", 2) : "0";
|
||||
|
||||
$displayedSubtotal = is_numeric($displayedSubtotal) ? sprintf('%F', $displayedSubtotal) : '0';
|
||||
|
||||
@@ -49,7 +49,7 @@ class BookingResource extends JsonResource
|
||||
'marking' => $this->marking,
|
||||
'amount' => $this->fix_amount,
|
||||
'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
'paid_amount_with_refund' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
// 'paid_amount_with_refund' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
'outstanding_amount_with_refund' => $outStandingAmountWithRefund > 0 ? $outStandingAmountWithRefund : 0,
|
||||
'refunded_amount' => floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)),
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddCategoryToVoucherCampaignsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('voucher_campaigns', function (Blueprint $table) {
|
||||
$table->string('category')->nullable()->after('description');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('voucher_campaigns', function (Blueprint $table) {
|
||||
$table->dropColumn('category');
|
||||
});
|
||||
}
|
||||
}
|
||||
+26
-4
@@ -5,8 +5,8 @@
|
||||
<div class="row" v-show="!isLoading" v-if="booking">
|
||||
<div class="col-md col-sm-12 m-b-20">
|
||||
<div class="row" v-if="booking">
|
||||
<div class="col" v-if="!(booking.amount === 0 && booking.outstanding_amount === 0 && booking.paid_amount === 0)">
|
||||
<div class="row m-b-50" v-if="booking.status === 3">
|
||||
<div class="col" v-if="showDownloadPDFButtons">
|
||||
<div class="row m-b-50" v-if="booking.status === 3 || isBookingWithAFullRefund">
|
||||
<div class="col no-padding">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@@ -122,7 +122,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10" v-if="booking.status !== 3">
|
||||
<div class="row m-b-10" v-if="booking.status !== 3 && !isBookingWithAFullRefund">
|
||||
<div class="col">
|
||||
<div class="row text-center m-b-15">
|
||||
<div class="col">
|
||||
@@ -395,7 +395,7 @@
|
||||
</general-confirmation-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
<div class="row m-t-15" v-if="booking.amount === 0 && booking.outstanding_amount === 0 && booking.paid_amount === 0 && $store.getters.isSuperAdmin && booking.einvoice">
|
||||
<div class="row m-t-15" v-if="showGenerateEInvoiceRefundButton">
|
||||
<div class="col-sm col-md-auto">
|
||||
<div class="btn btn-sm btn block all-caps b-rad-none btn-danger pointer requestModal equal-width-button" data-type="regenerateEInvoiceRefund">Regenerate E-Invoice<br>(Refund)</div>
|
||||
</div>
|
||||
@@ -636,6 +636,28 @@
|
||||
}
|
||||
return 'NOT PROVIDED';
|
||||
},
|
||||
showDownloadPDFButtons(){
|
||||
const condition1 = !(this.booking.amount === 0 && this.booking.outstanding_amount === 0 && this.booking.paid_amount === 0);
|
||||
const isBookingWithFullRefund = this.booking.payment_history.some(payment =>
|
||||
payment.status === 7 && this.booking.amount === payment.refunded_amount
|
||||
);
|
||||
|
||||
return condition1 || isBookingWithFullRefund;
|
||||
},
|
||||
showGenerateEInvoiceRefundButton(){
|
||||
const condition1 = this.booking.amount === 0 && this.booking.outstanding_amount === 0 && this.booking.paid_amount === 0
|
||||
&& this.$store.getters.isSuperAdmin && this.booking.einvoice;
|
||||
const isBookingWithFullRefund = this.booking.payment_history.some(payment =>
|
||||
payment.status === 7 && this.booking.amount === payment.refunded_amount
|
||||
);
|
||||
return condition1 || isBookingWithFullRefund;
|
||||
},
|
||||
isBookingWithAFullRefund(){
|
||||
const isBookingWithFullRefund = this.booking.payment_history.some(payment =>
|
||||
payment.status === 7 && this.booking.amount === payment.refunded_amount
|
||||
);
|
||||
return isBookingWithFullRefund;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
pendingQueue(inComplete){
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<!-- Table Header -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="stock-code" width="10%">Stock Code</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$subtotal = "0";
|
||||
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
|
||||
$displayedSubtotal = 0;
|
||||
$currency_id = $transaction->owner->fix_currency_id;
|
||||
@endphp
|
||||
|
||||
<?php
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundServiceCharge;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
$booking = $po_order_transaction->owner ?? $booking;
|
||||
$paymentSum = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->get()
|
||||
->sum(function ($transaction) {
|
||||
return round($transaction->amount, 2);
|
||||
});
|
||||
|
||||
$totalPayment = 0;
|
||||
$average_currency_rate = $transaction->currency_rate;
|
||||
|
||||
$paymentSumRefund = 0;
|
||||
if ($paymentSum){
|
||||
$average_currency_rate = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->get()
|
||||
->sum(function ($transaction) {
|
||||
return $transaction->currency_rate;
|
||||
}) / $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->count();
|
||||
|
||||
// $refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1);
|
||||
// $refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1);
|
||||
|
||||
$totalPayment = $paymentSum;
|
||||
// $totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge;
|
||||
}
|
||||
else{
|
||||
$paymentSumRefund = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->where('status', ApprovalStatus::REFUNDED)
|
||||
->get()
|
||||
->sum(function ($transaction) {
|
||||
return round($transaction->amount, 2);
|
||||
});
|
||||
}
|
||||
?>
|
||||
|
||||
@if (!empty($po_order_transaction) && $po_order_transaction->transactionDetails)
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
@php
|
||||
$exactUnitPrice = ($currency_id) === 1 ? $transaction_detail->price : bcdiv($transaction_detail->price, $average_currency_rate, 7);
|
||||
$displayUnitPrice = round($exactUnitPrice, 2);
|
||||
@endphp
|
||||
|
||||
@continue($transaction_detail->product_name === 'Discount' && $displayUnitPrice < 0)
|
||||
|
||||
@php
|
||||
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
|
||||
$displayedItemTotal = round(bcmul($displayUnitPrice, $transaction_detail->quantity, 7), 2);
|
||||
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
|
||||
$subtotal = bcadd($subtotal, $itemTotal, 5);
|
||||
@endphp
|
||||
<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="15%" class="center top">
|
||||
{{ number_format($displayUnitPrice, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ number_format($displayedItemTotal, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
@if ($paymentSumRefund)
|
||||
<tr>
|
||||
<td width="5%" class="center top"></td>
|
||||
<td class="stock-code top" width="10%"></td>
|
||||
<td class="description">CANCEL FULL ORDER</td>
|
||||
<td width="10%" class="center top"></td>
|
||||
<td width="15%" class="center top"></td>
|
||||
<td width="20%" class="right top"></td>
|
||||
</tr>
|
||||
@endif
|
||||
@endif
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@php
|
||||
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5);
|
||||
if (!$totalPayment) {
|
||||
$serviceCharge = $transaction->service_charge;
|
||||
}
|
||||
else {
|
||||
$serviceCharge = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->where('status', ApprovalStatus::COMPLETED)
|
||||
->get()
|
||||
->sum(function ($transaction) {
|
||||
return $transaction->service_charge;
|
||||
});
|
||||
}
|
||||
if ($paymentSumRefund && $displayedSubtotal === 0){
|
||||
$subtotal = bcsub($paymentSumRefund, $serviceCharge, 5);
|
||||
$displayedSubtotal = bcsub($paymentSumRefund, $serviceCharge, 2);
|
||||
}
|
||||
@endphp
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">{{ number_format($displayedSubtotal, 2) }}</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">{{ number_format($serviceCharge, 2) }}</td>
|
||||
</tr>
|
||||
@if($voucher_redemption)
|
||||
<tr class="voucher">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
|
||||
<td class="right middle">{{ number_format($voucherDiscount, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
|
||||
@if($transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@php
|
||||
$displayedSubtotal = is_numeric($displayedSubtotal) ? sprintf('%F', $displayedSubtotal) : '0';
|
||||
$serviceCharge = is_numeric($serviceCharge) ? sprintf('%F', $serviceCharge) : '0';
|
||||
$tax = is_numeric($transaction->tax) ? sprintf('%F', $transaction->tax) : '0';
|
||||
$voucherDiscount = is_numeric($voucherDiscount) ? sprintf('%F', $voucherDiscount) : '0';
|
||||
|
||||
$displayedTotal = bcadd(
|
||||
bcadd(
|
||||
bcadd($displayedSubtotal, $serviceCharge, 5),
|
||||
$tax,
|
||||
5
|
||||
),
|
||||
$voucherDiscount,
|
||||
5
|
||||
);
|
||||
|
||||
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $serviceCharge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
$discrepancy = bcsub($expectedTotal, $displayedTotal, 5);
|
||||
$total = bcadd(bcadd(bcadd($subtotal, $serviceCharge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
|
||||
if ($totalPayment) {
|
||||
$expectedTotal = $totalPayment;
|
||||
$discrepancy = bcsub($expectedTotal, $displayedTotal, 5);
|
||||
$total = $totalPayment;
|
||||
}
|
||||
|
||||
if($paymentSumRefund){
|
||||
$total = $paymentSumRefund;
|
||||
}
|
||||
@endphp
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Adjustment</td>
|
||||
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ number_format($total, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
Reference in New Issue
Block a user