mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 23:13:59 +00:00
E-Invoice - Partial completion of => Doc Delivery - E-INVOICE, E-CN, E-RN
This commit is contained in:
+15
-6
@@ -16,6 +16,7 @@ use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\ValueObjects\Constants\RemarkRefundReason;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -86,9 +87,10 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
if(auth()->user()->type === 3) {
|
||||
throw new MalformedRequestException('You do not have the permission to refund the order.');
|
||||
}
|
||||
//cief todo: 90 - move this into rules
|
||||
// if(auth()->user()->type === 3) {
|
||||
// throw new MalformedRequestException('You do not have the permission to refund the order.');
|
||||
// }
|
||||
|
||||
$refundTransaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
@@ -100,14 +102,21 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
|
||||
$booking = $paymentTransaction->owner;
|
||||
|
||||
$reference = $paymentTransaction->amount - $refundTransaction->amount < 0.01 ? 'Fully Refund for Ref. ' . $booking->marking : 'Partially Refund for Ref. ' . $booking->marking;
|
||||
// $reference = $paymentTransaction->amount - $refundTransaction->amount < 0.01 ? 'Fully Refund for Ref. ' . $booking->marking : 'Partially Refund for Ref. ' . $booking->marking;
|
||||
if ($paymentTransaction->amount - $refundTransaction->amount < 0.01) {
|
||||
$reference = 'Return Inward for Ref. ' . $booking->marking;
|
||||
} else {
|
||||
$remarkGroup = RemarkRefundReason::REFUND_REASONS[$request->input('refundRemark')] ?? '';
|
||||
$reference = $remarkGroup ? $remarkGroup . ' for Ref. ' . $booking->marking : $request->input('refundRemark'). ' for Ref. ' . $booking->marking;
|
||||
}
|
||||
|
||||
$refundAmount = $this->calculatesBookingRefundAmount->calculateRefundAmount($paymentTransaction, $booking->fix_currency_id);
|
||||
|
||||
$paidAmount = $paymentTransaction->original_amount - $refundAmount;
|
||||
|
||||
if ($refundTransaction->status == ApprovalStatus::APPROVED) {
|
||||
$this->creditWalletProcessor->execute($booking->company, $refundTransaction->type, $refundTransaction->amount, $reference);
|
||||
$this->creditWalletProcessor->execute($booking->company, $refundTransaction->type, $refundTransaction->amount, $reference, $refundTransaction);
|
||||
|
||||
$po_transaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
|
||||
|
||||
if ($po_transaction) {
|
||||
@@ -129,4 +138,4 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user