forked from verdnatura/salix-front
Invoice out globals corrections
This commit is contained in:
parent
248e02f530
commit
df620566ef
|
@ -565,7 +565,7 @@ export default {
|
|||
fillDates: 'Invoice date and the max date should be filled',
|
||||
invoiceDateLessThanMaxDate: 'Invoice date can not be less than max date',
|
||||
invoiceWithFutureDate: 'Exists an invoice with a future date',
|
||||
noTicketsToInvoice: 'There are not clients to invoice',
|
||||
noTicketsToInvoice: 'There are not tickets to invoice',
|
||||
criticalInvoiceError: 'Critical invoicing error, process stopped',
|
||||
},
|
||||
table: {
|
||||
|
|
|
@ -567,7 +567,7 @@ export default {
|
|||
invoiceDateLessThanMaxDate:
|
||||
'La fecha de la factura no puede ser menor que la fecha máxima',
|
||||
invoiceWithFutureDate: 'Existe una factura con una fecha futura',
|
||||
noTicketsToInvoice: 'No hay clientes para facturar',
|
||||
noTicketsToInvoice: 'No existen tickets para facturar',
|
||||
criticalInvoiceError: 'Error crítico en la facturación, proceso detenido',
|
||||
},
|
||||
table: {
|
||||
|
|
|
@ -13,13 +13,8 @@ const { t } = useI18n();
|
|||
const invoiceOutGlobalStore = useInvoiceOutGlobalStore();
|
||||
|
||||
// invoiceOutGlobalStore state and getters
|
||||
const {
|
||||
initialDataLoading,
|
||||
formInitialData,
|
||||
|
||||
invoicing,
|
||||
status,
|
||||
} = storeToRefs(invoiceOutGlobalStore);
|
||||
const { initialDataLoading, formInitialData, invoicing, status } =
|
||||
storeToRefs(invoiceOutGlobalStore);
|
||||
|
||||
// invoiceOutGlobalStore actions
|
||||
const { makeInvoice, setStatusValue } = invoiceOutGlobalStore;
|
||||
|
@ -32,13 +27,7 @@ const printersOptions = ref([]);
|
|||
|
||||
const clientsOptions = ref([]);
|
||||
|
||||
const formData = ref({
|
||||
companyFk: null,
|
||||
invoiceDate: null,
|
||||
maxShipped: null,
|
||||
clientId: null,
|
||||
printer: null,
|
||||
});
|
||||
const formData = ref({});
|
||||
|
||||
const optionsInitialData = computed(() => {
|
||||
return (
|
||||
|
|
|
@ -73,6 +73,9 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
const stringDate = data.issued.substring(0, 10);
|
||||
this.minInvoicingDate = stringDate;
|
||||
this.formInitialData.invoiceDate = stringDate;
|
||||
|
||||
this.minInvoicingDate = new Date(data.issued);
|
||||
this.formInitialData.invoiceDate = this.minInvoicingDate;
|
||||
} catch (err) {
|
||||
console.error('Error fetching invoice out global initial data');
|
||||
throw new Error();
|
||||
|
@ -103,12 +106,9 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
|
||||
if (clientsToInvoice == 'all') params.clientId = undefined;
|
||||
|
||||
const addressesResponse = await await axios.post(
|
||||
'InvoiceOuts/clientsToInvoice',
|
||||
params
|
||||
);
|
||||
const { data } = await axios.post('InvoiceOuts/clientsToInvoice', params);
|
||||
|
||||
this.addresses = addressesResponse.data;
|
||||
this.addresses = data;
|
||||
|
||||
if (!this.addresses || !this.addresses.length > 0) {
|
||||
notify(
|
||||
|
@ -118,9 +118,9 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
throw new Error("There aren't addresses to invoice");
|
||||
}
|
||||
|
||||
this.addresses.forEach(async (address) => {
|
||||
for (const address of this.addresses) {
|
||||
await this.invoiceClient(address, formData);
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
this.handleError(err);
|
||||
}
|
||||
|
@ -186,13 +186,10 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
this.status = 'invoicing';
|
||||
this.invoicing = true;
|
||||
|
||||
const invoiceResponse = await axios.post(
|
||||
'InvoiceOuts/invoiceClient',
|
||||
params
|
||||
);
|
||||
const { data } = await axios.post('InvoiceOuts/invoiceClient', params);
|
||||
|
||||
if (invoiceResponse.data) {
|
||||
this.makePdfAndNotify(invoiceResponse.data, address);
|
||||
if (data) {
|
||||
await this.makePdfAndNotify(data, address);
|
||||
}
|
||||
|
||||
this.isInvoicing = false;
|
||||
|
@ -203,7 +200,7 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
err.response.status >= 400 &&
|
||||
err.response.status < 500
|
||||
) {
|
||||
this.invoiceClientError(address, err.response);
|
||||
this.invoiceClientError(address, err.response?.data?.error?.message);
|
||||
this.addressIndex++;
|
||||
return;
|
||||
} else {
|
||||
|
@ -227,12 +224,11 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
this.nPdfs++;
|
||||
this.nRequests--;
|
||||
} catch (err) {
|
||||
this.invoiceClientError(client, err, true);
|
||||
this.invoiceClientError(client, err.response?.data?.error?.message, true);
|
||||
}
|
||||
},
|
||||
|
||||
invoiceClientError(client, response, isWarning) {
|
||||
const message = response.data?.error?.message || response.message;
|
||||
invoiceClientError(client, message, isWarning) {
|
||||
this.errors.unshift({ client, message, isWarning });
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue