WIP: #8120: Compact summaryPopup #1200
|
@ -247,8 +247,14 @@ function handleLocation(data, location) {
|
||||||
:label="t('Longitude')"
|
:label="t('Longitude')"
|
||||||
clearable
|
clearable
|
||||||
v-model="data.longitude"
|
v-model="data.longitude"
|
||||||
|
:decimal-places="7"
|
||||||
|
/>
|
||||||
|
<VnInputNumber
|
||||||
|
:label="t('Latitude')"
|
||||||
|
clearable
|
||||||
|
v-model="data.latitude"
|
||||||
|
:decimal-places="7"
|
||||||
/>
|
/>
|
||||||
<VnInputNumber :label="t('Latitude')" clearable v-model="data.latitude" />
|
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<h4 class="q-mb-xs">{{ t('Notes') }}</h4>
|
<h4 class="q-mb-xs">{{ t('Notes') }}</h4>
|
||||||
<VnRow
|
<VnRow
|
||||||
|
|
|
@ -172,13 +172,13 @@ const changeQuantity = async (request) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
await axios.patch(`Sales/${request.saleFk}`, params);
|
await axios.patch(`Sales/${request.saleFk}`, params);
|
||||||
|
}
|
||||||
|
await confirmRequest(request);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
confirmRequest(request);
|
|
||||||
} else confirmRequest(request);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const confirmRequest = async (request) => {
|
const confirmRequest = async (request) => {
|
||||||
if (request.itemFk && request.saleQuantity) {
|
if (!request.itemFk || !request.saleQuantity) return;
|
||||||
const params = {
|
const params = {
|
||||||
itemFk: request.itemFk,
|
itemFk: request.itemFk,
|
||||||
quantity: request.saleQuantity,
|
quantity: request.saleQuantity,
|
||||||
|
@ -188,8 +188,6 @@ const confirmRequest = async (request) => {
|
||||||
const { data } = await axios.post(`TicketRequests/${request.id}/confirm`, params);
|
const { data } = await axios.post(`TicketRequests/${request.id}/confirm`, params);
|
||||||
request.itemDescription = data.concept;
|
request.itemDescription = data.concept;
|
||||||
request.isOk = true;
|
request.isOk = true;
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getState = (isOk) => {
|
const getState = (isOk) => {
|
||||||
|
|
|
@ -10,7 +10,6 @@ const { notify } = useNotify();
|
||||||
|
|
||||||
export const useInvoiceOutGlobalStore = defineStore({
|
export const useInvoiceOutGlobalStore = defineStore({
|
||||||
id: 'invoiceOutGlobal',
|
id: 'invoiceOutGlobal',
|
||||||
|
|
||||||
state: () => ({
|
state: () => ({
|
||||||
initialDataLoading: true,
|
initialDataLoading: true,
|
||||||
formInitialData: {
|
formInitialData: {
|
||||||
|
@ -33,6 +32,7 @@ export const useInvoiceOutGlobalStore = defineStore({
|
||||||
nRequests: 0,
|
nRequests: 0,
|
||||||
nPdfs: 0,
|
nPdfs: 0,
|
||||||
totalPdfs: 0,
|
totalPdfs: 0,
|
||||||
|
formData: null,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async init() {
|
async init() {
|
||||||
|
@ -93,8 +93,6 @@ export const useInvoiceOutGlobalStore = defineStore({
|
||||||
},
|
},
|
||||||
|
|
||||||
async makeInvoice(formData, clientsToInvoice) {
|
async makeInvoice(formData, clientsToInvoice) {
|
||||||
this.invoicing = true;
|
|
||||||
const promises = [];
|
|
||||||
try {
|
try {
|
||||||
this.printer = formData.printer;
|
this.printer = formData.printer;
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -119,11 +117,12 @@ export const useInvoiceOutGlobalStore = defineStore({
|
||||||
);
|
);
|
||||||
throw new Error("There aren't addresses to invoice");
|
throw new Error("There aren't addresses to invoice");
|
||||||
}
|
}
|
||||||
|
this.invoicing = false;
|
||||||
this.status = 'invoicing';
|
this.status = 'invoicing';
|
||||||
for (let index = 0; index < this.parallelism; index++) {
|
this.formData = formData;
|
||||||
promises.push(this.invoiceClient(formData, index));
|
this.addressIndex = 0;
|
||||||
}
|
this.errors = [];
|
||||||
await Promise.all(promises);
|
await this.invoiceClient();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.handleError(err);
|
this.handleError(err);
|
||||||
}
|
}
|
||||||
|
@ -182,45 +181,42 @@ export const useInvoiceOutGlobalStore = defineStore({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async invoiceClient(formData, index) {
|
async invoiceClient() {
|
||||||
const address = this.addresses[index];
|
if (this.invoicing || this.nRequests >= this.parallelism) return;
|
||||||
|
const address = this.addresses[this.addressIndex];
|
||||||
|
|
||||||
if (!address || !this.status || this.status == 'stopping') {
|
if (!address || !this.status || this.status == 'stopping') {
|
||||||
this.status = 'stopping';
|
this.status = 'stopping';
|
||||||
this.invoicing = false;
|
this.invoicing = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
this.invoicing = true;
|
||||||
const params = {
|
const params = {
|
||||||
clientId: address.clientId,
|
clientId: address.clientId,
|
||||||
addressId: address.id,
|
addressId: address.id,
|
||||||
invoiceDate: new Date(formData.invoiceDate),
|
invoiceDate: new Date(this.formData.invoiceDate),
|
||||||
maxShipped: new Date(formData.maxShipped),
|
maxShipped: new Date(this.formData.maxShipped),
|
||||||
companyFk: formData.companyFk,
|
companyFk: this.formData.companyFk,
|
||||||
serialType: formData.serialType,
|
serialType: this.formData.serialType,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.invoicing = true;
|
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/invoiceClient', params);
|
const { data } = await axios.post('InvoiceOuts/invoiceClient', params);
|
||||||
|
if (data) this.makePdfAndNotify(data, address);
|
||||||
if (data) await this.makePdfAndNotify(data, address);
|
|
||||||
this.isInvoicing = false;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err?.response?.status >= 400 && err?.response?.status < 500) {
|
if (err?.response?.status >= 400 && err?.response?.status < 500) {
|
||||||
this.invoiceClientError(address, err.response?.data?.error?.message);
|
this.invoiceClientError(address, err.response?.data?.error?.message);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.invoicing = false;
|
|
||||||
notify(
|
notify(
|
||||||
'invoiceOut.globalInvoices.errors.criticalInvoiceError',
|
'invoiceOut.globalInvoices.errors.criticalInvoiceError',
|
||||||
'negative'
|
'negative'
|
||||||
);
|
);
|
||||||
throw new Error('Critical invoicing error, process stopped');
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
this.invoicing = false;
|
||||||
this.addressIndex++;
|
this.addressIndex++;
|
||||||
if (this.status != 'stopping')
|
this.invoiceClient();
|
||||||
await this.invoiceClient(formData, this.addressIndex);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -231,9 +227,11 @@ export const useInvoiceOutGlobalStore = defineStore({
|
||||||
const params = { printerFk: this.printer };
|
const params = { printerFk: this.printer };
|
||||||
await axios.post(`InvoiceOuts/${invoiceId}/makePdfAndNotify`, params);
|
await axios.post(`InvoiceOuts/${invoiceId}/makePdfAndNotify`, params);
|
||||||
this.nPdfs++;
|
this.nPdfs++;
|
||||||
this.nRequests--;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.invoiceClientError(client, err.response?.data?.error?.message, true);
|
this.invoiceClientError(client, err.response?.data?.error?.message, true);
|
||||||
|
} finally {
|
||||||
|
this.nRequests--;
|
||||||
|
this.invoiceClient();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue