make 1688 supplier in supplier currency order dashboard has the same flow as other supplier

This commit is contained in:
Jia Sheng
2024-07-31 22:39:04 +08:00
parent 1467d0880f
commit 7e42bda76e
6 changed files with 55 additions and 36 deletions
@@ -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 [
+9 -8
View File
@@ -30,6 +30,7 @@ class BillGroupResource extends JsonResource
'original_currency' => new CurrencyResource($this->original_currency),
'issuer_name' => $this->issuerCompany->name,
'issuer_id' => $this->issuerCompany->id,
'invoice_amount' => (float) $this->amount + $bill_refund_amount - $this->service_charge,
'amount' => (float) $this->amount,
'service_charge' => (float) $this->service_charge,
'currency' => new CurrencyResource($this->currency),
@@ -48,12 +49,12 @@ class BillGroupResource extends JsonResource
'type' => (int) $transaction->type,
'bill_no' => $transaction->bill_no,
'payment_method' => (float) $transaction->payment_method,
'amount' => (double) $transaction->amount,
'original_amount' => (double) $transaction->original_amount,
'amount' => (float) $transaction->amount,
'original_amount' => (float) $transaction->original_amount,
'currency' => new CurrencyResource($transaction->currency),
'original_currency' => new CurrencyResource($transaction->original_currency),
'service_charge' => (double) $transaction->service_charge,
'tax' => (double) $transaction->tax,
'service_charge' => (float) $transaction->service_charge,
'tax' => (float) $transaction->tax,
'status' => (int) $transaction->status,
'statusText' => ApprovalStatus::APPROVAL_STATUS_ID[(int) $transaction->status],
'documents' => $transaction->documents()->first() ? new DocumentResource($transaction->documents()->first()) : null,
@@ -66,12 +67,12 @@ class BillGroupResource extends JsonResource
'type' => (int) $transaction->type,
'bill_no' => $transaction->bill_no,
'payment_method' => (float) $transaction->payment_method,
'amount' => (double) $transaction->amount,
'original_amount' => (double) $transaction->original_amount,
'amount' => (float) $transaction->amount,
'original_amount' => (float) $transaction->original_amount,
'currency' => new CurrencyResource($transaction->currency),
'original_currency' => new CurrencyResource($transaction->original_currency),
'service_charge' => (double) $transaction->service_charge,
'tax' => (double) $transaction->tax,
'service_charge' => (float) $transaction->service_charge,
'tax' => (float) $transaction->tax,
'status' => (int) $transaction->status,
'statusText' => ApprovalStatus::APPROVAL_STATUS_ID[(int) $transaction->status],
'updated_at' => Carbon::parse($transaction->updated_at)->format('d-m-Y h:i:s A'),
@@ -19,7 +19,7 @@
<div class="font-heading all-caps fs-12"></div>
</div>
<div class="col-auto text-right" v-if="selectedBillGroup.id">
<div class="font-heading fs-12">{{selectedBillGroup.currency.short_code}} {{formatAmount(selectedBillGroup.amount - selectedBillGroup.service_charge)}}</div>
<div class="font-heading fs-12">{{selectedBillGroup.currency.short_code}} {{formatAmount((selectedBillGroup.invoice_amount))}}</div>
</div>
<div class="col-auto text-right" v-else>
<div class="font-heading fs-12">MYR 0.00</div>
@@ -108,7 +108,7 @@
<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, 'currency_rate_is_not_equal': 1, 'status': 2, 'receiver_in': [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, ...(this.supplier.id == 4548 && { 'created_after_or_equal': '01-08-2024' }), '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" :inputPaymentTotal="inputPaymentTotal" v-on:input="refundOrder($event)"></supplier-refund-component>
</template>
@@ -207,7 +207,8 @@
return this.originalTotal && paymentTotal > 0 ? (this.originalTotal / paymentTotal).toFixed(5) : 1;
},
is1688Supplier(){
return (this.supplier.id === 4548 || this.supplier.id === 2729)
// return (this.supplier.id === 4548 || this.supplier.id === 2729)
return false;
}
},
methods: {
@@ -46,7 +46,7 @@
</div>
<div class="row" v-if="this.selectedSupplier.id !== ''">
<div class="col">
<list-component :key="currencyOrderKey" section="transactionGroupsListPaymentSection" :options="{'per_page': 20, 'without_bill_group': true, 'issuer_in': [this.selectedSupplier.id]}" :endpoint="route('api.transaction.group.list')">
<list-component :key="currencyOrderKey" section="transactionGroupsListPaymentSection" :options="{'per_page': 20, 'without_bill_group': true, ...(this.selectedSupplier.id == 4548 && { 'created_after_or_equal': '01-08-2024' }), 'issuer_in': [this.selectedSupplier.id]}" :endpoint="route('api.transaction.group.list')">
<template slot="list" slot-scope="{data}">
<transaction-group-payment-component section="transactionGroupsListPaymentSection" :data="data" :payments="payments" v-on:input="updateOrder($event)" :emptyPaymentList="emptyPaymentList"></transaction-group-payment-component>
</template>