diff --git a/app/Classes/General/Eloquent/Filters/BelongsToSupplierId.php b/app/Classes/General/Eloquent/Filters/BelongsToSupplierId.php deleted file mode 100644 index 63536412..00000000 --- a/app/Classes/General/Eloquent/Filters/BelongsToSupplierId.php +++ /dev/null @@ -1,24 +0,0 @@ -whereHas('owner', function ($q) use ($value) { - $q->whereHas('transactions', function ($q2) use ($value) { - $q2->where('type', TransactionType::BILL)->where('issuer', $value); - }); - }); - } -} diff --git a/app/Classes/General/Eloquent/Filters/CurrencyRateIsNotEqual.php b/app/Classes/General/Eloquent/Filters/CurrencyRateIsNotEqual.php new file mode 100644 index 00000000..0372e760 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/CurrencyRateIsNotEqual.php @@ -0,0 +1,20 @@ +where('currency_rate', '!=', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/DoesNotHaveRefundInProgress.php b/app/Classes/General/Eloquent/Filters/DoesNotHaveRefundInProgress.php new file mode 100644 index 00000000..60618626 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/DoesNotHaveRefundInProgress.php @@ -0,0 +1,24 @@ +whereDoesntHave('transactions', function ($query) { + return $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION]); + }); + } +} diff --git a/app/Classes/General/Eloquent/Filters/IsPartialRefund.php b/app/Classes/General/Eloquent/Filters/IsPartialRefund.php new file mode 100644 index 00000000..1378a94c --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/IsPartialRefund.php @@ -0,0 +1,26 @@ +whereHas('owner', function ($q) use ($value) { + if ($value) { + $q->where('original_amount', '!=', DB::raw('transactions.original_amount')); + } else { + $q->where('original_amount', DB::raw('transactions.original_amount')); + } + }); + } +} diff --git a/app/Classes/General/Eloquent/Filters/OwnerDoesNotHaveTransactionType.php b/app/Classes/General/Eloquent/Filters/OwnerDoesNotHaveTransactionType.php new file mode 100644 index 00000000..4dcd401c --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/OwnerDoesNotHaveTransactionType.php @@ -0,0 +1,24 @@ +whereDoesntHave('owner', function($query) use($value) { + return $query->whereHas('transactions', function($query) use($value) { + return $query->where('transactions.type', $value); + }); + }); + } +} diff --git a/app/Classes/General/Eloquent/Filters/OwnerHasTransactionType.php b/app/Classes/General/Eloquent/Filters/OwnerHasTransactionType.php new file mode 100644 index 00000000..7f96643f --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/OwnerHasTransactionType.php @@ -0,0 +1,24 @@ +whereHas('owner', function($query) use($value) { + return $query->whereHas('transactions', function($query) use($value) { + return $query->where('transactions.type', $value); + }); + }); + } +} diff --git a/app/Classes/General/Eloquent/Filters/ReceiverIn.php b/app/Classes/General/Eloquent/Filters/ReceiverIn.php new file mode 100644 index 00000000..3ce91559 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/ReceiverIn.php @@ -0,0 +1,20 @@ +whereIn('receiver', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 0648629e..75ad76a1 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -75,10 +75,6 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $transaction = $this->fetchesTransaction->execute(['id' => $request->route('payment_id')]); - if ($transaction->transactions()->bills()->first()) { - throw new MalformedRequestException('Booking under white form cannot request for refund'); - } - $booking = $transaction->owner; $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); @@ -92,7 +88,8 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $refundAmount = bcdiv($request->input('amount'), $transaction->currency_rate, 7); // refund service charges if is fully refund - $refundTotal = ($refund + $request->input('amount')) == $transaction->original_amount ? $refundAmount + $transaction->service_charge + $transaction->tax : $refundAmount; + $isFullyRefund = ($refund + $request->input('amount')) == $transaction->original_amount; + $refundTotal = $isFullyRefund ? $refundAmount + $transaction->service_charge + $transaction->tax : $refundAmount; $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, 1, PaymentMethodType::CASH, @@ -100,9 +97,25 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $transaction->original_currency_id, $transaction->currency_rate, 0, 0, null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); - $transaction = $this->createsTransaction->execute($transaction, $object); + $refund_transaction = $this->createsTransaction->execute($transaction, $object); - return $this->resourceResponse(new TransactionResource($transaction)); + $bookingInWhiteForm = $transaction->transactions()->bills()->first(); + + // create supplier refund + if ($bookingInWhiteForm) { + $billNumber = $this->generatesTransactionBillNumber->execute('SRFD-'); + $supplierRefundTotal = bcdiv($request->input('amount'), $bookingInWhiteForm->currency_rate, 7); + + $object = new TransactionObject($billNumber, TransactionType::SUPPLIER_REFUND, 1, $bookingInWhiteForm->issuer, + 1, PaymentMethodType::CASH, + $supplierRefundTotal, $request->input('amount'), 1, + $transaction->original_currency_id, $bookingInWhiteForm->currency_rate, + 0, 0, null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); + + $transaction = $this->createsTransaction->execute($transaction, $object); + } + + return $this->resourceResponse(new TransactionResource($refund_transaction)); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php index 92a6343d..e2fc6dc1 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php @@ -77,13 +77,18 @@ class CreateBillGroupPaymentTransactionLogic extends AbstractControllerLogic $payAmount = floatval(str_replace(',', '', $request->input('payAmount'))); if($payAmount > round($outstanding_amount, 2)) throw new MalformedRequestException('Your payment must not be greater than '. $outstanding_amount .'.'); - $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-PYMT-'); - $transaction_object = new TransactionObject($billNumber, TransactionType::SUPPLIER_PAYMENT, $billGroup->issuer, - $billGroup->receiver, $billGroup->issuerCompany->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, - $payAmount, $payAmount, 1, 1, 1, - 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], ''); - $this->createsTransaction->execute($billGroup, $transaction_object); - + if ($billGroupPayment['outstanding_amount'] == 0 && $payAmount == 0) { + $billGroup->status = ApprovalStatus::APPROVED; + $billGroup->save(); + } else { + $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-PYMT-'); + $transaction_object = new TransactionObject($billNumber, TransactionType::SUPPLIER_PAYMENT, $billGroup->issuer, + $billGroup->receiver, $billGroup->issuerCompany->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payAmount, $payAmount, 1, 1, 1, + 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], ''); + $this->createsTransaction->execute($billGroup, $transaction_object); + } + return $this->resourceResponse(new BillGroupResource($billGroup)); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php index ef0560e7..33284726 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php @@ -102,6 +102,10 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic if ($refund->type !== TransactionType::SUPPLIER_REFUND) { throw new MalformedRequestException('Only transaction type supplier refund can be used for bill refund.'); } + + if ($refund->currency_rate == 1) { + throw new MalformedRequestException('Supplier refund with currecy rate 1 cannot be used for bill refund.'); + } } $amount = 0; diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateGroupLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateGroupLogic.php index aa432aea..f29db055 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateGroupLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateGroupLogic.php @@ -125,6 +125,18 @@ class UpdateGroupLogic extends AbstractControllerLogic $billTransaction = $this->updatesTransaction->execute($transaction, $object); + $supplierRefundTransactions = $transaction->owner->transactions()->supplierRefunds()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->get(); + + foreach ($supplierRefundTransactions as $supplierRefundTransaction) { + $claimBefore = $supplierRefundTransaction->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->exists(); + + if (!$claimBefore) { + $supplierRefundTransaction->currency_rate = $rate; + $supplierRefundTransaction->amount = $supplierRefundTransaction->original_amount / $rate; + $supplierRefundTransaction->save(); + } + } + $transferTransaction = $transaction->transactions()->where('type', TransactionType::TRANSFER_FEE)->first(); $transferFee = $this->calculatesTransactionTransferFee->execute($billTransaction->original_amount, $constant); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php index 09e4b102..02107a77 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -85,6 +85,8 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic $paymentTransaction = $refundTransaction->owner; + $supplierRefundTransaction = $paymentTransaction->transactions()->supplierRefunds()->where('status', [ApprovalStatus::PENDING_VERIFICATION])->first(); + $booking = $paymentTransaction->owner; $reference = $refundTransaction->amount == $paymentTransaction->amount ? 'Fully Refund for Ref. ' . $booking->marking : 'Partially Refund for Ref. ' . $booking->marking; @@ -93,6 +95,10 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic $this->creditWalletProcessor->execute($booking->company, $refundTransaction->type, $refundTransaction->amount, $reference); } + if ($supplierRefundTransaction) { + $this->updatesTransactionStatus->execute($supplierRefundTransaction, $request->route('status')); + } + $paidAmount = $paymentTransaction->original_amount - $this->calculatesBookingRefundAmount->calculateRefundAmount($paymentTransaction, $booking->fix_currency_id); if (!$paidAmount > 0) { $this->updatesTransactionStatus->execute($paymentTransaction, ApprovalStatus::REFUNDED); diff --git a/app/Classes/Modules/Transactions/Services/CalculatesBillGroupPaymentAmount.php b/app/Classes/Modules/Transactions/Services/CalculatesBillGroupPaymentAmount.php index 1a130b41..f41de813 100644 --- a/app/Classes/Modules/Transactions/Services/CalculatesBillGroupPaymentAmount.php +++ b/app/Classes/Modules/Transactions/Services/CalculatesBillGroupPaymentAmount.php @@ -7,11 +7,13 @@ use App\Models\BillGroup; class CalculatesBillGroupPaymentAmount { - public function execute(BillGroup $billGroup){ - $bill_refund_amount = floatval($billGroup->billRefunds->sum('amount')); - $floating_amount = floatval($billGroup->transactions()->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION])->sum('amount')); - $paid_amount = floatval($billGroup->transactions()->where('status', ApprovalStatus::APPROVED)->sum('amount')); + public function execute(BillGroup $billGroup) + { + $bill_refund_amount = round(floatval($billGroup->billRefunds->sum('amount')), 7); + $floating_amount = round(floatval($billGroup->transactions()->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION])->sum('amount')), 7); + $paid_amount = round(floatval($billGroup->transactions()->where('status', ApprovalStatus::APPROVED)->sum('amount')), 7); $outstanding_amount = $billGroup->amount - $bill_refund_amount - $paid_amount - $floating_amount + $billGroup->service_charge; + $outstanding_amount = round($outstanding_amount, 7); return [ 'bill_refund_amount' => $bill_refund_amount, @@ -20,5 +22,4 @@ class CalculatesBillGroupPaymentAmount 'outstanding_amount' => $outstanding_amount, ]; } - -} \ No newline at end of file +} diff --git a/app/Console/Commands/ExpiredBookingCommand.php b/app/Console/Commands/ExpiredBookingCommand.php index ca690c67..fe4f260e 100644 --- a/app/Console/Commands/ExpiredBookingCommand.php +++ b/app/Console/Commands/ExpiredBookingCommand.php @@ -62,13 +62,14 @@ class ExpiredBookingCommand extends Command foreach ($bookings as $booking) { $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); - Log::info("Expired Booking without payment & purchase order, booking id: " . $booking->id); + $this->info(Carbon::now() . " : Expired Booking without payment & purchase order, booking id: " . $booking->id); $transactions = $booking->transactions; foreach ($transactions as $transaction) { + $prevStatus = $transaction->status; $transaction->status = ApprovalStatus::EXPIRED; $transaction->save(); - Log::info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}"); + $this->info(Carbon::now() . " : Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); } } @@ -85,13 +86,14 @@ class ExpiredBookingCommand extends Command foreach ($bookings as $booking) { $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); - Log::info("Expired Booking without payment but with purchase order, booking id: " . $booking->id); + $this->info(Carbon::now() . " : Expired Booking without payment but with purchase order, booking id: " . $booking->id); $transactions = $booking->transactions; foreach ($transactions as $transaction) { + $prevStatus = $transaction->status; $transaction->status = ApprovalStatus::EXPIRED; $transaction->save(); - Log::info("Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}"); + $this->info(Carbon::now() . " : Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}"); } } } diff --git a/app/Console/Commands/ExpiredRefundedBookingCommand.php b/app/Console/Commands/ExpiredRefundedBookingCommand.php index 0fcbd87b..87f44f81 100644 --- a/app/Console/Commands/ExpiredRefundedBookingCommand.php +++ b/app/Console/Commands/ExpiredRefundedBookingCommand.php @@ -107,65 +107,84 @@ class ExpiredRefundedBookingCommand extends Command if (!$bookingPayment) { $bookingPayment = $booking->transactions()->payments()->whereIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED, ApprovalStatus::REJECTED])->orderBy('id', 'DESC')->first(); } + } + + if ($bookingPayment) { $status = ApprovalStatus::APPROVAL_STATUS_ID[$bookingPayment->status]; Log::info("Credit note transaction id: {$transaction->id}, the payment for the booking is in status {$status}"); - } - $bookingPaymentAmount = $bookingPayment->amount; - // check if the booking is fully refund - $amountDifference = bcsub($transaction->amount, $bookingPaymentAmount, 7); - if (abs($amountDifference) < 0.01) { - // rejecting booking payment transaction - // $bookingPayment->status = ApprovalStatus::REJECTED; - // $bookingPayment->save(); - - //expired booking - // $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); - Log::info("Credit note transaction id: {$transaction->id} is fully refunded, the refunded amount was {$transaction->amount} the payment reference is: {$transaction->payment_reference}"); - // Log::info("Credit note transaction id: {$transaction->id}, Rejected Booking Transaction Payment id: {$bookingPayment->id}, the payment amount was {$bookingPayment->amount}"); - // Log::info("Credit note transaction id: {$transaction->id}, Expired Booking id: {$booking->id}"); - } else { - Log::info("Credit note transaction id: {$transaction->id} is not fully refunded, the refunded amount was {$transaction->amount}, the payment amount was {$bookingPayment->amount}, the payment reference is: {$transaction->payment_reference}"); - } - - $refund = $bookingPayment->transactions()->refunds()->where('amount', $transaction->amount)->where('status', ApprovalStatus::APPROVED)->first(); - - $bookingInWhiteForm = $bookingPayment->transactions()->bills()->first(); - - if ($refund) { - Log::info("Credit note transaction id: {$transaction->id}, already created same amount of refund transaction for same booking payment transaction"); - } - - if ($bookingInWhiteForm) { - Log::info("Credit note transaction id: {$transaction->id}, booking is in white form"); - } - - if (!$refund && !$bookingInWhiteForm) { - $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); - - $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, - 1, PaymentMethodType::CASH, - $transaction->amount, $transaction->amount * $bookingPayment->currency_rate, 1, - $bookingPayment->original_currency_id, $bookingPayment->currency_rate, - 0, 0, null, ApprovalStatus::APPROVED, [], $bookingPayment->bill_no); + $bookingPaymentAmount = $bookingPayment->amount; + // check if the booking is fully refund + $amountDifference = bcsub($transaction->amount, $bookingPaymentAmount, 7); + + $isFullyRefund = false; + if (abs($amountDifference) < 0.01) { + $isFullyRefund = true; + // update fully refunded booking payment transaction + $bookingPayment->status = ApprovalStatus::REFUNDED; + $bookingPayment->save(); + + //expired booking + // $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED); + Log::info("Credit note transaction id: {$transaction->id} is fully refunded, the refunded amount was {$transaction->amount} the payment reference is: {$transaction->payment_reference}"); + // Log::info("Credit note transaction id: {$transaction->id}, Rejected Booking Transaction Payment id: {$bookingPayment->id}, the payment amount was {$bookingPayment->amount}"); + // Log::info("Credit note transaction id: {$transaction->id}, Expired Booking id: {$booking->id}"); + } else { + Log::info("Credit note transaction id: {$transaction->id} is not fully refunded, the refunded amount was {$transaction->amount}, the payment amount was {$bookingPayment->amount}, the payment reference is: {$transaction->payment_reference}"); + } + + $refund = $bookingPayment->transactions()->refunds()->where('amount', $transaction->amount)->where('status', ApprovalStatus::APPROVED)->first(); + + $bookingInWhiteForm = $bookingPayment->transactions()->bills()->first(); + + if ($refund) { + Log::info("Credit note transaction id: {$transaction->id}, already created same amount of refund transaction for same booking payment transaction"); + } - $transaction = $this->createsTransaction->execute($bookingPayment, $object); - } - - if ($bookingInWhiteForm) { - $refund = $bookingPayment->transactions()->supplierRefunds()->where('amount', $transaction->amount)->where('status', ApprovalStatus::APPROVED)->first(); - if (!$refund) { - $billNumber = $this->generatesTransactionBillNumber->execute('SRFD-'); - - $object = new TransactionObject($billNumber, TransactionType::SUPPLIER_REFUND, 1, $booking->company->id, + $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); + + $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, 1, PaymentMethodType::CASH, - $transaction->amount, $transaction->amount * $bookingPayment->currency_rate, 1, + $transaction->amount, $isFullyRefund ? $bookingPayment->original_amount : $transaction->amount * $bookingPayment->currency_rate, 1, $bookingPayment->original_currency_id, $bookingPayment->currency_rate, 0, 0, null, ApprovalStatus::APPROVED, [], $bookingPayment->bill_no); $transaction = $this->createsTransaction->execute($bookingPayment, $object); } + + if ($bookingInWhiteForm) { + $original_amount = $isFullyRefund ? $bookingPayment->original_amount : bcmul($transaction->amount, $bookingPayment->currency_rate, 7); + $supplier_refund_amount = bcdiv($original_amount, $bookingInWhiteForm->currency_rate, 7); + + Log::info("Credit note transaction id: {$transaction->id}, booking is in white form, white form currency rate is {$bookingInWhiteForm->currency_rate}"); + + // if ($isFullyRefund && $bookingInWhiteForm->currency_rate == 1) { + // dd ($bookingInWhiteForm->owner_id); + // } + + $refund = $bookingPayment->transactions()->supplierRefunds()->where('original_amount', $original_amount)->first(); + + if (!$refund) { + $billNumber = $this->generatesTransactionBillNumber->execute('SRFD-'); + + $object = new TransactionObject($billNumber, TransactionType::SUPPLIER_REFUND, 1, $bookingInWhiteForm->issuer, + 1, PaymentMethodType::CASH, + $supplier_refund_amount, $original_amount, 1, + $bookingPayment->original_currency_id, $bookingInWhiteForm->currency_rate, + 0, 0, null, ApprovalStatus::APPROVED, [], $bookingPayment->bill_no); + + $transaction = $this->createsTransaction->execute($bookingPayment, $object); + } + } + } else { + // $bookingPayment = $booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->orderBy('id', 'DESC')->first(); + + // if ($bookingPayment) { + // Log::info("Credit note transaction id: {$transaction->id}, booking payment refunded"); + // } else { + Log::info("Credit note transaction id: {$transaction->id}, booking payment not found, the payment reference is: {$transaction->payment_reference}"); + // } } } else { Log::info("Credit note transaction id: {$transaction->id}, booking marking not found, the payment reference is: {$transaction->payment_reference}"); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e3e0b48e..36a8c0e4 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -45,12 +45,13 @@ class Kernel extends ConsoleKernel ->withoutOverlapping(); $schedule->command('booking:expired') - ->dailyAt('02:00') - ->withoutOverlapping(); + ->dailyAt('02:00') + ->appendOutputTo(storage_path().'/logs/expire-booking.log') + ->withoutOverlapping(); - $schedule->command('purchaseOrder:autoFill') - ->dailyAt('03:00') - ->withoutOverlapping(); + // $schedule->command('purchaseOrder:autoFill') + // ->dailyAt('03:00') + // ->withoutOverlapping(); } /** diff --git a/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue b/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue index c826f154..284f681d 100644 --- a/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue @@ -96,11 +96,16 @@ -
+
+
+
+ +
+
diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index fa0912b8..365a1046 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -303,7 +303,7 @@
-
+
diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue index 75253aaa..c87122a5 100644 --- a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -38,6 +38,7 @@
Paid Amount: {{ paidAmount }}
+
Paid Amount: {{ (Math.round((this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2) }}
Refund Amount: {{ refundAmount }}
@@ -69,10 +70,11 @@ export default { }, data() { return { + refundAmount: (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2), refundMethod: { name: 'Fully Refund', status: false }, refundMethods: [ { name: 'Fully Refund', label: 'Full Refund' }, - // { name: 'Partially Refund', label: 'Partial Refund' } + { name: 'Partially Refund', label: 'Partial Refund' } ] } }, @@ -84,12 +86,8 @@ export default { } }, computed: { - refundAmount() { - // return (Math.round((this.data.booking.amount - this.totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2); - return (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2); - }, refundMaxValue() { - return this.refundAmount; + return (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2); }, paidAmount() { return this.data.original_amount; diff --git a/resources/assets/vue/components/bookings/elements/SupplierRefundComponent.vue b/resources/assets/vue/components/bookings/elements/SupplierRefundComponent.vue index 1a42fe6c..872ebef4 100644 --- a/resources/assets/vue/components/bookings/elements/SupplierRefundComponent.vue +++ b/resources/assets/vue/components/bookings/elements/SupplierRefundComponent.vue @@ -54,6 +54,10 @@ type: Number, required: true }, + inputPaymentTotal: { + type: Number, + required: true + }, refundTotal: { type: Number, required: true @@ -65,7 +69,11 @@ }, computed: { clickable(){ - return this.refundTotal < this.paymentTotal || this.supplierRefunds.some((i) => this.item.id === i.id ); + if (this.is1688Supplier) { + return this.refundTotal < this.inputPaymentTotal || this.supplierRefunds.some((i) => this.item.id === i.id ); + } else { + return this.refundTotal < this.paymentTotal || this.supplierRefunds.some((i) => this.item.id === i.id ); + } } }, data(){ diff --git a/resources/assets/vue/components/bookings/forms/SupplierWhiteFormPlaceOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/SupplierWhiteFormPlaceOrderFormComponent.vue index 9b7f8eb1..01c099ed 100644 --- a/resources/assets/vue/components/bookings/forms/SupplierWhiteFormPlaceOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/SupplierWhiteFormPlaceOrderFormComponent.vue @@ -108,9 +108,9 @@
Supplier Refund
- +
diff --git a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue index 1e743b9c..c68bab65 100644 --- a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue @@ -117,8 +117,7 @@
- - + @@ -203,7 +202,7 @@ // todo-refund: activate this for partial refund // this.$refs.pendingOrdersList.updateFilters({per_page: 10000, status: 2, type: 1, original_currency_id_in: [this.selectedCurrency.id], transaction_service_id: this.selectedService.id, is_not_fully_refunded: true}); - this.$refs.pendingOrdersList.updateFilters({per_page: 10000, status: 2, type: 1, original_currency_id_in: [this.selectedCurrency.id], transaction_service_id: this.selectedService.id}); + this.$refs.pendingOrdersList.updateFilters({per_page: 10, status: 2, type: 1, original_currency_id_in: [this.selectedCurrency.id], transaction_service_id: this.selectedService.id, does_not_have_refund_in_progress: true}); this.selectedSupplier.status = false; this.currencyDropdownLaunch.status = false; diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index d7223cc0..7ccdb219 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -81,11 +81,68 @@
+
+
+ Pre-Refund +
+
+
+
+ Fully Refund +
+
- + + +
+
+
+
+ Partial Refund +
+
+
+
+ + + +
+
+
+
+ Post-Refund +
+
+
+
+ Fully Refund +
+
+
+
+ + + +
+
+
+
+ Partial Refund +
+
+
+
+ +