perf: refs #7134 use ForModelPopup
This commit is contained in:
parent
34d08e4bfe
commit
9121e79533
|
@ -9,7 +9,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
insertable: {
|
insertable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -79,5 +79,10 @@ function accountShortToStandard() {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QInput @keydown="handleKeydown" ref="vnInputRef" v-model="internalValue" />
|
<QInput
|
||||||
|
@keydown="handleKeydown"
|
||||||
|
ref="vnInputRef"
|
||||||
|
v-model="internalValue"
|
||||||
|
:maxlength="10"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -106,8 +106,6 @@ function handleLocation(data, location) {
|
||||||
:label="t('supplier.fiscalData.account')"
|
:label="t('supplier.fiscalData.account')"
|
||||||
clearable
|
clearable
|
||||||
data-cy="supplierFiscalDataAccount"
|
data-cy="supplierFiscalDataAccount"
|
||||||
insertable
|
|
||||||
:maxlength="10"
|
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('supplier.fiscalData.sageTaxTypeFk')"
|
:label="t('supplier.fiscalData.sageTaxTypeFk')"
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { useDialogPluginComponent } from 'quasar';
|
||||||
import { usePrintService } from 'composables/usePrintService';
|
import { usePrintService } from 'composables/usePrintService';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import FormModel from 'components/FormModel.vue';
|
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInputNumber from 'components/common/VnInputNumber.vue';
|
import VnInputNumber from 'components/common/VnInputNumber.vue';
|
||||||
|
@ -74,39 +74,44 @@ const filterRecordFindOne = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialData = reactive({
|
const initialData = reactive({
|
||||||
amountPaid: $props.totalCredit,
|
received: '2001-01-01T11:00:00.000Z',
|
||||||
supplierFk: route.params.id,
|
supplierFk: '1',
|
||||||
companyFk: $props.companyId,
|
amount: 123123,
|
||||||
bankFk: $props.bankId,
|
|
||||||
email: recordFindOne.value.email,
|
|
||||||
currencyFk: 1,
|
currencyFk: 1,
|
||||||
|
bankFk: 3,
|
||||||
|
concept: 'Credit Card, ',
|
||||||
|
amountToReturn: null,
|
||||||
|
orderBy: 'issued',
|
||||||
|
payMethodFk: 1,
|
||||||
|
bankingFees: 0,
|
||||||
|
companyFk: 442,
|
||||||
|
divisa: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
urlCreate.value = `Suppliers/${route.params.id}/createReceipt`;
|
urlCreate.value = `Suppliers/${route.params.id}/createPayment`;
|
||||||
});
|
});
|
||||||
|
|
||||||
function setPaymentType(accounting) {
|
function setPaymentType(accounting) {
|
||||||
if (!accounting) return;
|
if (!accounting) return;
|
||||||
accountingType.value = accounting.accountingType;
|
accountingType.value = accounting.accountingType;
|
||||||
|
|
||||||
initialData.description = [];
|
initialData.concept = [];
|
||||||
initialData.payed = Date.vnNew();
|
initialData.received = Date.vnNew();
|
||||||
isCash.value = accountingType.value.code == 'cash';
|
isCash.value = accountingType.value.code == 'cash';
|
||||||
viewReceipt.value = isCash.value;
|
viewReceipt.value = isCash.value;
|
||||||
if (accountingType.value.daysInFuture)
|
if (accountingType.value.daysInFuture)
|
||||||
initialData.payed.setDate(
|
initialData.received.setDate(
|
||||||
initialData.payed.getDate() + accountingType.value.daysInFuture
|
initialData.received.getDate() + accountingType.value.daysInFuture
|
||||||
);
|
);
|
||||||
maxAmount.value = accountingType.value && accountingType.value.maxAmount;
|
maxAmount.value = accountingType.value && accountingType.value.maxAmount;
|
||||||
|
|
||||||
if (accountingType.value.code == 'compensation')
|
if (accountingType.value.code == 'compensation') return (initialData.concept = '');
|
||||||
return (initialData.description = '');
|
if (accountingType.value.receiptconcept)
|
||||||
if (accountingType.value.receiptDescription)
|
initialData.concept.push(accountingType.value.receiptconcept);
|
||||||
initialData.description.push(accountingType.value.receiptDescription);
|
if (initialData.concept) initialData.concept.push(initialData.concept);
|
||||||
if (initialData.description) initialData.description.push(initialData.description);
|
|
||||||
|
|
||||||
initialData.description = initialData.description.join(', ');
|
initialData.concept = initialData.concept.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
const calculateFromAmount = (event) => {
|
const calculateFromAmount = (event) => {
|
||||||
|
@ -115,17 +120,18 @@ const calculateFromAmount = (event) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const calculateFromDeliveredAmount = (event) => {
|
const calculateFromDeliveredAmount = (event) => {
|
||||||
initialData.amountToReturn = parseFloat(event) - initialData.amountPaid;
|
initialData.amountToReturn = parseFloat(event) - initialData.amount;
|
||||||
};
|
};
|
||||||
|
|
||||||
function onBeforeSave(data) {
|
function onBeforeSave(data) {
|
||||||
const exceededAmount = data.amountPaid > maxAmount.value;
|
const exceededAmount = data.amount > maxAmount.value;
|
||||||
if (isCash.value && exceededAmount)
|
if (isCash.value && exceededAmount)
|
||||||
return notify(t('Amount exceeded', { maxAmount: maxAmount.value }), 'negative');
|
return notify(t('Amount exceeded', { maxAmount: maxAmount.value }), 'negative');
|
||||||
|
|
||||||
if (isCash.value && shouldSendEmail.value && !data.email)
|
if (isCash.value && shouldSendEmail.value && !data.email)
|
||||||
return notify(t(`There is no assigned email for this supplier`), 'negative');
|
return notify(t(`There is no assigned email for this supplier`), 'negative');
|
||||||
|
|
||||||
|
data.dueDate = data.received;
|
||||||
data.bankFk = data.bankFk.id;
|
data.bankFk = data.bankFk.id;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -144,25 +150,7 @@ async function onDataSaved(formData, { id }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function accountShortToStandard({ target: { value } }) {
|
async function getAmount() {
|
||||||
if (!value) return (initialData.description = '');
|
|
||||||
initialData.compensationAccount = value.replace('.', '0'.repeat(11 - value.length));
|
|
||||||
const params = { bankAccount: initialData.compensationAccount };
|
|
||||||
const { data } = await axios(`Clients/getClientOrSupplierReference`, { params });
|
|
||||||
if (!data.clientId) {
|
|
||||||
initialData.description = t('Supplier Compensation Reference', {
|
|
||||||
supplierId: data.supplierId,
|
|
||||||
supplierName: data.supplierName,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
initialData.description = t('Client Compensation Reference', {
|
|
||||||
clientId: data.clientId,
|
|
||||||
clientName: data.clientName,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getAmountPaid() {
|
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
supplierFk: route.params.id,
|
supplierFk: route.params.id,
|
||||||
|
@ -170,7 +158,7 @@ async function getAmountPaid() {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const { data } = await getSupplierRisk(filter);
|
const { data } = await getSupplierRisk(filter);
|
||||||
initialData.amountPaid = (data?.length && data[0].amount) || undefined;
|
initialData.amount = (data?.length && data[0].amount) || undefined;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -195,7 +183,7 @@ async function getAmountPaid() {
|
||||||
@on-fetch="(data) => (currenciesOptions = data)"
|
@on-fetch="(data) => (currenciesOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FormModel
|
<FormModelPopup
|
||||||
ref="formModelRef"
|
ref="formModelRef"
|
||||||
:form-initial-data="initialData"
|
:form-initial-data="initialData"
|
||||||
:observe-form-changes="false"
|
:observe-form-changes="false"
|
||||||
|
@ -203,7 +191,7 @@ async function getAmountPaid() {
|
||||||
:mapper="onBeforeSave"
|
:mapper="onBeforeSave"
|
||||||
@on-data-saved="onDataSaved"
|
@on-data-saved="onDataSaved"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
<span ref="closeButton" class="row justify-end close-icon" v-close-popup>
|
<span ref="closeButton" class="row justify-end close-icon" v-close-popup>
|
||||||
<QIcon name="close" size="sm" />
|
<QIcon name="close" size="sm" />
|
||||||
</span>
|
</span>
|
||||||
|
@ -213,7 +201,7 @@ async function getAmountPaid() {
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('Date')"
|
:label="t('Date')"
|
||||||
:required="true"
|
:required="true"
|
||||||
v-model="data.payed"
|
v-model="data.received"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('Company')"
|
:label="t('Company')"
|
||||||
|
@ -224,7 +212,7 @@ async function getAmountPaid() {
|
||||||
option-label="code"
|
option-label="code"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="data.companyFk"
|
v-model="data.companyFk"
|
||||||
@update:model-value="getAmountPaid()"
|
@update:model-value="getAmount()"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
@ -251,33 +239,30 @@ async function getAmountPaid() {
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
</VnSelect>
|
</VnSelect>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('supplier.billingData.payMethodFk')"
|
||||||
|
v-model="data.payMethodFk"
|
||||||
|
url="Paymethods"
|
||||||
|
auto-load
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
hide-selected
|
||||||
|
:rules="validate('supplier.payMethodFk')"
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
|
|
||||||
<VnInputNumber
|
<VnInputNumber
|
||||||
:label="t('Amount')"
|
:label="t('Amount')"
|
||||||
:required="true"
|
:required="true"
|
||||||
@update:model-value="calculateFromAmount($event)"
|
@update:model-value="calculateFromAmount($event)"
|
||||||
clearable
|
clearable
|
||||||
v-model.number="data.amountPaid"
|
v-model.number="data.amount"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
|
||||||
<div v-if="data.bankFk?.accountingType?.code == 'compensation'">
|
|
||||||
<div class="text-h6">
|
|
||||||
{{ t('Compensation') }}
|
|
||||||
</div>
|
|
||||||
<VnRow>
|
|
||||||
<VnAccountNumber
|
|
||||||
:label="t('Compensation account')"
|
|
||||||
clearable
|
|
||||||
required
|
|
||||||
v-model="data.compensationAccount"
|
|
||||||
@blur="accountShortToStandard"
|
|
||||||
/>
|
|
||||||
</VnRow>
|
|
||||||
</div>
|
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('Reference')"
|
:label="t('Reference')"
|
||||||
:required="true"
|
:required="true"
|
||||||
clearable
|
clearable
|
||||||
v-model="data.description"
|
v-model="data.concept"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div v-if="data.bankFk?.accountingType?.code == 'cash'">
|
<div v-if="data.bankFk?.accountingType?.code == 'cash'">
|
||||||
|
@ -305,7 +290,12 @@ async function getAmountPaid() {
|
||||||
v-if="$props.extraFields.includes('orderBy')"
|
v-if="$props.extraFields.includes('orderBy')"
|
||||||
:label="t('Type')"
|
:label="t('Type')"
|
||||||
v-model="data.orderBy"
|
v-model="data.orderBy"
|
||||||
:options="['issued', ' bookEntried', ' booked', ' dueDate']"
|
:options="[
|
||||||
|
{ id: 'issued', name: 'Fecha de expedición' },
|
||||||
|
{ id: 'bookEntried', name: 'Fecha de asiento' },
|
||||||
|
{ id: 'booked', name: 'Fecha contable' },
|
||||||
|
{ id: 'dueDate', name: 'Fecha de vencimiento' },
|
||||||
|
]"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
@ -327,27 +317,8 @@ async function getAmountPaid() {
|
||||||
v-model="data.divisa"
|
v-model="data.divisa"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<div class="q-mt-lg row justify-end">
|
|
||||||
<QBtn
|
|
||||||
:disabled="formModelRef.isLoading"
|
|
||||||
:label="t('globals.cancel')"
|
|
||||||
:loading="formModelRef.isLoading"
|
|
||||||
class="q-ml-sm"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
type="reset"
|
|
||||||
v-close-popup
|
|
||||||
/>
|
|
||||||
<QBtn
|
|
||||||
:disabled="formModelRef.isLoading"
|
|
||||||
:label="t('globals.save')"
|
|
||||||
:loading="formModelRef.isLoading"
|
|
||||||
color="primary"
|
|
||||||
type="submit"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</FormModel>
|
</FormModelPopup>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue