feat: refs #7553 refs #7356 & #7553 added rest of missing functions in the descriptor menu
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-08-20 09:36:27 +02:00
parent 511d53d109
commit 85bc610298
2 changed files with 124 additions and 8 deletions

View File

@ -30,7 +30,7 @@ const filter = {
{
relation: 'address',
scope: {
fields: ['id', 'name', 'mobile', 'phone'],
fields: ['id', 'name', 'mobile', 'phone', 'incotermsFk'],
},
},
{

View File

@ -1,6 +1,6 @@
<script setup>
import axios from 'axios';
import { ref } from 'vue';
import { ref, toRefs } from 'vue';
import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
@ -11,6 +11,8 @@ import VnSmsDialog from 'components/common/VnSmsDialog.vue';
import toDate from 'filters/toDate';
import FormPopup from 'components/FormPopup.vue';
import VnSelect from 'components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue';
import VnInputTime from 'src/components/common/VnInputTime.vue';
const props = defineProps({
ticket: {
@ -24,12 +26,16 @@ const { dialog, notify } = useQuasar();
const { t } = useI18n();
const { openReport, sendEmail } = usePrintService();
const ticket = ref(props.ticket);
const { ticket } = toRefs(props);
const ticketId = currentRoute.value.params.id;
const client = ref();
const showTransferDialog = ref(false);
const showTurnDialog = ref(false);
const showChangeTimeDialog = ref(false);
const dialogRef = ref();
const isEditable = ref();
const hasInvoicing = ref();
const hasPdf = ref();
const actions = {
clone: async () => {
const opts = { message: t('Ticket cloned'), type: 'positive' };
@ -187,6 +193,26 @@ async function createPdfInvoice() {
}
}
function makeInvoiceDialog() {
//TODO: lo de abajo?
// if (ticket.value.address?.incotermsFk && !ticket.value.weight && !force)
dialog({
component: VnConfirm,
componentProps: {
promise: makeInvoice,
},
});
}
async function makeInvoice() {
console.log(ticket.value);
const params = {
ticketsIds: [parseInt(ticketId)],
};
const { data } = await axios.post(`Tickets/invoiceTicketsAndPdf`, params);
if (data) window.location.reload();
}
async function transferClient(client) {
const params = {
clientFk: client,
@ -218,17 +244,65 @@ async function createRefund(withWarehouse) {
withWarehouse: withWarehouse,
};
const { data } = await axios.post(`Tickets/refund`, params);
console.log('data: ', data);
if (data) {
const refundTicket = data;
console.log('refundTicket: ', refundTicket);
push({ name: 'TicketSale', params: { id: refundTicket[0].id } });
}
}
async function changeShippedHour(time) {
console.log('time: ', time);
const params = {
shipped: time,
};
const { data } = await axios.post(`Tickets/${ticketId}/updateEditableTicket`, params);
if (data) window.location.reload();
}
function openRecalculateDialog() {
dialog({
component: VnConfirm,
componentProps: {
title: t('Recalculate components'),
message: t('Are you sure you want to recalculate components?'),
promise: recalculateComponents,
},
});
}
async function recalculateComponents() {
await axios.post(`Tickets/${ticketId}/recalculateComponents`);
notify({
message: t('Data saved'),
type: 'positive',
});
window.location.reload();
}
const handleFetchData = (data) => {
isEditable.value = data;
handleInvoiceOutData();
};
async function handleInvoiceOutData() {
const { data } = await axios.get(`InvoiceOuts`, {
params: {
filter: JSON.stringify({ where: { ref: ticket.value.refFk } }),
},
});
hasPdf.value = data[0]?.hasPdf;
}
</script>
<template>
<FetchData
:url="`Tickets/${ticketId}/isEditable`"
auto-load
@on-fetch="handleFetchData"
/>
<QItem @click="showTransferDialog = !showTransferDialog" v-ripple clickable>
<QItemSection avatar>
<QIcon name="content_paste" />
@ -268,7 +342,7 @@ async function createRefund(withWarehouse) {
</QDialog>
<QItem @click="showTurnDialog = !showTurnDialog" v-ripple clickable>
<QItemSection avatar>
<QIcon name="content_paste" />
<QIcon name="vn:calendar" />
</QItemSection>
<QItemSection>{{ t('addTurn') }}</QItemSection>
</QItem>
@ -401,6 +475,20 @@ async function createRefund(withWarehouse) {
</QItemSection>
<QItemSection>{{ t('Show Proforma') }}</QItemSection>
</QItem>
<QItem @click="showChangeTimeDialog = !showChangeTimeDialog" v-ripple clickable>
<QItemSection avatar>
<QIcon name="schedule" />
</QItemSection>
<QItemSection>{{ t('Change shipped hour') }}</QItemSection>
</QItem>
<QDialog ref="dialogRef" v-model="showChangeTimeDialog">
<FormPopup @on-submit="changeShippedHour(time)" :title="t('Change shipped hour')">
<template #form-inputs>
<!--TODO: pone el año a 1970, corregir-->
<VnInputTime v-model="time" :label="t('Shipped hour')" clearable />
</template>
</FormPopup>
</QDialog>
<QItem v-ripple clickable>
<QItemSection avatar>
<QIcon name="sms" />
@ -427,11 +515,26 @@ async function createRefund(withWarehouse) {
</QList>
</QMenu>
</QItem>
<QItem @click="createPdfDialog()" v-ripple clickable>
<!--TODO: acabar esta parte, falta la función makeInvoice-->
<QItem @click="makeInvoiceDialog()" v-ripple clickable v-if="isEditable">
<QItemSection avatar>
<QIcon name="picture_as_pdf" />
</QItemSection>
<QItemSection>{{ t('Regenerate PDF invoice') }}</QItemSection>
<QItemSection>{{ t('Make invoice') }}</QItemSection>
</QItem>
<!--TODO: acabar esta parte, falta el campo hasInvoicing-->
<QItem
@click="createPdfDialog()"
v-ripple
clickable
v-if="ticket.refFk !== null && (ticket.hasInvoicing || hasPdf)"
>
<QItemSection avatar>
<QIcon name="picture_as_pdf" />
</QItemSection>
<QItemSection>{{
hasPdf.value ? t('Regenerate PDF invoice') : t('Generate PDF invoice')
}}</QItemSection>
</QItem>
<QItem @click="openConfirmDialog('clone')" v-ripple clickable>
<QItemSection avatar>
@ -439,6 +542,12 @@ async function createRefund(withWarehouse) {
</QItemSection>
<QItemSection>{{ t('To clone ticket') }}</QItemSection>
</QItem>
<QItem @click="openRecalculateDialog()" v-ripple clickable>
<QItemSection avatar>
<QIcon name="refresh" />
</QItemSection>
<QItemSection>{{ t('Recalculate components') }}</QItemSection>
</QItem>
<QItem v-ripple clickable>
<QItemSection avatar>
<QIcon name="monetization_on" />
@ -502,6 +611,7 @@ es:
To clone ticket: Clonar ticket
Ticket cloned: Ticked clonado
It was not able to clone the ticket: No se pudo clonar el ticket
Generate PDF invoice: Generar PDF factura
Regenerate PDF invoice: Regenerar PDF factura
The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado
Transfer client: Transferir cliente
@ -512,4 +622,10 @@ es:
Refund all...: Abonar todo...
with warehouse: con almacén
without warehouse: sin almacén
Make invoice: Crear factura
Change shipped hour: Cambiar hora de envío
Shipped hour: Hora de envío
Recalculate components: Recalcular componentes
Are you sure you want to recalculate components?: ¿Seguro que quieres recalcular los componentes?
Data saved: Datos guardados
</i18n>