2024-02-15 14:36:53 +00:00
|
|
|
|
<script setup>
|
2024-05-10 05:04:03 +00:00
|
|
|
|
import { ref, reactive } from 'vue';
|
2024-02-15 14:36:53 +00:00
|
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
import { useRouter } from 'vue-router';
|
2024-05-07 08:35:48 +00:00
|
|
|
|
import { useQuasar } from 'quasar';
|
|
|
|
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
2024-02-15 14:36:53 +00:00
|
|
|
|
import VnRow from 'components/ui/VnRow.vue';
|
|
|
|
|
import FetchData from 'components/FetchData.vue';
|
2024-04-23 11:03:32 +00:00
|
|
|
|
import VnSelect from 'components/common/VnSelect.vue';
|
2024-02-21 14:27:32 +00:00
|
|
|
|
import FormPopup from './FormPopup.vue';
|
|
|
|
|
|
2024-02-15 14:36:53 +00:00
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import useNotify from 'src/composables/useNotify.js';
|
|
|
|
|
|
|
|
|
|
const $props = defineProps({
|
|
|
|
|
invoiceOutData: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: () => {},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2024-05-07 08:35:48 +00:00
|
|
|
|
const quasar = useQuasar();
|
2024-02-15 14:36:53 +00:00
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const { notify } = useNotify();
|
2024-05-06 12:50:15 +00:00
|
|
|
|
const checked = ref(true);
|
2024-02-15 14:36:53 +00:00
|
|
|
|
const transferInvoiceParams = reactive({
|
|
|
|
|
id: $props.invoiceOutData?.id,
|
|
|
|
|
refFk: $props.invoiceOutData?.ref,
|
|
|
|
|
});
|
2024-05-10 05:04:03 +00:00
|
|
|
|
|
2024-02-15 14:36:53 +00:00
|
|
|
|
const rectificativeTypeOptions = ref([]);
|
|
|
|
|
const siiTypeInvoiceOutsOptions = ref([]);
|
|
|
|
|
const invoiceCorrectionTypesOptions = ref([]);
|
|
|
|
|
|
2024-05-10 05:04:03 +00:00
|
|
|
|
const selectedClient = (client) => {
|
|
|
|
|
transferInvoiceParams.selectedClientData = client;
|
2024-05-06 12:50:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-02-15 14:36:53 +00:00
|
|
|
|
const transferInvoice = async () => {
|
2024-05-10 05:04:03 +00:00
|
|
|
|
const hasToInvoiceByAddress =
|
|
|
|
|
transferInvoiceParams.selectedClientData.hasToInvoiceByAddress;
|
|
|
|
|
|
2024-05-07 09:27:39 +00:00
|
|
|
|
const params = {
|
|
|
|
|
id: transferInvoiceParams.id,
|
|
|
|
|
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
|
|
|
|
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
|
|
|
|
newClientFk: transferInvoiceParams.newClientFk,
|
|
|
|
|
refFk: transferInvoiceParams.refFk,
|
|
|
|
|
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
|
|
|
|
checked: checked.value,
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-15 14:36:53 +00:00
|
|
|
|
try {
|
2024-05-10 05:04:03 +00:00
|
|
|
|
if (checked.value && hasToInvoiceByAddress) {
|
|
|
|
|
const response = await new Promise((resolve) => {
|
|
|
|
|
quasar
|
|
|
|
|
.dialog({
|
|
|
|
|
component: VnConfirm,
|
|
|
|
|
componentProps: {
|
|
|
|
|
title: t('Bill destination client'),
|
|
|
|
|
message: t('transferInvoiceInfo'),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.onOk(() => {
|
|
|
|
|
resolve(true);
|
|
|
|
|
})
|
|
|
|
|
.onCancel(() => {
|
|
|
|
|
resolve(false);
|
|
|
|
|
});
|
2024-05-07 08:35:48 +00:00
|
|
|
|
});
|
2024-05-10 05:04:03 +00:00
|
|
|
|
if (!response) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-06 12:50:15 +00:00
|
|
|
|
|
2024-05-07 09:27:39 +00:00
|
|
|
|
const { data } = await axios.post('InvoiceOuts/transferInvoice', params);
|
2024-05-07 08:35:48 +00:00
|
|
|
|
notify(t('Transferred invoice'), 'positive');
|
2024-05-23 13:06:57 +00:00
|
|
|
|
if (data.id) router.push({ name: 'InvoiceOutSummary', params: { id: data.id } });
|
2024-02-15 14:36:53 +00:00
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('Error transfering invoice', err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<FetchData
|
|
|
|
|
url="CplusRectificationTypes"
|
|
|
|
|
:filter="{ order: 'description' }"
|
2024-05-06 12:50:15 +00:00
|
|
|
|
@on-fetch="
|
|
|
|
|
(data) => (
|
|
|
|
|
(rectificativeTypeOptions = data),
|
2024-05-10 05:04:03 +00:00
|
|
|
|
(transferInvoiceParams.cplusRectificationTypeFk = data.filter(
|
|
|
|
|
(type) => type.description == 'I – Por diferencias'
|
|
|
|
|
)[0].id)
|
2024-05-06 12:50:15 +00:00
|
|
|
|
)
|
|
|
|
|
"
|
2024-02-15 14:36:53 +00:00
|
|
|
|
auto-load
|
|
|
|
|
/>
|
|
|
|
|
<FetchData
|
|
|
|
|
url="SiiTypeInvoiceOuts"
|
|
|
|
|
:filter="{ where: { code: { like: 'R%' } } }"
|
2024-05-06 12:50:15 +00:00
|
|
|
|
@on-fetch="
|
|
|
|
|
(data) => (
|
|
|
|
|
(siiTypeInvoiceOutsOptions = data),
|
2024-05-10 05:04:03 +00:00
|
|
|
|
(transferInvoiceParams.siiTypeInvoiceOutFk = data.filter(
|
|
|
|
|
(type) => type.code == 'R4'
|
|
|
|
|
)[0].id)
|
2024-05-06 12:50:15 +00:00
|
|
|
|
)
|
|
|
|
|
"
|
2024-02-15 14:36:53 +00:00
|
|
|
|
auto-load
|
|
|
|
|
/>
|
|
|
|
|
<FetchData
|
|
|
|
|
url="InvoiceCorrectionTypes"
|
|
|
|
|
@on-fetch="(data) => (invoiceCorrectionTypesOptions = data)"
|
|
|
|
|
auto-load
|
|
|
|
|
/>
|
2024-02-21 14:27:32 +00:00
|
|
|
|
<FormPopup
|
|
|
|
|
@on-submit="transferInvoice()"
|
|
|
|
|
:title="t('Transfer invoice')"
|
|
|
|
|
:custom-submit-button-label="t('Transfer client')"
|
|
|
|
|
:default-cancel-button="false"
|
|
|
|
|
>
|
|
|
|
|
<template #form-inputs>
|
2024-02-15 14:36:53 +00:00
|
|
|
|
<VnRow class="row q-gutter-md q-mb-md">
|
2024-04-26 07:47:44 +00:00
|
|
|
|
<VnSelect
|
2024-04-17 11:26:08 +00:00
|
|
|
|
:label="t('Client')"
|
|
|
|
|
:options="clientsOptions"
|
|
|
|
|
hide-selected
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="id"
|
|
|
|
|
v-model="transferInvoiceParams.newClientFk"
|
|
|
|
|
:required="true"
|
2024-05-13 05:14:10 +00:00
|
|
|
|
url="Clients"
|
|
|
|
|
:fields="['id', 'name', 'hasToInvoiceByAddress']"
|
|
|
|
|
auto-load
|
2024-04-17 11:26:08 +00:00
|
|
|
|
>
|
|
|
|
|
<template #option="scope">
|
2024-05-13 05:14:10 +00:00
|
|
|
|
<QItem
|
|
|
|
|
v-bind="scope.itemProps"
|
|
|
|
|
@click="selectedClient(scope.opt)"
|
|
|
|
|
>
|
2024-04-17 11:26:08 +00:00
|
|
|
|
<QItemSection>
|
|
|
|
|
<QItemLabel>
|
2024-05-13 05:14:10 +00:00
|
|
|
|
#{{ scope.opt?.id }} - {{ scope.opt?.name }}
|
2024-04-17 11:26:08 +00:00
|
|
|
|
</QItemLabel>
|
|
|
|
|
</QItemSection>
|
|
|
|
|
</QItem>
|
|
|
|
|
</template>
|
2024-04-26 07:47:44 +00:00
|
|
|
|
</VnSelect>
|
|
|
|
|
<VnSelect
|
2024-04-17 11:26:08 +00:00
|
|
|
|
:label="t('Rectificative type')"
|
|
|
|
|
:options="rectificativeTypeOptions"
|
|
|
|
|
hide-selected
|
|
|
|
|
option-label="description"
|
|
|
|
|
option-value="id"
|
|
|
|
|
v-model="transferInvoiceParams.cplusRectificationTypeFk"
|
|
|
|
|
:required="true"
|
|
|
|
|
/>
|
2024-02-15 14:36:53 +00:00
|
|
|
|
</VnRow>
|
|
|
|
|
<VnRow class="row q-gutter-md q-mb-md">
|
2024-04-26 07:47:44 +00:00
|
|
|
|
<VnSelect
|
2024-04-17 11:26:08 +00:00
|
|
|
|
:label="t('Class')"
|
|
|
|
|
:options="siiTypeInvoiceOutsOptions"
|
|
|
|
|
hide-selected
|
|
|
|
|
option-label="description"
|
|
|
|
|
option-value="id"
|
|
|
|
|
v-model="transferInvoiceParams.siiTypeInvoiceOutFk"
|
|
|
|
|
:required="true"
|
|
|
|
|
>
|
|
|
|
|
<template #option="scope">
|
|
|
|
|
<QItem v-bind="scope.itemProps">
|
|
|
|
|
<QItemSection>
|
|
|
|
|
<QItemLabel>
|
|
|
|
|
{{ scope.opt?.code }} -
|
|
|
|
|
{{ scope.opt?.description }}
|
|
|
|
|
</QItemLabel>
|
|
|
|
|
</QItemSection>
|
|
|
|
|
</QItem>
|
|
|
|
|
</template>
|
2024-04-26 07:47:44 +00:00
|
|
|
|
</VnSelect>
|
|
|
|
|
<VnSelect
|
2024-04-17 11:26:08 +00:00
|
|
|
|
:label="t('Type')"
|
|
|
|
|
:options="invoiceCorrectionTypesOptions"
|
|
|
|
|
hide-selected
|
|
|
|
|
option-label="description"
|
|
|
|
|
option-value="id"
|
|
|
|
|
v-model="transferInvoiceParams.invoiceCorrectionTypeFk"
|
|
|
|
|
:required="true"
|
|
|
|
|
/>
|
2024-02-15 14:36:53 +00:00
|
|
|
|
</VnRow>
|
2024-05-06 12:50:15 +00:00
|
|
|
|
<VnRow class="row q-gutter-md q-mb-md">
|
|
|
|
|
<div>
|
|
|
|
|
<QCheckbox :label="t('Bill destination client')" v-model="checked" />
|
|
|
|
|
<QIcon name="info" class="cursor-info q-ml-sm" size="sm">
|
2024-05-10 05:04:03 +00:00
|
|
|
|
<QTooltip>{{ t('transferInvoiceInfo') }}</QTooltip>
|
2024-05-06 12:50:15 +00:00
|
|
|
|
</QIcon>
|
|
|
|
|
</div>
|
|
|
|
|
</VnRow>
|
2024-02-21 14:27:32 +00:00
|
|
|
|
</template>
|
|
|
|
|
</FormPopup>
|
2024-02-15 14:36:53 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<i18n>
|
2024-05-06 12:50:15 +00:00
|
|
|
|
en:
|
|
|
|
|
checkInfo: New tickets from the destination customer will be generated in the consignee by default.
|
2024-05-10 05:04:03 +00:00
|
|
|
|
transferInvoiceInfo: Destination customer is marked to bill in the consignee, do you want to continue?
|
|
|
|
|
confirmTransferInvoice: The destination customer has selected to bill in the consignee, do you want to continue?
|
2024-02-15 14:36:53 +00:00
|
|
|
|
es:
|
|
|
|
|
Transfer invoice: Transferir factura
|
|
|
|
|
Transfer client: Transferir cliente
|
|
|
|
|
Client: Cliente
|
|
|
|
|
Rectificative type: Tipo rectificativa
|
|
|
|
|
Class: Clase
|
|
|
|
|
Type: Tipo
|
|
|
|
|
Transferred invoice: Factura transferida
|
2024-05-06 12:50:15 +00:00
|
|
|
|
Bill destination client: Facturar cliente destino
|
2024-05-10 05:04:03 +00:00
|
|
|
|
transferInvoiceInfo: Los nuevos tickets del cliente destino, serán generados en el consignatario por defecto.
|
|
|
|
|
confirmTransferInvoice: El cliente destino tiene marcado facturar por consignatario, desea continuar?
|
2024-02-15 14:36:53 +00:00
|
|
|
|
</i18n>
|