diff --git a/src/pages/Customer/components/CustomerNewPayment.vue b/src/pages/Customer/components/CustomerNewPayment.vue index d27679e33..d78093c02 100644 --- a/src/pages/Customer/components/CustomerNewPayment.vue +++ b/src/pages/Customer/components/CustomerNewPayment.vue @@ -130,20 +130,22 @@ async function onDataSaved(formData, { id }) { } } -async function getSupplierClientReferences(value) { - if (!value) return (initialData.description = ''); - const params = { bankAccount: value }; - const { data } = await axios(`Clients/getClientOrSupplierReference`, { params }); - if (!data.clientId) { - initialData.description = t('Supplier Compensation Reference', { - supplierId: data.supplierId, - supplierName: data.supplierName, +async function getSupplierClientReferences(data) { + if (!data) return (initialData.description = ''); + const params = { bankAccount: data.compensationAccount }; + const { data: reference } = await axios(`Clients/getClientOrSupplierReference`, { + params, + }); + if (!reference) { + data.description = t('Supplier Compensation Reference', { + supplierId: reference.supplierId, + supplierName: reference.supplierName, }); return; } - initialData.description = t('Client Compensation Reference', { - clientId: data.clientId, - clientName: data.clientName, + data.description = t('Client Compensation Reference', { + clientId: reference.clientId, + clientName: reference.clientName, }); } @@ -252,7 +254,7 @@ async function getAmountPaid() { :label="t('Compensation account')" clearable v-model="data.compensationAccount" - @blur="getSupplierClientReferences(data.compensationAccount)" + @blur="getSupplierClientReferences(data)" /> @@ -260,7 +262,7 @@ async function getAmountPaid() { :label="t('Reference')" :required="true" clearable - v-model="initialData.description" + v-model="data.description" />