diff --git a/src/components/common/VnBankDetailsForm.vue b/src/components/common/VnBankDetailsForm.vue
new file mode 100644
index 000000000..4e13a4d86
--- /dev/null
+++ b/src/components/common/VnBankDetailsForm.vue
@@ -0,0 +1,93 @@
+
+
+ (bankEntities = data)"
+ />
+
+
+
+ {{ t('components.iban_tooltip') }}
+
+
+
+
+
+
+
+
+
+
+ {{ scope.opt.bic }}
+ {{ scope.opt.name }}
+
+
+
+
+
diff --git a/src/components/common/VnInputBic.vue b/src/components/common/VnInputBic.vue
deleted file mode 100644
index b29644912..000000000
--- a/src/components/common/VnInputBic.vue
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
- {{ t('components.iban_tooltip') }}
-
-
-
-
diff --git a/src/components/common/__tests__/VnBankDetailsForm.spec.js b/src/components/common/__tests__/VnBankDetailsForm.spec.js
new file mode 100644
index 000000000..9d6ade902
--- /dev/null
+++ b/src/components/common/__tests__/VnBankDetailsForm.spec.js
@@ -0,0 +1,43 @@
+import { createWrapper } from 'app/test/vitest/helper';
+import VnBankDetailsForm from 'components/common/VnBankDetailsForm.vue';
+import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest';
+
+describe('VnBankDetail Component', () => {
+ let vm;
+ let wrapper;
+ const bankEntities = [
+ { id: 2100, bic: 'CAIXESBBXXX', name: 'CaixaBank' },
+ { id: 1234, bic: 'TESTBIC', name: 'Test Bank' },
+ ];
+ const correctIban = 'ES6621000418401234567891';
+
+ beforeAll(() => {
+ wrapper = createWrapper(VnBankDetailsForm, {
+ $props: {
+ iban: null,
+ bankEntityFk: null,
+ disableElement: false,
+ },
+ });
+ vm = wrapper.vm;
+ wrapper = wrapper.wrapper;
+ });
+
+ afterEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it('should update bankEntityFk when IBAN exists in bankEntities', async () => {
+ vm.bankEntities = bankEntities;
+
+ await vm.autofillBic(correctIban);
+ expect(vm.bankEntityFk).toBe(2100);
+ });
+
+ it('should set bankEntityFk to null when IBAN bank code is not found', async () => {
+ vm.bankEntities = bankEntities;
+
+ await vm.autofillBic('ES1234567891324567891234');
+ expect(vm.bankEntityFk).toBe(null);
+ });
+});
diff --git a/src/pages/Customer/Card/CustomerBillingData.vue b/src/pages/Customer/Card/CustomerBillingData.vue
index e4b6f8365..fdcbf75d4 100644
--- a/src/pages/Customer/Card/CustomerBillingData.vue
+++ b/src/pages/Customer/Card/CustomerBillingData.vue
@@ -1,5 +1,4 @@
-
+
{
/>
-
- (data.bankEntityFk = bankEntityFk)"
+ {
+ if (!iban || !bankEntityFk) return;
+ data.iban = iban;
+ data.bankEntityFk = bankEntityFk;
+ }
+ "
/>
-
-
-
-
-
-
-
- {{ scope.opt.bic }}
- {{ scope.opt.name }}
-
-
-
-
-
diff --git a/src/pages/Supplier/Card/SupplierAccounts.vue b/src/pages/Supplier/Card/SupplierAccounts.vue
index 2e3acdfb6..d26151994 100644
--- a/src/pages/Supplier/Card/SupplierAccounts.vue
+++ b/src/pages/Supplier/Card/SupplierAccounts.vue
@@ -7,12 +7,11 @@ import FetchData from 'components/FetchData.vue';
import CrudModel from 'components/CrudModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
-import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
-import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import { useQuasar } from 'quasar';
+import VnBankDetailsForm from 'src/components/common/VnBankDetailsForm.vue';
const { t } = useI18n();
const { notify } = useNotify();
@@ -26,11 +25,6 @@ const wireTransferFk = ref(null);
const bankEntitiesOptions = ref([]);
const filteredBankEntitiesOptions = ref([]);
-const onBankEntityCreated = async (dataSaved, rowData) => {
- await bankEntitiesRef.value.fetch();
- rowData.bankEntityFk = dataSaved.id;
-};
-
const onChangesSaved = async () => {
if (supplier.value.payMethodFk !== wireTransferFk.value)
quasar
@@ -56,23 +50,6 @@ const setWireTransfer = async () => {
await axios.patch(`Suppliers/${route.params.id}`, params);
notify('globals.dataSaved', 'positive');
};
-
-function findBankFk(value, row) {
- row.bankEntityFk = null;
- if (!value) return;
-
- const bankEntityFk = bankEntitiesOptions.value.find((b) => b.id == value.slice(4, 8));
- if (bankEntityFk) row.bankEntityFk = bankEntityFk.id;
-}
-
-function bankEntityFilter(val) {
- const needle = val.toLowerCase();
- filteredBankEntitiesOptions.value = bankEntitiesOptions.value.filter(
- (bank) =>
- bank.bic.toLowerCase().startsWith(needle) ||
- bank.name.toLowerCase().includes(needle),
- );
-}
- findBankFk(value, row)"
- :required="true"
- >
-
-
- {{ t('components.iban_tooltip') }}
-
-
-
-
-
-
- onBankEntityCreated(requestResponse, row)
- "
- />
-
-
-
-
- {{ scope.opt.bic }}
- {{ scope.opt.name }}
-
-
-
-
+ {
+ row.iban = iban;
+ row.bankEntityFk = bankEntityFk;
+ }
+ "
+ />
{
).data?.payMethodFk;
});
-async function handleNewBankEntity(data, resp) {
- await bankEntitiesRef.value.fetch();
- data.bankEntityFk = resp.id;
- bankEntitiesOptions.value.push(resp);
-}
-
function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {};
data.postcode = code;
@@ -323,51 +315,19 @@ function generateCodeUser(worker) {
(val) => !val && delete data.payMethodFk
"
/>
- (data.bankEntityFk = bankEntityFk)
- "
- />
-
-
- handleNewBankEntity(data, resp)
- "
- />
-
-
-
-
- {{ scope.opt.bic }}
- {{ scope.opt.name }}
-
-
-
-
+ {
+ data.iban = iban;
+ data.bankEntityFk = bankEntityFk;
+ }
+ "
+ />