diff --git a/app/Classes/ValueObjects/Constants/BankAccountType.php b/app/Classes/ValueObjects/Constants/BankAccountType.php index c1ae288e..0393091f 100644 --- a/app/Classes/ValueObjects/Constants/BankAccountType.php +++ b/app/Classes/ValueObjects/Constants/BankAccountType.php @@ -8,6 +8,8 @@ final class BankAccountType { public const EXTERNAL = 2; - public const ALIPAY= 3; + public const ALIPAY_1688 = 3; + + public const ALIPAY_RECIPIENT = 4; } diff --git a/app/Console/Commands/DeleteDuplicate1688BankAccount.php b/app/Console/Commands/DeleteDuplicate1688BankAccount.php new file mode 100644 index 00000000..57b65733 --- /dev/null +++ b/app/Console/Commands/DeleteDuplicate1688BankAccount.php @@ -0,0 +1,75 @@ +get(); + + $groupedBanks = $records->groupBy(function($item, $key) { + return $item['company_id'] . '-' . $item['account_no']; + }); + + foreach ($groupedBanks as $key => $banksWithSameUserAndAccountNo) { + // Sort banks by created_at or updated_at to find the latest one + $sortedBanks = $banksWithSameUserAndAccountNo->sortByDesc('created_at'); + + // Retain the latest bank + $latestBank = $sortedBanks->first(); + + // Get all IDs except the latest one + $idsToDelete = $sortedBanks->pluck('id')->slice(1); + + foreach ($idsToDelete as $id) { + Booking::where('bank_id', $id)->update([ + 'bank_id' => $latestBank->id + ]); + } + + $this->info('for company id: ' . $latestBank->company_id . ', account no: ' . $latestBank->account_no . ', duplicated id: ' . $idsToDelete); + // Delete the rest + Bank::whereIn('id', $idsToDelete)->delete(); + } + } +} diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index eff2bd1b..a8103e8b 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -56,7 +56,7 @@ class CompanyResource extends JsonResource 'last_payment' => $lastPayment ? $lastPayment->created_at->diffForHumans() : 'No Payments', 'personal_banks' => BankResource::collection($this->banks->where('type', BankAccountType::PERSONAL)), 'recipient_banks' => [ - 'accounts' => BankResource::collection($this->banks->where('type', BankAccountType::EXTERNAL)), + 'accounts' => BankResource::collection($this->banks->whereIn('type', [BankAccountType::EXTERNAL, BankAccountType::ALIPAY_1688, BankAccountType::ALIPAY_RECIPIENT])), 'default' => new BankResource($this->banks->where('type', BankAccountType::EXTERNAL)->where('default', true)->first()) ], 'segments' => SegmentResource::collection($this->segments), diff --git a/public/images/alipay_logo.png b/public/images/alipay_logo.png new file mode 100644 index 00000000..5bd88d72 Binary files /dev/null and b/public/images/alipay_logo.png differ diff --git a/resources/assets/vue/components/banks/elements/BankAccountComponent.vue b/resources/assets/vue/components/banks/elements/BankAccountComponent.vue index 0585e4aa..54d01e04 100644 --- a/resources/assets/vue/components/banks/elements/BankAccountComponent.vue +++ b/resources/assets/vue/components/banks/elements/BankAccountComponent.vue @@ -11,7 +11,7 @@
-
{{item.type === 2 ? item.reference : item.company_business_type === 1 ? 'Company\'s Bank Account' : 'Personal Bank Account'}}
+
{{item.type === 2 ? item.reference : item.type === 4 ? 'Alipay' : item.company_business_type === 1 ? 'Company\'s Bank Account' : 'Personal Bank Account'}}
default
diff --git a/resources/assets/vue/components/banks/forms/AlipayAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/AlipayAccountFormComponent.vue new file mode 100644 index 00000000..e1d71d62 --- /dev/null +++ b/resources/assets/vue/components/banks/forms/AlipayAccountFormComponent.vue @@ -0,0 +1,127 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue index 84cba3e6..3e19e8e3 100644 --- a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue @@ -100,12 +100,14 @@
-
+
- + + +
@@ -116,7 +118,7 @@
-
+
@@ -142,16 +144,17 @@
-
-
+
- + +
@@ -315,6 +318,7 @@ data(){ return { createBank: false, + existingBank: false, recipientBanks: [], dropdownStatus: false, account_no: '', @@ -323,12 +327,36 @@ oneSixEightEightServiceIds: [4, 10], } }, + watch: { + 'data.serviceType.id': function() { + this.clearAccount(); + } + }, computed: { formDisabled(){ - return !!Object.keys(this.parameters.bankAccount).length; + return this.existingBank; }, isOneSizEightEightOrder() { return this.oneSixEightEightServiceIds.includes(this.data.serviceType.id); + }, + isAlipayOrder() { + return this.data.serviceType.id === 11; + }, + filterBankType() { + if (this.isAlipayOrder) { + return [4]; + } + + if (this.isOneSizEightEightOrder) { + return [3]; + } + + if (!this.isAlipayOrder && !this.isOneSizEightEightOrder) { + return [1, 2]; + } + + + return []; } }, created(){ @@ -345,12 +373,14 @@ }, selectBank(bank){ this.account_no = bank.account_no; - this.createBank = true; + this.createBank = false; + this.existingBank = true; this.parameters.bankAccount = bank; this.dropdownStatus = false; }, clearAccount(){ this.createBank = false; + this.existingBank = false; this.account_no = ''; this.parameters.bankAccount = {}; } diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 10246745..a3116164 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -61,7 +61,8 @@
-
+ +
-
{{item.bank.holder_name}} {{item.bank.type === 3 ? item.bank.account_no : item.bank.account_no.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim()}}
+
{{item.bank.holder_name}} {{[3, 4].includes(item.bank.type) ? item.bank.account_no : item.bank.account_no.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim()}}
-
+
{{item.bank.bank_name}} ({{item.bank.bank_branch}}) ({{item.bank.swift}})
diff --git a/resources/assets/vue/components/companies/elements/CompanyBankAccountComponent.vue b/resources/assets/vue/components/companies/elements/CompanyBankAccountComponent.vue index 913dd328..1b911592 100644 --- a/resources/assets/vue/components/companies/elements/CompanyBankAccountComponent.vue +++ b/resources/assets/vue/components/companies/elements/CompanyBankAccountComponent.vue @@ -11,7 +11,7 @@
-
{{item.type === 2 ? item.reference : item.company_business_type === 1 ? 'Company\'s Bank Account' : 'Personal Bank Account'}}
+
{{item.type === 2 ? item.reference : item.type === 4 ? 'Alipay' : item.company_business_type === 1 ? 'Company\'s Bank Account' : 'Personal Bank Account'}}