@@ -48,9 +61,6 @@
|
ID
|
-
- Date
- |
IPT
|
@@ -69,9 +79,6 @@
ID
|
-
- Date
- |
IPT
|
@@ -105,7 +112,7 @@
@@ -114,12 +121,7 @@
- {{::ticket.id | dashIfEmpty}}
-
- |
-
-
- {{::ticket.shipped | date: 'dd/MM/yyyy'}}
+ {{::ticket.id}}
|
{{::ticket.ipt | dashIfEmpty}} |
@@ -135,7 +137,7 @@
- {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
+ {{::ticket.totalWithVat | currency: 'EUR': 2}}
@@ -145,11 +147,6 @@
{{::ticket.futureId | dashIfEmpty}}
|
-
-
- {{::ticket.futureShipped | date: 'dd/MM/yyyy'}}
-
- |
{{::ticket.futureIpt | dashIfEmpty}} |
+
+
+
+
+
+
+
+
+
+
+ Error list
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js
index 389bcdf14..fb539311f 100644
--- a/modules/ticket/front/advance/index.js
+++ b/modules/ticket/front/advance/index.js
@@ -75,20 +75,6 @@ export default class Controller extends Section {
});
}
- compareDate(date) {
- let today = Date.vnNew();
- today.setHours(0, 0, 0, 0);
- let timeTicket = new Date(date);
- timeTicket.setHours(0, 0, 0, 0);
-
- let comparation = today - timeTicket;
-
- if (comparation == 0)
- return 'warning';
- if (comparation < 0)
- return 'success';
- }
-
get checked() {
const tickets = this.$.model.data || [];
const checkedLines = [];
@@ -134,9 +120,16 @@ export default class Controller extends Section {
'\n' + this.$t(`Destination agency`, {agency: agency});
}
- moveTicketsAdvance() {
+ async moveTicketsAdvance() {
let ticketsToMove = [];
- this.checked.forEach(ticket => {
+ for (const ticket of this.checked) {
+ if (!ticket.id) {
+ try {
+ const {query, params} = await this.requestComponentUpdate(ticket, false);
+ this.$http.post(query, params);
+ } catch (e) {}
+ continue;
+ }
ticketsToMove.push({
originId: ticket.futureId,
destinationId: ticket.id,
@@ -144,15 +137,105 @@ export default class Controller extends Section {
destinationShipped: ticket.shipped,
workerFk: ticket.workerFk
});
- });
+ }
+
const params = {tickets: ticketsToMove};
return this.$http.post('Tickets/merge', params)
.then(() => {
- this.$.model.refresh();
- this.vnApp.showSuccess(this.$t('Success'));
+ this.refresh();
+ if (ticketsToMove.length)
+ this.vnApp.showSuccess(this.$t('Success', {tickets: ticketsToMove.length}));
});
}
+ async getLanded(params) {
+ const query = `Agencies/getLanded`;
+ return this.$http.get(query, {params}).then(res => {
+ if (res.data)
+ return res.data;
+
+ return this.vnApp.showError(
+ this.$t(`No delivery zone available for this landing date`)
+ );
+ });
+ }
+
+ async splitTickets() {
+ this.progress = [];
+ this.splitErrors = [];
+ this.$.splitTickets.hide();
+ this.$.splitProgress.enable = true;
+ this.$.splitProgress.cancel = false;
+ this.$.splitProgress.show();
+
+ for (const ticket of this.checked) {
+ if (this.$.splitProgress.cancel) break;
+ try {
+ const {query, params} = await this.requestComponentUpdate(ticket, true);
+ this.$http.post(query, params)
+ .catch(e => {
+ this.splitErrors.push({id: ticket.futureId, reason: e.message});
+ })
+ .finally(() => this.progressAdd(ticket.futureId));
+ } catch (e) {
+ this.splitErrors.push({id: ticket.futureId, reason: e.message});
+ this.progressAdd(ticket.futureId);
+ }
+ }
+ }
+
+ progressAdd(ticketId) {
+ this.progress.push(ticketId);
+ if (this.progress.length == this.checked.length) {
+ this.$.splitProgress.enable = false;
+ this.refresh();
+ if ((this.progress.length - this.splitErrors.length) > 0) {
+ this.vnApp.showSuccess(this.$t('Success', {
+ tickets: this.progress.length - this.splitErrors.length
+ }));
+ }
+ }
+ }
+
+ async requestComponentUpdate(ticket, isWithoutNegatives) {
+ const query = `tickets/${ticket.futureId}/componentUpdate`;
+ if (!ticket.landed) {
+ const newLanded = await this.getLanded({
+ shipped: this.$.model.userParams.dateToAdvance,
+ addressFk: ticket.addressFk,
+ agencyModeFk: ticket.agencyModeFk,
+ warehouseFk: ticket.warehouseFk
+ });
+ if (!newLanded)
+ throw new Error(this.$t(`No delivery zone available for this landing date`));
+
+ ticket.landed = newLanded.landed;
+ ticket.zoneFk = newLanded.zoneFk;
+ }
+ const params = {
+ clientFk: ticket.clientFk,
+ nickname: ticket.nickname,
+ agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
+ addressFk: ticket.addressFk,
+ zoneFk: ticket.zoneFk ?? ticket.futureZoneFk,
+ warehouseFk: ticket.warehouseFk,
+ companyFk: ticket.companyFk,
+ shipped: this.$.model.userParams.dateToAdvance,
+ landed: ticket.landed,
+ isDeleted: false,
+ isWithoutNegatives,
+ newTicket: ticket.id ?? undefined,
+ keepPrice: true
+ };
+
+ return {query, params};
+ }
+
+ refresh() {
+ this.$.model.refresh();
+ this.$checkAll = null;
+ }
+
exprBuilder(param, value) {
switch (param) {
case 'id':
diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js
index da8614ca5..883993c1c 100644
--- a/modules/ticket/front/advance/index.spec.js
+++ b/modules/ticket/front/advance/index.spec.js
@@ -24,31 +24,6 @@ describe('Component vnTicketAdvance', () => {
}];
}));
- describe('compareDate()', () => {
- it('should return warning when the date is the present', () => {
- let today = Date.vnNew();
- let result = controller.compareDate(today);
-
- expect(result).toEqual('warning');
- });
-
- it('should return sucess when the date is in the future', () => {
- let futureDate = Date.vnNew();
- futureDate = futureDate.setDate(futureDate.getDate() + 10);
- let result = controller.compareDate(futureDate);
-
- expect(result).toEqual('success');
- });
-
- it('should return undefined when the date is in the past', () => {
- let pastDate = Date.vnNew();
- pastDate = pastDate.setDate(pastDate.getDate() - 10);
- let result = controller.compareDate(pastDate);
-
- expect(result).toEqual(undefined);
- });
- });
-
describe('checked()', () => {
it('should return an array of checked tickets', () => {
const result = controller.checked;
diff --git a/modules/ticket/front/advance/locale/es.yml b/modules/ticket/front/advance/locale/es.yml
index 3111d9afd..e42e65b6e 100644
--- a/modules/ticket/front/advance/locale/es.yml
+++ b/modules/ticket/front/advance/locale/es.yml
@@ -1,7 +1,9 @@
Advance tickets: Adelantar tickets
+Advance tickets with negatives: Adelantar tickets con negativos
+Advance tickets without negatives: Adelantar tickets sin negativos
Search advance tickets by date: Busca tickets para adelantar por fecha
Advance confirmation: ¿Desea adelantar {{checked}} tickets?
-Success: Tickets movidos correctamente
+Success: "{{tickets}} Tickets movidos correctamente"
Lines: Líneas
Liters: Litros
Item Packing Type: Encajado
@@ -9,3 +11,7 @@ Origin agency: "Agencia origen: {{agency}}"
Destination agency: "Agencia destino: {{agency}}"
Less than 50€: Menor a 50€
Not Movable: No movibles
+Error list: Lista de errores
+Progress: Progreso
+Total progress: Progreso total
+Advance tickets (without negatives): Adelantar tickets (sin negativos)
diff --git a/modules/ticket/front/advance/style.scss b/modules/ticket/front/advance/style.scss
index 8fa9de438..82ae901cd 100644
--- a/modules/ticket/front/advance/style.scss
+++ b/modules/ticket/front/advance/style.scss
@@ -5,3 +5,12 @@ vn-ticket-advance{
color: #f7931e
}
}
+.split-progress {
+ width: 40em;
+}
+
+@media screen and (max-width: 600px) {
+ .split-progress {
+ width: 100%;
+ }
+}
diff --git a/modules/ticket/front/basic-data/step-two/index.js b/modules/ticket/front/basic-data/step-two/index.js
index 74e2df074..8c8a3a079 100644
--- a/modules/ticket/front/basic-data/step-two/index.js
+++ b/modules/ticket/front/basic-data/step-two/index.js
@@ -114,7 +114,8 @@ class Controller extends Component {
isDeleted: this.ticket.isDeleted,
option: parseInt(this.ticket.option),
isWithoutNegatives: this.ticket.withoutNegatives,
- withWarningAccept: this.ticket.withWarningAccept
+ withWarningAccept: this.ticket.withWarningAccept,
+ keepPrice: false
};
this.$http.post(query, params)
|