mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-30 18:03:59 +00:00
Merge branch 'supplier-bill-group-dashboard' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
# Conflicts: # resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class BelongsToSupplierId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('owner', function ($q) use ($value) {
|
||||
$q->whereHas('transactions', function ($q2) use ($value) {
|
||||
$q2->where('type', TransactionType::BILL)->where('issuer', $value);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CurrencyRateIsNotEqual implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('currency_rate', '!=', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DoesNotHaveRefundInProgress implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('transactions', function ($query) {
|
||||
return $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class IsPartialRefund implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->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'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerDoesNotHaveTransactionType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('owner', function($query) use($value) {
|
||||
return $query->whereHas('transactions', function($query) use($value) {
|
||||
return $query->where('transactions.type', $value);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerHasTransactionType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('owner', function($query) use($value) {
|
||||
return $query->whereHas('transactions', function($query) use($value) {
|
||||
return $query->where('transactions.type', $value);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ReceiverIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereIn('receiver', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+12
-7
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+6
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-1
@@ -96,11 +96,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20">
|
||||
<div class="row m-t-20" v-if="selectedBillGroup.outstanding_amount > 0">
|
||||
<div class="col">
|
||||
<button id="payment-btn" class="btn btn-sm all-caps b-rad-none btn-success btn-block" @click="submitForm">Make Payment</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20" v-if="(selectedBillGroup.bill_refund_amount === selectedBillGroup.amount)">
|
||||
<div class="col">
|
||||
<button id="payment-btn" class="btn btn-sm all-caps b-rad-none btn-success btn-block" @click="submitForm">Complete Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -303,7 +303,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-10" v-show="[2, 3].includes(item.status) && (totalRequestedRefund + totalRefunds) < data.original_amount">
|
||||
<div class="col" v-if="!item.transaction_bill && $store.getters.isAdmin">
|
||||
<div class="col" v-if="$store.getters.isAdmin">
|
||||
<button class="btn btn-xs all-caps b-rad-none bg-master-lighter btn-block no-border requestModal" data-type="transferSummary">Request Refund</button>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="transferSummary" size="large">
|
||||
<refund-confirmation-component :data="data" :section="section" :totalRefunds="totalRequestedRefund + totalRefunds"></refund-confirmation-component>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<div class="row m-t-10 m-b-10">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-10 m-b-5">Paid Amount: {{ paidAmount }}</div>
|
||||
<div class="font-heading all-caps fs-10 m-b-5" v-if="this.data.refunded_amount > 0">Paid Amount: {{ (Math.round((this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2) }}</div>
|
||||
<div class="font-heading all-caps fs-10 m-b-5">Refund Amount: {{ refundAmount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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;
|
||||
|
||||
@@ -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(){
|
||||
|
||||
+2
-2
@@ -108,9 +108,9 @@
|
||||
<div class="m-b-20">
|
||||
<small class="all-caps muted fs-15">Supplier Refund</small>
|
||||
</div>
|
||||
<list-component :key="supplierRefundListKey" section="supplierRefundListSection" :options="{'per_page': 20, 'type': 15, 'status': 2, 'belongs_to_supplier_id': this.supplier.id}" :endpoint="route('api.transaction.list')">
|
||||
<list-component :key="supplierRefundListKey" section="supplierRefundListSection" :options="{'per_page': 20, 'type': 15, 'currency_rate_is_not_equal': 1, 'status': 2, 'receiver_in': [this.supplier.id]}" :endpoint="route('api.transaction.list')">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<supplier-refund-component section="supplierRefundListSection" :data="data" :is1688Supplier="is1688Supplier" :payments="payments" :supplierRefunds="supplierRefunds" :refundTotal="refundTotal" :paymentTotal="paymentTotal" v-on:input="refundOrder($event)"></supplier-refund-component>
|
||||
<supplier-refund-component section="supplierRefundListSection" :data="data" :is1688Supplier="is1688Supplier" :payments="payments" :supplierRefunds="supplierRefunds" :refundTotal="refundTotal" :paymentTotal="paymentTotal" :inputPaymentTotal="inputPaymentTotal" v-on:input="refundOrder($event)"></supplier-refund-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
|
||||
+2
-3
@@ -117,8 +117,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<!-- CIEF TODO: For easy revert to old code -->
|
||||
<list-component ref="pendingOrdersList" section="pendingOrdersSection" :endpoint="route('api.transaction.list')" :options="{per_page: 5, status: 2, owner_type: 'App\\Models\\Booking', is_not_fully_refunded: true, type: 1, original_currency_id_in: [selectedCurrency.id], transaction_service_id: selectedService.id}">
|
||||
<list-component ref="pendingOrdersList" section="pendingOrdersSection" :endpoint="route('api.transaction.list')" :options="{per_page: 5, status: 2, owner_type: 'App\\Models\\Booking', type: 1, original_currency_id_in: [selectedCurrency.id], transaction_service_id: selectedService.id, does_not_have_refund_in_progress: true}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<supplier-pending-order-component :data="data" v-on:input="updateOrder($event)"></supplier-pending-order-component>
|
||||
</template>
|
||||
@@ -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;
|
||||
|
||||
@@ -81,11 +81,68 @@
|
||||
</div>
|
||||
<div class="row tabsContainer hide tabContent" tab-name="refunds">
|
||||
<div class="col">
|
||||
<div class="row m-b-15 p-b-10 b-b b-grey">
|
||||
<div class="col">
|
||||
<small class="all-caps muted fs-14 bold">Pre-Refund</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15 p-b-10 b-grey">
|
||||
<div class="col text-center">
|
||||
<small class="all-caps muted fs-10">Fully Refund</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="listRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1}">
|
||||
<list-component key="2" section="listPreFullRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_does_not_have_transaction_type: 3, is_partial_refund: false}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<refund-verification-component section="listRefundTransactionSection" :data="data"></refund-verification-component>
|
||||
<refund-verification-component section="listPreFullRefundTransactionSection" :data="data"></refund-verification-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15 p-b-10 b-grey">
|
||||
<div class="col text-center">
|
||||
<small class="all-caps muted fs-10">Partial Refund</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="3" section="listPrePartialRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_does_not_have_transaction_type: 3, is_partial_refund: true}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<refund-verification-component section="listPrePartialRefundTransactionSection" :data="data"></refund-verification-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15 p-b-10 p-t-10 b-t b-b b-grey">
|
||||
<div class="col">
|
||||
<small class="all-caps muted fs-14 bold">Post-Refund</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15 p-b-10 b-grey">
|
||||
<div class="col text-center">
|
||||
<small class="all-caps muted fs-10">Fully Refund</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="4" section="listPostFullRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_has_transaction_type: 3, is_partial_refund: false}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<refund-verification-component section="listPostFullRefundTransactionSection" :data="data"></refund-verification-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15 p-b-10 b-grey">
|
||||
<div class="col text-center">
|
||||
<small class="all-caps muted fs-10">Partial Refund</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="5" section="listPostPartialRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1, owner_has_transaction_type: 3, is_partial_refund: true}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<refund-verification-component section="listPostPartialRefundTransactionSection" :data="data"></refund-verification-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user