mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-30 09:53:58 +00:00
make 1688 supplier in supplier currency order dashboard has the same flow as other supplier
This commit is contained in:
+40
-23
@@ -34,7 +34,8 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Create Supplier White Form Order',
|
||||
'message' => 'You have successfully created currency supplier white form order'
|
||||
@@ -84,7 +85,7 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
@@ -118,23 +119,23 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
|
||||
$service_charges = 0;
|
||||
|
||||
if ($supplier->id === 4548 || $supplier->id === 2729) {
|
||||
$amount = round(floatval(str_replace(',', '', $request->input('payment_total'))), 2);
|
||||
} else {
|
||||
$service_charges = round(floatval(str_replace(',', '', $request->input('service_charges'))), 2);
|
||||
}
|
||||
|
||||
// if ($supplier->id === 4548 || $supplier->id === 2729) {
|
||||
// $amount = round(floatval(str_replace(',', '', $request->input('payment_total'))), 2);
|
||||
// } else {
|
||||
$service_charges = round(floatval(str_replace(',', '', $request->input('service_charges'))), 2);
|
||||
// }
|
||||
|
||||
$rate = $original_amount / $amount;
|
||||
|
||||
if ($supplier->id === 4548 || $supplier->id === 2729) {
|
||||
$request['rate'] = $rate;
|
||||
$request['supplier_id'] = $supplier->id;
|
||||
foreach ($payments as $payment) {
|
||||
$request->route()->setParameter('id', $payment['id']);
|
||||
$this->updateGroupLogic->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
// if ($supplier->id === 4548 || $supplier->id === 2729) {
|
||||
// $request['rate'] = $rate;
|
||||
// $request['supplier_id'] = $supplier->id;
|
||||
// foreach ($payments as $payment) {
|
||||
// $request->route()->setParameter('id', $payment['id']);
|
||||
// $this->updateGroupLogic->execute($request);
|
||||
// }
|
||||
// }
|
||||
|
||||
$billGroup = new BillGroup();
|
||||
$billGroup->issuer = $supplier->id;
|
||||
$billGroup->receiver = 1;
|
||||
@@ -153,7 +154,7 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
$billGroup->groups()->sync($payment['id'], false);
|
||||
}
|
||||
|
||||
//create bill refund
|
||||
//create bill refund
|
||||
$amount += $service_charges;
|
||||
|
||||
foreach ($supplierRefunds as $supplierRefund) {
|
||||
@@ -179,17 +180,33 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('BRFD-');
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::BILL_REFUND, $supplier->id, 1,
|
||||
1, PaymentMethodType::CASH,
|
||||
$deductedRefundAmount, $deductedRefundOriginalAmount, $refund->currency_id,
|
||||
$refund->original_currency_id, $deductedRefundOriginalAmount / $deductedRefundAmount,
|
||||
0, 0, null, ApprovalStatus::APPROVED, []);
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::BILL_REFUND,
|
||||
$supplier->id,
|
||||
1,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$deductedRefundAmount,
|
||||
$deductedRefundOriginalAmount,
|
||||
$refund->currency_id,
|
||||
$refund->original_currency_id,
|
||||
$deductedRefundOriginalAmount / $deductedRefundAmount,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::APPROVED,
|
||||
[]
|
||||
);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($refund, $object);
|
||||
|
||||
$billGroup->billRefunds()->sync($transaction->id, false);
|
||||
}
|
||||
|
||||
$billGroup->amount = $amount;
|
||||
$billGroup->save();
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class CalculatesBillGroupPaymentAmount
|
||||
$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;
|
||||
$outstanding_amount = $billGroup->amount - $paid_amount - $floating_amount;
|
||||
$outstanding_amount = round($outstanding_amount, 7);
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user