feat: refs #6739 transferInvoice new checkbox and functionality
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
e3a36c0ab1
commit
5ed2a82194
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ const $props = defineProps({
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
const checked = ref(true);
|
||||||
|
let skip = 0;
|
||||||
|
|
||||||
const transferInvoiceParams = reactive({
|
const transferInvoiceParams = reactive({
|
||||||
id: $props.invoiceOutData?.id,
|
id: $props.invoiceOutData?.id,
|
||||||
|
@ -36,15 +38,74 @@ const closeForm = () => {
|
||||||
if (closeButton.value) closeButton.value.click();
|
if (closeButton.value) closeButton.value.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await fetchClients();
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchClients = async () => {
|
||||||
|
try {
|
||||||
|
const filter = {
|
||||||
|
skip: skip,
|
||||||
|
order: 'id DESC',
|
||||||
|
limit: 10,
|
||||||
|
};
|
||||||
|
const { data } = await axios.get('http://localhost:9000/api/Clients/filter', {
|
||||||
|
params: {
|
||||||
|
filter: serializeFilter(filter),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
clientsOptions.value = [...clientsOptions.value, ...data];
|
||||||
|
skip += 10;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching clients:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const serializeFilter = (filter) => {
|
||||||
|
let serializedFilter = '{';
|
||||||
|
for (const key in filter) {
|
||||||
|
serializedFilter += `"${key}":${JSON.stringify(filter[key])},`;
|
||||||
|
}
|
||||||
|
serializedFilter = serializedFilter.slice(0, -1);
|
||||||
|
serializedFilter += '}';
|
||||||
|
return serializedFilter;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleScroll = async () => {
|
||||||
|
const selectEl = document.querySelector('.vn-select');
|
||||||
|
if (selectEl.scrollTop + selectEl.clientHeight >= selectEl.scrollHeight) {
|
||||||
|
await fetchClients();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const transferInvoice = async () => {
|
const transferInvoice = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.post(
|
const clientDetails = await axios.get(
|
||||||
'InvoiceOuts/transferInvoice',
|
`Clients/${transferInvoiceParams.newClientFk}`
|
||||||
transferInvoiceParams
|
|
||||||
);
|
);
|
||||||
notify(t('Transferred invoice'), 'positive');
|
const hasToInvoiceByAddress = clientDetails.data.hasToInvoiceByAddress;
|
||||||
closeForm();
|
|
||||||
router.push('InvoiceOutSummary', { id: data.id });
|
if (checked.value && hasToInvoiceByAddress) {
|
||||||
|
const confirmed = confirm(t('confirmationInfo'));
|
||||||
|
|
||||||
|
if (confirmed) {
|
||||||
|
const { data } = await axios.post(
|
||||||
|
'InvoiceOuts/transferInvoice',
|
||||||
|
transferInvoiceParams
|
||||||
|
);
|
||||||
|
notify(t('Transferred invoice'), 'positive');
|
||||||
|
closeForm();
|
||||||
|
router.push('InvoiceOutSummary', { id: data.id });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const { data } = await axios.post(
|
||||||
|
'InvoiceOuts/transferInvoice',
|
||||||
|
transferInvoiceParams
|
||||||
|
);
|
||||||
|
notify(t('Transferred invoice'), 'positive');
|
||||||
|
closeForm();
|
||||||
|
router.push('InvoiceOutSummary', { id: data.id });
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error transfering invoice', err);
|
console.error('Error transfering invoice', err);
|
||||||
}
|
}
|
||||||
|
@ -61,13 +122,23 @@ const transferInvoice = async () => {
|
||||||
<FetchData
|
<FetchData
|
||||||
url="CplusRectificationTypes"
|
url="CplusRectificationTypes"
|
||||||
:filter="{ order: 'description' }"
|
:filter="{ order: 'description' }"
|
||||||
@on-fetch="(data) => (rectificativeTypeOptions = data)"
|
@on-fetch="
|
||||||
|
(data) => (
|
||||||
|
(rectificativeTypeOptions = data),
|
||||||
|
(transferInvoiceParams.cplusRectificationTypeFk = data[1].id)
|
||||||
|
)
|
||||||
|
"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="SiiTypeInvoiceOuts"
|
url="SiiTypeInvoiceOuts"
|
||||||
:filter="{ where: { code: { like: 'R%' } } }"
|
:filter="{ where: { code: { like: 'R%' } } }"
|
||||||
@on-fetch="(data) => (siiTypeInvoiceOutsOptions = data)"
|
@on-fetch="
|
||||||
|
(data) => (
|
||||||
|
(siiTypeInvoiceOutsOptions = data),
|
||||||
|
(transferInvoiceParams.siiTypeInvoiceOutFk = data[3].id)
|
||||||
|
)
|
||||||
|
"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -92,6 +163,7 @@ const transferInvoice = async () => {
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="transferInvoiceParams.newClientFk"
|
v-model="transferInvoiceParams.newClientFk"
|
||||||
:required="true"
|
:required="true"
|
||||||
|
@scroll="handleScroll"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
|
@ -152,11 +224,22 @@ const transferInvoice = async () => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
<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">
|
||||||
|
<QTooltip>{{ t('checkInfo') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
</FormPopup>
|
</FormPopup>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
en:
|
||||||
|
checkInfo: New tickets from the destination customer will be generated in the consignee by default.
|
||||||
|
confirmationInfo: Destination customer is marked to bill in the consignee, do you want to continue?
|
||||||
es:
|
es:
|
||||||
Transfer invoice: Transferir factura
|
Transfer invoice: Transferir factura
|
||||||
Transfer client: Transferir cliente
|
Transfer client: Transferir cliente
|
||||||
|
@ -165,4 +248,7 @@ es:
|
||||||
Class: Clase
|
Class: Clase
|
||||||
Type: Tipo
|
Type: Tipo
|
||||||
Transferred invoice: Factura transferida
|
Transferred invoice: Factura transferida
|
||||||
|
Bill destination client: Facturar cliente destino
|
||||||
|
checkInfo: Los nuevos tickets del cliente destino, serán generados en el consignatario por defecto.
|
||||||
|
confirmationInfo: El cliente destino tiene marcado facturar por consignatario, desea continuar?
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue