@@ -125,19 +124,18 @@
{{::line.packageFk | dashIfEmpty}} |
{{::line.weight}} |
-
+
{{::line.packing | dashIfEmpty}}
|
-
+
{{::line.grouping | dashIfEmpty}}
{{::line.buyingValue | currency: 'EUR':2}} |
{{::line.quantity * line.buyingValue | currency: 'EUR':2}} |
- {{::line.price2 | currency: 'EUR':2}} |
- {{::line.price3 | currency: 'EUR':2}} |
+ {{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}} |
@@ -195,7 +193,7 @@
vn-id="item-descriptor"
warehouse-fk="$ctrl.vnConfig.warehouseFk">
-
diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js
index 401b8dab0..adab3cbeb 100644
--- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js
+++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js
@@ -146,8 +146,8 @@ describe('InvoiceIn filter()', () => {
const options = {transaction: tx};
try {
- const from = new Date();
- const to = new Date();
+ const from = Date.vnNew();
+ const to = Date.vnNew();
from.setHours(0, 0, 0, 0);
to.setHours(23, 59, 59, 999);
to.setDate(to.getDate() + 1);
diff --git a/modules/invoiceIn/front/basic-data/index.spec.js b/modules/invoiceIn/front/basic-data/index.spec.js
index 09aa08293..98710ac35 100644
--- a/modules/invoiceIn/front/basic-data/index.spec.js
+++ b/modules/invoiceIn/front/basic-data/index.spec.js
@@ -78,7 +78,7 @@ describe('InvoiceIn', () => {
description: 'This is a description',
files: [{
lastModified: 1668673957761,
- lastModifiedDate: new Date(),
+ lastModifiedDate: Date.vnNew(),
name: 'file-example.png',
size: 19653,
type: 'image/png',
diff --git a/modules/invoiceIn/front/descriptor/index.js b/modules/invoiceIn/front/descriptor/index.js
index 4dc89a459..e005211a3 100644
--- a/modules/invoiceIn/front/descriptor/index.js
+++ b/modules/invoiceIn/front/descriptor/index.js
@@ -75,7 +75,7 @@ class Controller extends Descriptor {
filter: {
where: {
invoiceInFk: id,
- dueDated: {gte: new Date()}
+ dueDated: {gte: Date.vnNew()}
}
}})
.then(res => {
diff --git a/modules/invoiceIn/front/dueDay/index.js b/modules/invoiceIn/front/dueDay/index.js
index 3cc1c81e8..ee9b13e5c 100644
--- a/modules/invoiceIn/front/dueDay/index.js
+++ b/modules/invoiceIn/front/dueDay/index.js
@@ -4,7 +4,7 @@ import Section from 'salix/components/section';
class Controller extends Section {
add() {
this.$.model.insert({
- dueDated: new Date(),
+ dueDated: Date.vnNew(),
bankFk: this.vnConfig.local.bankFk
});
}
diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js
index d42184ae5..f3c7a5093 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js
@@ -60,9 +60,9 @@ module.exports = Self => {
try {
query = `
SELECT MAX(issued) issued
- FROM vn.invoiceOut io
- JOIN vn.time t ON t.dated = io.issued
- WHERE io.serial = 'A'
+ FROM vn.invoiceOut io
+ JOIN vn.time t ON t.dated = io.issued
+ WHERE io.serial = 'A'
AND t.year = YEAR(?)
AND io.companyFk = ?`;
const [maxIssued] = await Self.rawSql(query, [
@@ -77,7 +77,7 @@ module.exports = Self => {
if (args.invoiceDate < args.maxShipped)
args.maxShipped = args.invoiceDate;
- const minShipped = new Date();
+ const minShipped = Date.vnNew();
minShipped.setFullYear(minShipped.getFullYear() - 1);
minShipped.setMonth(1);
minShipped.setDate(1);
@@ -131,11 +131,11 @@ module.exports = Self => {
const models = Self.app.models;
const args = ctx.args;
const query = `SELECT DISTINCT clientFk AS id
- FROM ticket t
+ FROM ticket t
JOIN ticketPackaging tp ON t.id = tp.ticketFk
JOIN client c ON c.id = t.clientFk
WHERE t.shipped BETWEEN '2017-11-21' AND ?
- AND t.clientFk >= ?
+ AND t.clientFk >= ?
AND (t.clientFk <= ? OR ? IS NULL)
AND c.isActive`;
return models.InvoiceOut.rawSql(query, [
@@ -149,16 +149,16 @@ module.exports = Self => {
async function getInvoiceableClients(ctx, options) {
const models = Self.app.models;
const args = ctx.args;
- const minShipped = new Date();
+ const minShipped = Date.vnNew();
minShipped.setFullYear(minShipped.getFullYear() - 1);
const query = `SELECT
c.id,
SUM(IFNULL
(
- s.quantity *
+ s.quantity *
s.price * (100-s.discount)/100,
- 0)
+ 0)
+ IFNULL(ts.quantity * ts.price,0)
) AS sumAmount,
c.hasToInvoiceByAddress,
@@ -170,7 +170,7 @@ module.exports = Self => {
LEFT JOIN ticketService ts ON ts.ticketFk = t.id
JOIN address a ON a.id = t.addressFk
JOIN client c ON c.id = t.clientFk
- WHERE ISNULL(t.refFk) AND c.id >= ?
+ WHERE ISNULL(t.refFk) AND c.id >= ?
AND (t.clientFk <= ? OR ? IS NULL)
AND t.shipped BETWEEN ? AND util.dayEnd(?)
AND t.companyFk = ? AND c.hasToInvoice
diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js
index 297afa8e8..a458aa18e 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js
@@ -108,14 +108,14 @@ module.exports = Self => {
throw new UserError(`This client is not invoiceable`);
// Can't invoice tickets into future
- const tomorrow = new Date();
+ const tomorrow = Date.vnNew();
tomorrow.setDate(tomorrow.getDate() + 1);
if (maxShipped >= tomorrow)
throw new UserError(`Can't invoice to future`);
const maxInvoiceDate = await getMaxIssued(args.serial, companyId, myOptions);
- if (new Date() < maxInvoiceDate)
+ if (Date.vnNew() < maxInvoiceDate)
throw new UserError(`Can't invoice to past`);
if (ticketId) {
@@ -155,7 +155,7 @@ module.exports = Self => {
async function isInvoiceable(clientId, options) {
const models = Self.app.models;
const query = `SELECT (hasToInvoice AND isTaxDataChecked) AS invoiceable
- FROM client
+ FROM client
WHERE id = ?`;
const [result] = await models.InvoiceOut.rawSql(query, [clientId], options);
@@ -172,12 +172,12 @@ module.exports = Self => {
async function getMaxIssued(serial, companyId, options) {
const models = Self.app.models;
- const query = `SELECT MAX(issued) AS issued
- FROM invoiceOut
+ const query = `SELECT MAX(issued) AS issued
+ FROM invoiceOut
WHERE serial = ? AND companyFk = ?`;
const [maxIssued] = await models.InvoiceOut.rawSql(query,
[serial, companyId], options);
- const maxInvoiceDate = maxIssued && maxIssued.issued || new Date();
+ const maxInvoiceDate = maxIssued && maxIssued.issued || Date.vnNew();
return maxInvoiceDate;
}
diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js
index e5cf5fda0..d3d789393 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js
@@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
describe('InvoiceOut filter()', () => {
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(2, 0, 0, 0);
it('should return the invoice out matching ref', async() => {
diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js
index 5f890de26..9a0574dba 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js
@@ -5,7 +5,7 @@ describe('InvoiceOut invoiceClient()', () => {
const clientId = 1101;
const addressId = 121;
const companyFk = 442;
- const minShipped = new Date();
+ const minShipped = Date.vnNew();
minShipped.setFullYear(minShipped.getFullYear() - 1);
minShipped.setMonth(1);
minShipped.setDate(1);
@@ -33,8 +33,8 @@ describe('InvoiceOut invoiceClient()', () => {
ctx.args = {
clientId: clientId,
addressId: addressId,
- invoiceDate: new Date(),
- maxShipped: new Date(),
+ invoiceDate: Date.vnNew(),
+ maxShipped: Date.vnNew(),
companyFk: companyFk,
minShipped: minShipped
};
diff --git a/modules/invoiceOut/front/index/global-invoicing/index.js b/modules/invoiceOut/front/index/global-invoicing/index.js
index f772a4936..0c5773adc 100644
--- a/modules/invoiceOut/front/index/global-invoicing/index.js
+++ b/modules/invoiceOut/front/index/global-invoicing/index.js
@@ -6,7 +6,7 @@ class Controller extends Dialog {
constructor($element, $, $transclude) {
super($element, $, $transclude);
this.invoice = {
- maxShipped: new Date()
+ maxShipped: Date.vnNew()
};
this.clientsNumber = 'allClients';
}
diff --git a/modules/invoiceOut/front/index/global-invoicing/index.spec.js b/modules/invoiceOut/front/index/global-invoicing/index.spec.js
index e88b0b1d4..aa9674b0e 100644
--- a/modules/invoiceOut/front/index/global-invoicing/index.spec.js
+++ b/modules/invoiceOut/front/index/global-invoicing/index.spec.js
@@ -76,8 +76,8 @@ describe('InvoiceOut', () => {
jest.spyOn(controller.vnApp, 'showError');
controller.invoice = {
- invoiceDate: new Date(),
- maxShipped: new Date()
+ invoiceDate: Date.vnNew(),
+ maxShipped: Date.vnNew()
};
controller.responseHandler('accept');
@@ -88,14 +88,14 @@ describe('InvoiceOut', () => {
it('should make an http POST query and then call to the showSuccess() method', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
- const minShipped = new Date();
+ const minShipped = Date.vnNew();
minShipped.setFullYear(minShipped.getFullYear() - 1);
minShipped.setMonth(1);
minShipped.setDate(1);
minShipped.setHours(0, 0, 0, 0);
controller.invoice = {
- invoiceDate: new Date(),
- maxShipped: new Date(),
+ invoiceDate: Date.vnNew(),
+ maxShipped: Date.vnNew(),
fromClientId: 1101,
toClientId: 1101,
companyFk: 442,
diff --git a/modules/invoiceOut/front/index/manual/index.js b/modules/invoiceOut/front/index/manual/index.js
index ed50e37da..3abe4b825 100644
--- a/modules/invoiceOut/front/index/manual/index.js
+++ b/modules/invoiceOut/front/index/manual/index.js
@@ -8,7 +8,7 @@ class Controller extends Dialog {
this.isInvoicing = false;
this.invoice = {
- maxShipped: new Date()
+ maxShipped: Date.vnNew()
};
}
diff --git a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js
index 68eacfbad..5c3fec7d6 100644
--- a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js
+++ b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js
@@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
describe('upsertFixedPrice()', () => {
- const now = new Date();
+ const now = Date.vnNew();
const fixedPriceId = 1;
let originalFixedPrice;
diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js
index 05b223598..0f57856c7 100644
--- a/modules/item/back/methods/item-image-queue/downloadImages.js
+++ b/modules/item/back/methods/item-image-queue/downloadImages.js
@@ -27,7 +27,7 @@ module.exports = Self => {
});
for (let image of images) {
- const currentStamp = new Date().getTime();
+ const currentStamp = Date.vnNew().getTime();
const updatedStamp = image.updated.getTime();
const graceTime = Math.abs(currentStamp - updatedStamp);
const maxTTL = 3600 * 48 * 1000; // 48 hours in ms;
@@ -97,7 +97,7 @@ module.exports = Self => {
await row.updateAttributes({
error: error,
attempts: row.attempts + 1,
- updated: new Date()
+ updated: Date.vnNew()
});
}
diff --git a/modules/item/back/methods/item/getVisibleAvailable.js b/modules/item/back/methods/item/getVisibleAvailable.js
index b291ad9b4..612f64022 100644
--- a/modules/item/back/methods/item/getVisibleAvailable.js
+++ b/modules/item/back/methods/item/getVisibleAvailable.js
@@ -29,7 +29,7 @@ module.exports = Self => {
}
});
- Self.getVisibleAvailable = async(id, warehouseFk, dated = new Date(), options) => {
+ Self.getVisibleAvailable = async(id, warehouseFk, dated = Date.vnNew(), options) => {
const myOptions = {};
if (typeof options == 'object')
diff --git a/modules/item/back/methods/item/getWasteByItem.js b/modules/item/back/methods/item/getWasteByItem.js
index b93d534da..56b90b04a 100644
--- a/modules/item/back/methods/item/getWasteByItem.js
+++ b/modules/item/back/methods/item/getWasteByItem.js
@@ -32,7 +32,7 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const wastes = await Self.rawSql(`
SELECT *, 100 * dwindle / total AS percentage
@@ -43,7 +43,7 @@ module.exports = Self => {
sum(ws.saleTotal) AS total,
sum(ws.saleWaste) AS dwindle
FROM bs.waste ws
- WHERE buyer = ? AND family = ?
+ WHERE buyer = ? AND family = ?
AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
GROUP BY buyer, itemFk
diff --git a/modules/item/back/methods/item/getWasteByWorker.js b/modules/item/back/methods/item/getWasteByWorker.js
index 4c3c64a91..8fa351eed 100644
--- a/modules/item/back/methods/item/getWasteByWorker.js
+++ b/modules/item/back/methods/item/getWasteByWorker.js
@@ -19,7 +19,7 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const wastes = await Self.rawSql(`
SELECT *, 100 * dwindle / total AS percentage
diff --git a/modules/item/back/methods/item/regularize.js b/modules/item/back/methods/item/regularize.js
index 0878e3242..dfbcaa69f 100644
--- a/modules/item/back/methods/item/regularize.js
+++ b/modules/item/back/methods/item/regularize.js
@@ -94,8 +94,8 @@ module.exports = Self => {
}
async function createTicket(ctx, options) {
- ctx.args.shipped = new Date();
- ctx.args.landed = new Date();
+ ctx.args.shipped = Date.vnNew();
+ ctx.args.landed = Date.vnNew();
ctx.args.companyId = null;
ctx.args.agencyModeId = null;
ctx.args.routeId = null;
@@ -106,10 +106,10 @@ module.exports = Self => {
}
async function getTicketId(params, options) {
- const minDate = new Date();
+ const minDate = Date.vnNew();
minDate.setHours(0, 0, 0, 0);
- const maxDate = new Date();
+ const maxDate = Date.vnNew();
maxDate.setHours(23, 59, 59, 59);
let ticket = await Self.app.models.Ticket.findOne({
diff --git a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js
index 8e4864ee8..13b2417d7 100644
--- a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js
+++ b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js
@@ -8,7 +8,7 @@ describe('item getVisibleAvailable()', () => {
try {
const itemFk = 1;
const warehouseFk = 1;
- const dated = new Date();
+ const dated = Date.vnNew();
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
@@ -29,7 +29,7 @@ describe('item getVisibleAvailable()', () => {
try {
const itemFk = 1;
const warehouseFk = 1;
- const dated = new Date();
+ const dated = Date.vnNew();
dated.setDate(dated.getDate() - 1);
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
index 25e661aee..00488e534 100644
--- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
+++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
@@ -1,9 +1,9 @@
const {models} = require('vn-loopback/server/server');
describe('item lastEntriesFilter()', () => {
it('should return one entry for the given item', async() => {
- const minDate = new Date();
+ const minDate = Date.vnNew();
minDate.setHours(0, 0, 0, 0);
- const maxDate = new Date();
+ const maxDate = Date.vnNew();
maxDate.setHours(23, 59, 59, 59);
const tx = await models.Item.beginTransaction({});
@@ -23,11 +23,11 @@ describe('item lastEntriesFilter()', () => {
});
it('should return five entries for the given item', async() => {
- const minDate = new Date();
+ const minDate = Date.vnNew();
minDate.setHours(0, 0, 0, 0);
minDate.setMonth(minDate.getMonth() - 2, 1);
- const maxDate = new Date();
+ const maxDate = Date.vnNew();
maxDate.setHours(23, 59, 59, 59);
const tx = await models.Item.beginTransaction({});
diff --git a/modules/item/back/methods/tag/onSubmit.js b/modules/item/back/methods/tag/onSubmit.js
new file mode 100644
index 000000000..7abbe60d4
--- /dev/null
+++ b/modules/item/back/methods/tag/onSubmit.js
@@ -0,0 +1,81 @@
+
+module.exports = function(Self) {
+ Self.remoteMethodCtx('onSubmit', {
+ description: 'Save model changes',
+ accessType: 'WRITE',
+ accepts: [
+ {
+ arg: 'creates',
+ type: ['object'],
+ description: 'The itemTags records to create'
+ }, {
+ arg: 'deletes',
+ type: ['number'],
+ description: 'The itemTags ids to delete'
+ }, {
+ arg: 'updates',
+ type: ['object'],
+ description: 'The itemTags records to update'
+ }, {
+ arg: 'maxPriority',
+ type: 'number',
+ description: 'The maxPriority value'
+ }
+ ],
+ returns: {
+ root: true,
+ type: 'object'
+ },
+ http: {
+ verb: 'PATCH',
+ path: '/onSubmit'
+ }
+ });
+
+ Self.onSubmit = async(ctx, options) => {
+ const models = Self.app.models;
+ const args = ctx.args;
+ let tx;
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ if (!myOptions.transaction) {
+ tx = await Self.beginTransaction({});
+ myOptions.transaction = tx;
+ }
+
+ try {
+ if (args.deletes) {
+ for (const itemTagId of args.deletes)
+ await models.ItemTag.destroyById(itemTagId, myOptions);
+ }
+
+ if (args.updates) {
+ for (const row of args.updates) {
+ if (row.data.priority) {
+ const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
+ await itemTag.updateAttributes({
+ priority: row.data.priority + args.maxPriority
+ }, myOptions);
+ }
+ }
+ for (const row of args.updates) {
+ const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
+ await itemTag.updateAttributes(row.data, myOptions);
+ }
+ }
+
+ if (args.creates) {
+ for (const itemTag of args.creates)
+ await models.ItemTag.create(itemTag, myOptions);
+ }
+
+ if (tx) await tx.commit();
+ } catch (e) {
+ if (tx) await tx.rollback();
+ throw e;
+ }
+ };
+};
diff --git a/modules/item/back/methods/tag/specs/onSubmit.spec.js b/modules/item/back/methods/tag/specs/onSubmit.spec.js
new file mode 100644
index 000000000..f24aad7e4
--- /dev/null
+++ b/modules/item/back/methods/tag/specs/onSubmit.spec.js
@@ -0,0 +1,96 @@
+const models = require('vn-loopback/server/server').models;
+
+describe('tag onSubmit()', () => {
+ it('should delete a tag', async() => {
+ const tx = await models.Item.beginTransaction({});
+ const options = {transaction: tx};
+
+ try {
+ const deletes = [40];
+ const ctx = {
+ args: {
+ deletes: deletes
+ }
+ };
+ await models.Tag.onSubmit(ctx, options);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should update a tag', async() => {
+ const tx = await models.Item.beginTransaction({});
+ const options = {transaction: tx};
+
+ try {
+ const updates = [{data: {value: 'Container Test'}, where: {id: 36}}];
+ const ctx = {
+ args: {
+ updates: updates
+ }
+ };
+ await models.Tag.onSubmit(ctx, options);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should create a tag', async() => {
+ const tx = await models.Item.beginTransaction({});
+ const options = {transaction: tx};
+
+ try {
+ const creates = [{
+ 'itemFk': '6',
+ 'priority': 8,
+ '$orgIndex': null,
+ '$oldData': null,
+ '$isNew': true,
+ 'tagFk': 3,
+ 'value': 'madera'
+ }];
+ const ctx = {
+ args: {
+ creates: creates
+ }
+ };
+ await models.Tag.onSubmit(ctx, options);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should swap priority for two tags', async() => {
+ const tx = await models.Item.beginTransaction({});
+ const options = {transaction: tx};
+
+ try {
+ const updates = [
+ {data: {priority: 2}, where: {id: 36}},
+ {data: {priority: 1}, where: {id: 37}}
+ ];
+ const ctx = {
+ args: {
+ updates: updates,
+ maxPriority: 7,
+
+ }
+ };
+ await models.Tag.onSubmit(ctx, options);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+});
diff --git a/modules/item/back/models/tag.js b/modules/item/back/models/tag.js
index 43fbc0db3..92760e34f 100644
--- a/modules/item/back/models/tag.js
+++ b/modules/item/back/models/tag.js
@@ -1,3 +1,4 @@
module.exports = Self => {
require('../methods/tag/filterValue')(Self);
+ require('../methods/tag/onSubmit')(Self);
};
diff --git a/modules/item/front/descriptor/index.js b/modules/item/front/descriptor/index.js
index 133b11b48..b88f24456 100644
--- a/modules/item/front/descriptor/index.js
+++ b/modules/item/front/descriptor/index.js
@@ -80,7 +80,7 @@ class Controller extends Descriptor {
}
onUploadResponse() {
- const timestamp = new Date().getTime();
+ const timestamp = Date.vnNew().getTime();
const src = this.$rootScope.imagePath('catalog', '200x200', this.item.id);
const zoomSrc = this.$rootScope.imagePath('catalog', '1600x900', this.item.id);
const newSrc = `${src}&t=${timestamp}`;
diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js
index c997ea491..1e93f9f16 100644
--- a/modules/item/front/diary/index.js
+++ b/modules/item/front/diary/index.js
@@ -7,7 +7,7 @@ class Controller extends Section {
super($element, $scope);
this.$anchorScroll = $anchorScroll;
this.$location = $location;
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
this.today = today.toJSON();
}
diff --git a/modules/item/front/fixed-price/index.spec.js b/modules/item/front/fixed-price/index.spec.js
index db9579444..5f28e22b1 100644
--- a/modules/item/front/fixed-price/index.spec.js
+++ b/modules/item/front/fixed-price/index.spec.js
@@ -24,7 +24,7 @@ describe('fixed price', () => {
});
it('should perform an http request to update the price', () => {
- const now = new Date();
+ const now = Date.vnNew();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPATCH('FixedPrices/upsertFixedPrice').respond();
diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html
index 0348d4f66..1c2db10a5 100644
--- a/modules/item/front/last-entries/index.html
+++ b/modules/item/front/last-entries/index.html
@@ -9,15 +9,15 @@
-
+
@@ -35,8 +35,7 @@
Warehouse
Landed
Entry
- P.P.U
- P.P.P
+ PVP
Label
Packing
Grouping
@@ -51,7 +50,7 @@
-
@@ -65,30 +64,31 @@
{{::entry.entryFk | dashIfEmpty}}
- {{::entry.price2 | dashIfEmpty}}
- {{::entry.price3 | dashIfEmpty}}
+
+ {{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}}
+
{{entry.stickers | dashIfEmpty}}
-
+
{{::entry.packing | dashIfEmpty}}
-
+
{{::entry.grouping | dashIfEmpty}}
{{::entry.stems | dashIfEmpty}}
{{::entry.quantity}}
-
- {{::entry.cost | dashIfEmpty}}
+ {{::$ctrl.$t('Cost')}}: {{::entry.buyingValue | currency: 'EUR':2 | dashIfEmpty}}
+ {{::$ctrl.$t('Package')}}: {{::entry.packageValue | currency: 'EUR':2 | dashIfEmpty}}
+ {{::$ctrl.$t('Freight')}}: {{::entry.freightValue | currency: 'EUR':2 | dashIfEmpty}}
+ {{::$ctrl.$t('Comission')}}: {{::entry.comissionValue | currency: 'EUR':2 | dashIfEmpty}}">
+ {{::entry.cost | currency: 'EUR':2 | dashIfEmpty}}
{{::entry.weight | dashIfEmpty}}
@@ -113,24 +113,24 @@
ng-click="contextmenu.filterBySelection()">
Filter by selection
-
Exclude selection
-
Remove filter
-
Remove all filters
-
Copy value
-
\ No newline at end of file
+
diff --git a/modules/item/front/last-entries/index.js b/modules/item/front/last-entries/index.js
index 014761da9..0c6804838 100644
--- a/modules/item/front/last-entries/index.js
+++ b/modules/item/front/last-entries/index.js
@@ -5,11 +5,11 @@ class Controller extends Section {
constructor($element, $) {
super($element, $);
- const from = new Date();
+ const from = Date.vnNew();
from.setDate(from.getDate() - 75);
from.setHours(0, 0, 0, 0);
- const to = new Date();
+ const to = Date.vnNew();
to.setDate(to.getDate() + 10);
to.setHours(23, 59, 59, 59);
diff --git a/modules/item/front/request-search-panel/index.spec.js b/modules/item/front/request-search-panel/index.spec.js
index 2fb339209..56c76eabf 100644
--- a/modules/item/front/request-search-panel/index.spec.js
+++ b/modules/item/front/request-search-panel/index.spec.js
@@ -15,7 +15,7 @@ describe(' Component vnRequestSearchPanel', () => {
it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1;
- controller.from = new Date();
+ controller.from = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
@@ -26,7 +26,7 @@ describe(' Component vnRequestSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
- controller.to = new Date();
+ controller.to = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
@@ -35,8 +35,8 @@ describe(' Component vnRequestSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
- controller.filter.from = new Date();
- controller.filter.to = new Date();
+ controller.filter.from = Date.vnNew();
+ controller.filter.to = Date.vnNew();
controller.scopeDays = 1;
diff --git a/modules/item/front/request/index.js b/modules/item/front/request/index.js
index 2fe08ada6..747cbeff2 100644
--- a/modules/item/front/request/index.js
+++ b/modules/item/front/request/index.js
@@ -7,10 +7,10 @@ export default class Controller extends Section {
super($element, $);
if (!this.$state.q) {
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
- const nextWeek = new Date();
+ const nextWeek = Date.vnNew();
nextWeek.setHours(23, 59, 59, 59);
nextWeek.setDate(nextWeek.getDate() + 7);
@@ -27,7 +27,7 @@ export default class Controller extends Section {
$params.scopeDays = 1;
if (typeof $params.scopeDays === 'number') {
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
@@ -82,7 +82,7 @@ export default class Controller extends Section {
}
compareDate(date) {
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let timeTicket = new Date(date);
timeTicket.setHours(0, 0, 0, 0);
diff --git a/modules/item/front/request/index.spec.js b/modules/item/front/request/index.spec.js
index 0fc061023..aadeaddca 100644
--- a/modules/item/front/request/index.spec.js
+++ b/modules/item/front/request/index.spec.js
@@ -93,7 +93,7 @@ describe('Item', () => {
});
it(`should return "warning" if date is today`, () => {
- let date = new Date();
+ let date = Date.vnNew();
let result = controller.compareDate(date);
expect(result).toEqual('warning');
diff --git a/modules/item/front/tags/index.html b/modules/item/front/tags/index.html
index c040b9984..f9b5370fa 100644
--- a/modules/item/front/tags/index.html
+++ b/modules/item/front/tags/index.html
@@ -19,7 +19,7 @@
data="tags"
auto-load="true">
-
\ No newline at end of file
+
diff --git a/modules/item/front/tags/index.js b/modules/item/front/tags/index.js
index 3b3cd58ef..bfa1f3f46 100644
--- a/modules/item/front/tags/index.js
+++ b/modules/item/front/tags/index.js
@@ -29,11 +29,17 @@ class Controller extends Section {
}
onSubmit() {
- this.$.watcher.check();
- this.$.model.save().then(() => {
+ const changes = this.$.model.getChanges();
+ const data = {
+ creates: changes.creates,
+ deletes: changes.deletes,
+ updates: changes.updates,
+ maxPriority: this.getHighestPriority()
+ };
+ this.$http.patch(`Tags/onSubmit`, data).then(() => {
+ this.$.model.refresh();
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
- this.card.reload();
});
}
}
diff --git a/modules/mdb/back/methods/mdbApp/lock.js b/modules/mdb/back/methods/mdbApp/lock.js
index 98e61fb53..a12a93814 100644
--- a/modules/mdb/back/methods/mdbApp/lock.js
+++ b/modules/mdb/back/methods/mdbApp/lock.js
@@ -51,7 +51,7 @@ module.exports = Self => {
const updatedMdbApp = await mdbApp.updateAttributes({
userFk: userId,
- locked: new Date()
+ locked: Date.vnNew()
}, myOptions);
if (tx) await tx.commit();
diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js
index 09ea24eb1..13e38f8e1 100644
--- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js
+++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js
@@ -34,7 +34,7 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const stmt = new ParameterizedSQL(`
SELECT
@@ -51,7 +51,7 @@ module.exports = Self => {
JOIN account.user u ON c.salesPersonFk = u.id
LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk
AND ? BETWEEN sc.started AND sc.ended
- LEFT JOIN workerTeamCollegues wtc
+ LEFT JOIN workerTeamCollegues wtc
ON wtc.collegueFk = IFNULL(sc.workerSubstitute, c.salesPersonFk)`,
[date]);
diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js
index 7be130dda..881fc637a 100644
--- a/modules/monitor/back/methods/sales-monitor/salesFilter.js
+++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js
@@ -104,7 +104,7 @@ module.exports = Self => {
const userId = ctx.req.accessToken.userId;
const conn = Self.dataSource.connector;
const models = Self.app.models;
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const args = ctx.args;
const myOptions = {};
diff --git a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js
index bcb37830c..febfc5357 100644
--- a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js
+++ b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js
@@ -8,8 +8,8 @@ describe('SalesMonitor clientsFilter()', () => {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
- const from = new Date();
- const to = new Date();
+ const from = Date.vnNew();
+ const to = Date.vnNew();
from.setHours(0, 0, 0, 0);
to.setHours(23, 59, 59, 59);
@@ -35,9 +35,9 @@ describe('SalesMonitor clientsFilter()', () => {
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
- const yesterday = new Date();
+ const yesterday = Date.vnNew();
yesterday.setDate(yesterday.getDate() - 1);
- const today = new Date();
+ const today = Date.vnNew();
yesterday.setHours(0, 0, 0, 0);
today.setHours(23, 59, 59, 59);
diff --git a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js
index d2e1a5bec..4e0fb85b7 100644
--- a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js
+++ b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js
@@ -26,9 +26,9 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
- const yesterday = new Date();
+ const yesterday = Date.vnNew();
yesterday.setHours(0, 0, 0, 0);
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: {
@@ -54,10 +54,10 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
- const yesterday = new Date();
+ const yesterday = Date.vnNew();
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: {
@@ -205,10 +205,10 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
- const yesterday = new Date();
+ const yesterday = Date.vnNew();
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
@@ -234,10 +234,10 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
- const yesterday = new Date();
+ const yesterday = Date.vnNew();
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
diff --git a/modules/monitor/front/index/clients/index.js b/modules/monitor/front/index/clients/index.js
index 58613f09d..ac3ce9140 100644
--- a/modules/monitor/front/index/clients/index.js
+++ b/modules/monitor/front/index/clients/index.js
@@ -5,7 +5,7 @@ export default class Controller extends Section {
constructor($element, $) {
super($element, $);
- const date = new Date();
+ const date = Date.vnNew();
this.dateFrom = date;
this.dateTo = date;
this.filter = {
@@ -64,9 +64,9 @@ export default class Controller extends Section {
let from = this.dateFrom;
let to = this.dateTo;
if (!from)
- from = new Date();
+ from = Date.vnNew();
if (!to)
- to = new Date();
+ to = Date.vnNew();
const minHour = new Date(from);
minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(to);
diff --git a/modules/monitor/front/index/orders/index.js b/modules/monitor/front/index/orders/index.js
index e3a47f68b..40100b79f 100644
--- a/modules/monitor/front/index/orders/index.js
+++ b/modules/monitor/front/index/orders/index.js
@@ -26,7 +26,7 @@ export default class Controller extends Section {
}
chipColor(date) {
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
const orderLanded = new Date(date);
diff --git a/modules/monitor/front/index/search-panel/index.spec.js b/modules/monitor/front/index/search-panel/index.spec.js
index f862e8d77..18cf1abfc 100644
--- a/modules/monitor/front/index/search-panel/index.spec.js
+++ b/modules/monitor/front/index/search-panel/index.spec.js
@@ -38,7 +38,7 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1;
- controller.from = new Date();
+ controller.from = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
@@ -49,7 +49,7 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
- controller.to = new Date();
+ controller.to = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
@@ -58,8 +58,8 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
- controller.filter.from = new Date();
- controller.filter.to = new Date();
+ controller.filter.from = Date.vnNew();
+ controller.filter.to = Date.vnNew();
controller.scopeDays = 1;
diff --git a/modules/monitor/front/index/tickets/index.js b/modules/monitor/front/index/tickets/index.js
index 91d9079d8..2f2dead05 100644
--- a/modules/monitor/front/index/tickets/index.js
+++ b/modules/monitor/front/index/tickets/index.js
@@ -91,7 +91,7 @@ export default class Controller extends Section {
$params.scopeDays = 1;
if (typeof $params.scopeDays === 'number') {
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
@@ -105,7 +105,7 @@ export default class Controller extends Section {
}
compareDate(date) {
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let timeTicket = new Date(date);
timeTicket.setHours(0, 0, 0, 0);
diff --git a/modules/monitor/front/index/tickets/index.spec.js b/modules/monitor/front/index/tickets/index.spec.js
index 5d42743c1..c12ea6844 100644
--- a/modules/monitor/front/index/tickets/index.spec.js
+++ b/modules/monitor/front/index/tickets/index.spec.js
@@ -32,7 +32,7 @@ describe('Component vnMonitorSalesTickets', () => {
let params = controller.fetchParams({
scopeDays: 2
});
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
to.setDate(to.getDate() + params.scopeDays);
@@ -66,14 +66,14 @@ describe('Component vnMonitorSalesTickets', () => {
describe('compareDate()', () => {
it('should return warning when the date is the present', () => {
- let today = new Date();
+ 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 = new Date();
+ let futureDate = Date.vnNew();
futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate);
@@ -81,7 +81,7 @@ describe('Component vnMonitorSalesTickets', () => {
});
it('should return undefined when the date is in the past', () => {
- let pastDate = new Date();
+ let pastDate = Date.vnNew();
pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate);
@@ -99,7 +99,7 @@ describe('Component vnMonitorSalesTickets', () => {
describe('dateRange()', () => {
it('should return two dates with the hours at the start and end of the given date', () => {
- const now = new Date();
+ const now = Date.vnNew();
const today = now.getDate();
diff --git a/modules/order/back/methods/order/specs/new.spec.js b/modules/order/back/methods/order/specs/new.spec.js
index 5873189f8..f11367579 100644
--- a/modules/order/back/methods/order/specs/new.spec.js
+++ b/modules/order/back/methods/order/specs/new.spec.js
@@ -9,7 +9,7 @@ describe('order new()', () => {
try {
const options = {transaction: tx};
- const landed = new Date();
+ const landed = Date.vnNew();
const addressFk = 6;
const agencyModeFk = 1;
@@ -30,7 +30,7 @@ describe('order new()', () => {
try {
const options = {transaction: tx};
- const landed = new Date();
+ const landed = Date.vnNew();
const addressFk = 121;
const agencyModeFk = 1;
diff --git a/modules/order/front/basic-data/index.spec.js b/modules/order/front/basic-data/index.spec.js
index 01009d085..21dee0765 100644
--- a/modules/order/front/basic-data/index.spec.js
+++ b/modules/order/front/basic-data/index.spec.js
@@ -46,7 +46,7 @@ describe('Order', () => {
it('should set agencyModeFk to null and get the available agencies if the order has landed and client', async() => {
controller.order.agencyModeFk = 999;
controller.order.addressFk = 999;
- controller.order.landed = new Date();
+ controller.order.landed = Date.vnNew();
const expectedAgencies = [{id: 1}, {id: 2}];
diff --git a/modules/order/front/index/index.js b/modules/order/front/index/index.js
index a8e6e977e..750f2e226 100644
--- a/modules/order/front/index/index.js
+++ b/modules/order/front/index/index.js
@@ -8,7 +8,7 @@ export default class Controller extends Section {
}
compareDate(date) {
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
date = new Date(date);
diff --git a/modules/order/front/index/index.spec.js b/modules/order/front/index/index.spec.js
index 5b85b3333..abe336478 100644
--- a/modules/order/front/index/index.spec.js
+++ b/modules/order/front/index/index.spec.js
@@ -26,14 +26,14 @@ describe('Component vnOrderIndex', () => {
describe('compareDate()', () => {
it('should return warning when the date is the present', () => {
- let curDate = new Date();
+ let curDate = Date.vnNew();
let result = controller.compareDate(curDate);
expect(result).toEqual('warning');
});
it('should return sucess when the date is in the future', () => {
- let futureDate = new Date();
+ let futureDate = Date.vnNew();
futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate);
@@ -41,7 +41,7 @@ describe('Component vnOrderIndex', () => {
});
it('should return undefined when the date is in the past', () => {
- let pastDate = new Date();
+ let pastDate = Date.vnNew();
pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate);
diff --git a/modules/route/back/methods/agency-term/filter.js b/modules/route/back/methods/agency-term/filter.js
index 0ecec7e88..9d1268958 100644
--- a/modules/route/back/methods/agency-term/filter.js
+++ b/modules/route/back/methods/agency-term/filter.js
@@ -74,35 +74,35 @@ module.exports = Self => {
filter = mergeFilters(filter, {where});
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const stmts = [];
const stmt = new ParameterizedSQL(
`SELECT *
FROM (
- SELECT r.id routeFk,
- r.created,
- r.agencyModeFk,
+ SELECT r.id routeFk,
+ r.created,
+ r.agencyModeFk,
am.name agencyModeName,
- am.agencyFk,
+ am.agencyFk,
a.name agencyAgreement,
SUM(t.packages) packages,
r.m3,
- r.kmEnd - r.kmStart kmTotal,
- CAST(IFNULL(sat.routePrice,
- (sat.kmPrice * (GREATEST(r.kmEnd - r.kmStart , sat.minimumKm))
- + GREATEST(r.m3 , sat.minimumM3) * sat.m3Price)
- + sat.packagePrice * SUM(t.packages) )
+ r.kmEnd - r.kmStart kmTotal,
+ CAST(IFNULL(sat.routePrice,
+ (sat.kmPrice * (GREATEST(r.kmEnd - r.kmStart , sat.minimumKm))
+ + GREATEST(r.m3 , sat.minimumM3) * sat.m3Price)
+ + sat.packagePrice * SUM(t.packages) )
AS DECIMAL(10,2)) price,
r.invoiceInFk,
sat.supplierFk,
s.name supplierName
FROM vn.route r
- LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id
+ LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id
LEFT JOIN vn.agency a ON am.agencyFk = a.id
LEFT JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
- LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
+ LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
WHERE r.created > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL
GROUP BY r.id
) a`
diff --git a/modules/route/back/methods/agency-term/specs/filter.spec.js b/modules/route/back/methods/agency-term/specs/filter.spec.js
index d6c00e585..41e696157 100644
--- a/modules/route/back/methods/agency-term/specs/filter.spec.js
+++ b/modules/route/back/methods/agency-term/specs/filter.spec.js
@@ -3,7 +3,7 @@ const models = require('vn-loopback/server/server').models;
describe('AgencyTerm filter()', () => {
const authUserId = 9;
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(2, 0, 0, 0);
it('should return all results matching the filter', async() => {
@@ -57,10 +57,10 @@ describe('AgencyTerm filter()', () => {
const options = {transaction: tx};
try {
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
- const to = new Date();
+ const to = Date.vnNew();
to.setHours(23, 59, 59, 999);
const ctx = {
diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js
new file mode 100644
index 000000000..597f1d1f6
--- /dev/null
+++ b/modules/route/back/methods/route/downloadZip.js
@@ -0,0 +1,62 @@
+const JSZip = require('jszip');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('downloadZip', {
+ description: 'Download a zip file with multiple routes pdfs',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'id',
+ type: 'string',
+ description: 'The routes ids',
+ }
+ ],
+ returns: [
+ {
+ arg: 'body',
+ type: 'file',
+ root: true
+ }, {
+ arg: 'Content-Type',
+ type: 'string',
+ http: {target: 'header'}
+ }, {
+ arg: 'Content-Disposition',
+ type: 'string',
+ http: {target: 'header'}
+ }
+ ],
+ http: {
+ path: '/downloadZip',
+ verb: 'GET'
+ }
+ });
+
+ Self.downloadZip = async function(ctx, id, options) {
+ const models = Self.app.models;
+ const myOptions = {};
+ const zip = new JSZip();
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ const ids = id.split(',');
+ for (let id of ids) {
+ ctx.args.id = id;
+ const routePdf = await models.Route.driverRoutePdf(ctx, id);
+ const fileName = extractFileName(routePdf[2]);
+ const body = routePdf[0];
+
+ zip.file(fileName, body);
+ }
+
+ const stream = zip.generateNodeStream({streamFiles: true});
+
+ return [stream, 'application/zip', `filename="download.zip"`];
+ };
+
+ function extractFileName(str) {
+ const matches = str.match(/"(.*?)"/);
+ return matches ? matches[1] : str;
+ }
+};
diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js
index 708644c1a..1eb9e27f5 100644
--- a/modules/route/back/methods/route/getTickets.js
+++ b/modules/route/back/methods/route/getTickets.js
@@ -50,14 +50,17 @@ module.exports = Self => {
am.name AS agencyModeName,
u.nickname AS userNickname,
vn.ticketTotalVolume(t.id) AS volume,
- tob.description
+ tob.description,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt
FROM vn.route r
JOIN ticket t ON t.routeFk = r.id
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN observationType ot ON ot.code = 'delivery'
- LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id
+ LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id
AND tob.observationTypeFk = ot.id
LEFT JOIN address a ON a.id = t.addressFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
@@ -70,7 +73,9 @@ module.exports = Self => {
const where = filter.where;
where['r.id'] = filter.id;
- stmt.merge(conn.makeSuffix(filter));
+ stmt.merge(conn.makeWhere(filter.where));
+ stmt.merge(conn.makeGroupBy('t.id'));
+ stmt.merge(conn.makeOrderBy(filter.order));
const tickets = await conn.executeStmt(stmt, myOptions);
diff --git a/modules/route/back/methods/route/specs/clone.spec.js b/modules/route/back/methods/route/specs/clone.spec.js
index d1fc6b297..9192854f8 100644
--- a/modules/route/back/methods/route/specs/clone.spec.js
+++ b/modules/route/back/methods/route/specs/clone.spec.js
@@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server');
describe('route clone()', () => {
- const createdDate = new Date();
+ const createdDate = Date.vnNew();
it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => {
const ids = [996, 997, 998, 999];
diff --git a/modules/route/back/methods/route/specs/filter.spec.js b/modules/route/back/methods/route/specs/filter.spec.js
index 9d481f21e..18c0ca04f 100644
--- a/modules/route/back/methods/route/specs/filter.spec.js
+++ b/modules/route/back/methods/route/specs/filter.spec.js
@@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
const models = require('vn-loopback/server/server').models;
describe('Route filter()', () => {
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(2, 0, 0, 0);
it('should return the routes matching "search"', async() => {
@@ -23,10 +23,10 @@ describe('Route filter()', () => {
const options = {transaction: tx};
try {
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
- const to = new Date();
+ const to = Date.vnNew();
to.setHours(23, 59, 59, 999);
const ctx = {
args: {
diff --git a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js
index bb38cb50e..0acc6c1a7 100644
--- a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js
+++ b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js
@@ -23,7 +23,7 @@ describe('route getSuggestedTickets()', () => {
await ticketInRoute.updateAttributes({
routeFk: null,
- landed: new Date()
+ landed: Date.vnNew()
}, options);
const result = await models.Route.getSuggestedTickets(routeID, options);
diff --git a/modules/route/back/methods/route/specs/insertTicket.spec.js b/modules/route/back/methods/route/specs/insertTicket.spec.js
index 7c60e755f..19d02e1ef 100644
--- a/modules/route/back/methods/route/specs/insertTicket.spec.js
+++ b/modules/route/back/methods/route/specs/insertTicket.spec.js
@@ -23,7 +23,7 @@ describe('route insertTicket()', () => {
const ticketInRoute = await app.models.Ticket.findById(ticketId, null, options);
await ticketInRoute.updateAttributes({
routeFk: null,
- landed: new Date()
+ landed: Date.vnNew()
}, options);
const result = await app.models.Route.insertTicket(routeId, ticketId, options);
diff --git a/modules/route/back/methods/route/updateWorkCenter.js b/modules/route/back/methods/route/updateWorkCenter.js
index 7796fba41..75169ce7e 100644
--- a/modules/route/back/methods/route/updateWorkCenter.js
+++ b/modules/route/back/methods/route/updateWorkCenter.js
@@ -33,12 +33,13 @@ module.exports = Self => {
}
try {
+ const date = Date.vnNew();
const [result] = await Self.rawSql(`
SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter
FROM vn.routeConfig r
LEFT JOIN vn.workerLabour wl ON wl.workerFk = ?
- AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE());
- `, [userId], myOptions);
+ AND ? BETWEEN wl.started AND IFNULL(wl.ended, ?);
+ `, [userId, date, date], myOptions);
const route = await models.Route.findById(id, null, myOptions);
await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions);
diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js
index 08cabd30e..883f4597e 100644
--- a/modules/route/back/models/route.js
+++ b/modules/route/back/models/route.js
@@ -13,6 +13,7 @@ module.exports = Self => {
require('../methods/route/driverRoutePdf')(Self);
require('../methods/route/driverRouteEmail')(Self);
require('../methods/route/sendSms')(Self);
+ require('../methods/route/downloadZip')(Self);
Self.validate('kmStart', validateDistance, {
message: 'Distance must be lesser than 1000'
diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js
index 9258c8fac..7c19a26cd 100644
--- a/modules/route/front/index/index.js
+++ b/modules/route/front/index/index.js
@@ -34,17 +34,27 @@ export default class Controller extends Section {
}
showRouteReport() {
- const routes = [];
+ const routesIds = [];
for (let route of this.checked)
- routes.push(route.id);
- const routesId = routes.join(',');
+ routesIds.push(route.id);
+ const stringRoutesIds = routesIds.join(',');
- this.vnReport.show(`Routes/${routesId}/driver-route-pdf`);
+ if (this.checked.length <= 1) {
+ const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.token}`;
+ window.open(url, '_blank');
+ } else {
+ const serializedParams = this.$httpParamSerializer({
+ access_token: this.vnToken.token,
+ id: stringRoutesIds
+ });
+ const url = `api/Routes/downloadZip?${serializedParams}`;
+ window.open(url, '_blank');
+ }
}
openClonationDialog() {
this.$.clonationDialog.show();
- this.createdDate = new Date();
+ this.createdDate = Date.vnNew();
}
cloneSelectedRoutes() {
diff --git a/modules/route/front/index/index.spec.js b/modules/route/front/index/index.spec.js
index 05dd56433..399ece714 100644
--- a/modules/route/front/index/index.spec.js
+++ b/modules/route/front/index/index.spec.js
@@ -44,23 +44,21 @@ describe('Component vnRouteIndex', () => {
describe('showRouteReport()', () => {
it('should call to the vnReport show method', () => {
- controller.vnReport.show = jest.fn();
+ jest.spyOn(window, 'open').mockReturnThis();
const data = controller.$.model.data;
data[0].checked = true;
data[2].checked = true;
- const routeIds = '1,3';
-
controller.showRouteReport();
- expect(controller.vnReport.show).toHaveBeenCalledWith(`Routes/${routeIds}/driver-route-pdf`);
+ expect(window.open).toHaveBeenCalled();
});
});
describe('cloneSelectedRoutes()', () => {
it('should perform an http request to Routes/clone', () => {
- controller.createdDate = new Date();
+ controller.createdDate = Date.vnNew();
$httpBackend.expect('POST', 'Routes/clone').respond();
controller.cloneSelectedRoutes();
diff --git a/modules/route/front/main/index.js b/modules/route/front/main/index.js
index 938f81bcc..8c57bbad6 100644
--- a/modules/route/front/main/index.js
+++ b/modules/route/front/main/index.js
@@ -3,11 +3,11 @@ import ModuleMain from 'salix/components/module-main';
export default class Route extends ModuleMain {
$postLink() {
- const to = new Date();
+ const to = Date.vnNew();
to.setDate(to.getDate() + 1);
to.setHours(0, 0, 0, 0);
- const from = new Date();
+ const from = Date.vnNew();
from.setDate(from.getDate());
from.setHours(0, 0, 0, 0);
@@ -21,7 +21,7 @@ export default class Route extends ModuleMain {
$params.scopeDays = 1;
if (typeof $params.scopeDays === 'number') {
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
diff --git a/modules/route/front/main/index.spec.js b/modules/route/front/main/index.spec.js
index e5724b493..0c16a7b1f 100644
--- a/modules/route/front/main/index.spec.js
+++ b/modules/route/front/main/index.spec.js
@@ -15,7 +15,7 @@ describe('Route Component vnRoute', () => {
let params = controller.fetchParams({
scopeDays: 2
});
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
to.setDate(to.getDate() + params.scopeDays);
diff --git a/modules/route/front/search-panel/index.spec.js b/modules/route/front/search-panel/index.spec.js
index 16e1a5cfc..ae15e16e4 100644
--- a/modules/route/front/search-panel/index.spec.js
+++ b/modules/route/front/search-panel/index.spec.js
@@ -15,7 +15,7 @@ describe('Route Component vnRouteSearchPanel', () => {
it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1;
- controller.from = new Date();
+ controller.from = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
@@ -26,7 +26,7 @@ describe('Route Component vnRouteSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
- controller.to = new Date();
+ controller.to = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
@@ -35,8 +35,8 @@ describe('Route Component vnRouteSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
- controller.filter.from = new Date();
- controller.filter.to = new Date();
+ controller.filter.from = Date.vnNew();
+ controller.filter.to = Date.vnNew();
controller.scopeDays = 1;
diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html
index 86f558634..a64ad4ff7 100644
--- a/modules/route/front/summary/index.html
+++ b/modules/route/front/summary/index.html
@@ -10,26 +10,26 @@
-
-
-
-
-
{{$ctrl.summary.route.worker.user.name}}
-
@@ -40,35 +40,35 @@
-
-
-
-
-
Ticket
@@ -77,45 +77,49 @@
Order
- Ticket id
- Alias
+ Street
+ City
+ PC
+ Client
+ Warehouse
Packages
m³
- Warehouse
- PC
- Street
+ Packaging
+ Ticket
{{ticket.priority | dashIfEmpty}}
+ {{ticket.street}}
+ {{ticket.city}}
+ {{ticket.postalCode}}
+
+
+ {{ticket.nickname}}
+
+
+ {{ticket.warehouseName}}
+ {{ticket.packages}}
+ {{ticket.volume}}
+ {{ticket.ipt}}
-
{{ticket.id}}
-
- {{ticket.nickname}}
-
-
- {{ticket.packages}}
- {{ticket.volume}}
- {{ticket.warehouseName}}
- {{ticket.postalCode}}
- {{ticket.street}}
-
-
-
+
+
@@ -123,12 +127,12 @@
-
-
diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html
index dae894ac7..18d6fb160 100644
--- a/modules/route/front/tickets/index.html
+++ b/modules/route/front/tickets/index.html
@@ -6,9 +6,9 @@
data="$ctrl.tickets"
auto-load="true">
-
-
-
-
@@ -160,7 +164,7 @@
-
-
-
\ No newline at end of file
+
diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json
index 09a8e389b..4059e5095 100644
--- a/modules/shelving/front/routes.json
+++ b/modules/shelving/front/routes.json
@@ -1,12 +1,12 @@
{
"module": "shelving",
"name": "Shelvings",
- "icon" : "contact_support",
+ "icon" : "icon-inventory",
"dependencies": ["worker"],
"validations" : true,
"menus": {
"main": [
- {"state": "shelving.index", "icon": "contact_support"}
+ {"state": "shelving.index", "icon": "icon-inventory"}
],
"card": [
{"state": "shelving.card.basicData", "icon": "settings"},
@@ -20,7 +20,7 @@
"abstract": true,
"component": "vn-shelving",
"description": "Shelvings"
- },
+ },
{
"url": "/index?q",
"state": "shelving.index",
@@ -32,13 +32,13 @@
"state": "shelving.create",
"component": "vn-shelving-create",
"description": "New shelving"
- },
+ },
{
"url": "/:id",
"state": "shelving.card",
"abstract": true,
"component": "vn-shelving-card"
- },
+ },
{
"url": "/summary",
"state": "shelving.card.summary",
@@ -47,7 +47,7 @@
"params": {
"shelving": "$ctrl.shelving"
}
- },
+ },
{
"url": "/basic-data",
"state": "shelving.card.basicData",
@@ -56,7 +56,7 @@
"params": {
"shelving": "$ctrl.shelving"
}
- },
+ },
{
"url" : "/log",
"state": "shelving.card.log",
@@ -64,4 +64,4 @@
"description": "Log"
}
]
-}
\ No newline at end of file
+}
diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js
index 44549c65c..4e509aafc 100644
--- a/modules/supplier/back/models/supplier.js
+++ b/modules/supplier/back/models/supplier.js
@@ -16,10 +16,6 @@ module.exports = Self => {
message: 'The social name cannot be empty'
});
- Self.validatesUniquenessOf('name', {
- message: 'The supplier name must be unique'
- });
-
if (this.city) {
Self.validatesPresenceOf('city', {
message: 'City cannot be empty'
@@ -117,6 +113,27 @@ module.exports = Self => {
throw new UserError('You can not modify is pay method checked');
});
+ Self.validateAsync('name', 'countryFk', hasSupplierSameName, {
+ message: 'A supplier with the same name already exists. Change the country.'
+ });
+
+ async function hasSupplierSameName(err, done) {
+ if (!this.name || !this.countryFk) done();
+ const supplier = await Self.app.models.Supplier.findOne(
+ {
+ where: {
+ name: this.name,
+ countryFk: this.countryFk
+ },
+ fields: ['id']
+ });
+
+ if (supplier && supplier.id != this.id)
+ err();
+
+ done();
+ }
+
Self.observe('before save', async function(ctx) {
const changes = ctx.data || ctx.instance;
const orgData = ctx.currentInstance;
diff --git a/modules/supplier/front/agency-term/index/index.html b/modules/supplier/front/agency-term/index/index.html
index 9d53226c5..44c6deba9 100644
--- a/modules/supplier/front/agency-term/index/index.html
+++ b/modules/supplier/front/agency-term/index/index.html
@@ -24,36 +24,42 @@
diff --git a/modules/supplier/front/consumption/index.js b/modules/supplier/front/consumption/index.js
index 8de6a1e71..9af0d1747 100644
--- a/modules/supplier/front/consumption/index.js
+++ b/modules/supplier/front/consumption/index.js
@@ -11,11 +11,11 @@ class Controller extends Section {
}
setDefaultFilter() {
- const minDate = new Date();
+ const minDate = Date.vnNew();
minDate.setHours(0, 0, 0, 0);
minDate.setMonth(minDate.getMonth() - 2);
- const maxDate = new Date();
+ const maxDate = Date.vnNew();
maxDate.setHours(23, 59, 59, 59);
this.filterParams = {
diff --git a/modules/supplier/front/consumption/index.spec.js b/modules/supplier/front/consumption/index.spec.js
index ebf19ccec..0ac531a68 100644
--- a/modules/supplier/front/consumption/index.spec.js
+++ b/modules/supplier/front/consumption/index.spec.js
@@ -28,7 +28,7 @@ describe('Supplier', () => {
it('should call the window.open function', () => {
jest.spyOn(window, 'open').mockReturnThis();
- const now = new Date();
+ const now = Date.vnNew();
controller.$.model.userParams = {
from: now,
to: now
@@ -86,7 +86,7 @@ describe('Supplier', () => {
{id: 1, email: 'batman@gothamcity.com'}
]);
- const now = new Date();
+ const now = Date.vnNew();
controller.$.model.userParams = {
from: now,
to: now
diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js
index a26d9c510..9f23ce68c 100644
--- a/modules/supplier/front/descriptor/index.js
+++ b/modules/supplier/front/descriptor/index.js
@@ -13,7 +13,7 @@ class Controller extends Descriptor {
get entryFilter() {
if (!this.supplier) return null;
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const from = new Date(date.getTime());
diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js
index 67919e76c..ac397d38e 100644
--- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js
+++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js
@@ -14,7 +14,7 @@ describe('ticket moveExpeditions()', () => {
const options = {transaction: tx};
myCtx.args = {
clientId: 1101,
- landed: new Date(),
+ landed: Date.vnNew(),
warehouseId: 1,
addressId: 121,
agencyModeId: 1,
diff --git a/modules/ticket/back/methods/sale/canEdit.js b/modules/ticket/back/methods/sale/canEdit.js
index f44bd6743..3091ebca7 100644
--- a/modules/ticket/back/methods/sale/canEdit.js
+++ b/modules/ticket/back/methods/sale/canEdit.js
@@ -56,6 +56,13 @@ module.exports = Self => {
const shouldEditCloned = canEditCloned || !hasSaleCloned;
const shouldEditFloramondo = canEditFloramondo || !hasSaleFloramondo;
- return shouldEditTracked && shouldEditCloned && shouldEditFloramondo;
+ if (!shouldEditTracked)
+ throw new UserError('It is not possible to modify tracked sales');
+ if (!shouldEditCloned)
+ throw new UserError('It is not possible to modify cloned sales');
+ if (!shouldEditFloramondo)
+ throw new UserError('It is not possible to modify sales that their articles are from Floramondo');
+
+ return true;
};
};
diff --git a/modules/ticket/back/methods/sale/deleteSales.js b/modules/ticket/back/methods/sale/deleteSales.js
index c045b9197..5d1463a66 100644
--- a/modules/ticket/back/methods/sale/deleteSales.js
+++ b/modules/ticket/back/methods/sale/deleteSales.js
@@ -43,9 +43,7 @@ module.exports = Self => {
try {
const saleIds = sales.map(sale => sale.id);
- const canEditSales = await models.Sale.canEdit(ctx, saleIds, myOptions);
- if (!canEditSales)
- throw new UserError(`Sale(s) blocked, please contact production`);
+ await models.Sale.canEdit(ctx, saleIds, myOptions);
const ticket = await models.Ticket.findById(ticketId, {
include: {
diff --git a/modules/ticket/back/methods/sale/getClaimableFromTicket.js b/modules/ticket/back/methods/sale/getClaimableFromTicket.js
index ecbc52b94..c51781f59 100644
--- a/modules/ticket/back/methods/sale/getClaimableFromTicket.js
+++ b/modules/ticket/back/methods/sale/getClaimableFromTicket.js
@@ -24,24 +24,24 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const query = `
- SELECT
- s.id AS saleFk,
- t.id AS ticketFk,
+ SELECT
+ s.id AS saleFk,
+ t.id AS ticketFk,
t.landed,
- s.concept,
- s.itemFk,
- s.quantity,
- s.price,
- s.discount,
+ s.concept,
+ s.itemFk,
+ s.quantity,
+ s.price,
+ s.discount,
t.nickname
- FROM vn.ticket t
+ FROM vn.ticket t
INNER JOIN vn.sale s ON s.ticketFk = t.id
LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id
- WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, ?)
+ WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, ?)
AND t.id = ? AND cb.id IS NULL
ORDER BY t.landed DESC, t.id DESC`;
diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js
index 38c68d7f6..2c8e6768b 100644
--- a/modules/ticket/back/methods/sale/recalculatePrice.js
+++ b/modules/ticket/back/methods/sale/recalculatePrice.js
@@ -37,9 +37,7 @@ module.exports = Self => {
try {
const salesIds = sales.map(sale => sale.id);
- const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
- if (!canEditSale)
- throw new UserError(`Sale(s) blocked, please contact production`);
+ await models.Sale.canEdit(ctx, salesIds, myOptions);
const query = `
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js
index c0c431636..febef9730 100644
--- a/modules/ticket/back/methods/sale/refund.js
+++ b/modules/ticket/back/methods/sale/refund.js
@@ -64,7 +64,7 @@ module.exports = Self => {
const refundTickets = [];
- const now = new Date();
+ const now = Date.vnNew();
const mappedTickets = new Map();
for (let ticketId of ticketsIds) {
diff --git a/modules/ticket/back/methods/sale/reserve.js b/modules/ticket/back/methods/sale/reserve.js
index 648e6de23..2dc368af6 100644
--- a/modules/ticket/back/methods/sale/reserve.js
+++ b/modules/ticket/back/methods/sale/reserve.js
@@ -51,9 +51,7 @@ module.exports = Self => {
try {
const salesIds = sales.map(sale => sale.id);
- const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
- if (!canEditSale)
- throw new UserError(`Sale(s) blocked, please contact production`);
+ await models.Sale.canEdit(ctx, salesIds, myOptions);
let changesMade = '';
const promises = [];
diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js
index 2aa873df5..58d8f0635 100644
--- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js
+++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js
@@ -50,7 +50,7 @@ describe('sale canEdit()', () => {
it('should return false if any of the sales has a saleTracking record', async() => {
const tx = await models.Sale.beginTransaction({});
-
+ let error;
try {
const options = {transaction: tx};
@@ -59,15 +59,15 @@ describe('sale canEdit()', () => {
const sales = [31];
- const result = await models.Sale.canEdit(ctx, sales, options);
-
- expect(result).toEqual(false);
-
+ await models.Sale.canEdit(ctx, sales, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
- throw e;
+ error = e;
}
+
+ expect(error).toEqual(
+ new Error('It is not possible to modify tracked sales'));
});
});
@@ -75,22 +75,22 @@ describe('sale canEdit()', () => {
const saleCloned = [29];
it('should return false if any of the sales is cloned', async() => {
const tx = await models.Sale.beginTransaction({});
-
+ let error;
try {
const options = {transaction: tx};
const buyerId = 35;
const ctx = {req: {accessToken: {userId: buyerId}}};
- const result = await models.Sale.canEdit(ctx, saleCloned, options);
-
- expect(result).toEqual(false);
-
+ await models.Sale.canEdit(ctx, saleCloned, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
- throw e;
+ error = e;
}
+
+ expect(error).toEqual(
+ new Error('It is not possible to modify cloned sales'));
});
it('should return true if any of the sales is cloned and has the correct role', async() => {
@@ -130,7 +130,7 @@ describe('sale canEdit()', () => {
it('should return false if any of the sales isFloramondo', async() => {
const tx = await models.Sale.beginTransaction({});
const sales = [26];
-
+ let error;
try {
const options = {transaction: tx};
@@ -140,15 +140,15 @@ describe('sale canEdit()', () => {
const saleToEdit = await models.Sale.findById(sales[0], null, options);
await saleToEdit.updateAttribute('itemFk', 9, options);
- const result = await models.Sale.canEdit(ctx, sales, options);
-
- expect(result).toEqual(false);
-
+ await models.Sale.canEdit(ctx, sales, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
- throw e;
+ error = e;
}
+
+ expect(error).toEqual(
+ new Error('It is not possible to modify sales that their articles are from Floramondo'));
});
it('should return true if any of the sales is of isFloramondo and has the correct role', async() => {
diff --git a/modules/ticket/back/methods/sale/updateConcept.js b/modules/ticket/back/methods/sale/updateConcept.js
index 0730f85e2..dcd25dcbb 100644
--- a/modules/ticket/back/methods/sale/updateConcept.js
+++ b/modules/ticket/back/methods/sale/updateConcept.js
@@ -40,10 +40,7 @@ module.exports = Self => {
try {
const currentLine = await models.Sale.findById(id, null, myOptions);
- const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
-
- if (!canEditSale)
- throw new UserError(`Sale(s) blocked, please contact production`);
+ await models.Sale.canEdit(ctx, [id], myOptions);
const line = await currentLine.updateAttributes({concept: newConcept}, myOptions);
diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js
index 8f27e1af5..505de5180 100644
--- a/modules/ticket/back/methods/sale/updatePrice.js
+++ b/modules/ticket/back/methods/sale/updatePrice.js
@@ -66,9 +66,7 @@ module.exports = Self => {
const sale = await models.Sale.findById(id, filter, myOptions);
- const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
- if (!canEditSale)
- throw new UserError(`Sale(s) blocked, please contact production`);
+ await models.Sale.canEdit(ctx, [id], myOptions);
const oldPrice = sale.price;
const userId = ctx.req.accessToken.userId;
diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js
index 8cf0720ce..d2927c65c 100644
--- a/modules/ticket/back/methods/sale/updateQuantity.js
+++ b/modules/ticket/back/methods/sale/updateQuantity.js
@@ -41,9 +41,7 @@ module.exports = Self => {
}
try {
- const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
- if (!canEditSale)
- throw new UserError(`Sale(s) blocked, please contact production`);
+ await models.Sale.canEdit(ctx, [id], myOptions);
const filter = {
include: {
diff --git a/modules/ticket/back/methods/state/editableStates.js b/modules/ticket/back/methods/state/editableStates.js
index 2c90ac43b..115876f26 100644
--- a/modules/ticket/back/methods/state/editableStates.js
+++ b/modules/ticket/back/methods/state/editableStates.js
@@ -24,7 +24,7 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
- let statesList = await models.State.find({where: filter.where}, myOptions);
+ let statesList = await models.State.find(filter, myOptions);
const isProduction = await models.Account.hasRole(userId, 'production', myOptions);
const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson', myOptions);
const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions);
diff --git a/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js b/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js
index 746e1b7fc..175bc4e4b 100644
--- a/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js
+++ b/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js
@@ -9,7 +9,7 @@ describe('ticket changeState()', () => {
accessToken: {userId: 9},
};
const ctx = {req: activeCtx};
- const now = new Date();
+ const now = Date.vnNew();
const sampleTicket = {
shipped: now,
landed: now,
diff --git a/modules/ticket/back/methods/ticket/canBeInvoiced.js b/modules/ticket/back/methods/ticket/canBeInvoiced.js
index a009d63cf..6b8f9e71a 100644
--- a/modules/ticket/back/methods/ticket/canBeInvoiced.js
+++ b/modules/ticket/back/methods/ticket/canBeInvoiced.js
@@ -43,7 +43,7 @@ module.exports = function(Self) {
ticketBases => ticketBases.hasSomeNegativeBase
);
- const today = new Date();
+ const today = Date.vnNew();
const invalidTickets = tickets.some(ticket => {
const shipped = new Date(ticket.shipped);
diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js
index 327278c2b..3726d85b7 100644
--- a/modules/ticket/back/methods/ticket/closeAll.js
+++ b/modules/ticket/back/methods/ticket/closeAll.js
@@ -17,14 +17,14 @@ module.exports = Self => {
});
Self.closeAll = async() => {
- const toDate = new Date();
+ const toDate = Date.vnNew();
toDate.setHours(0, 0, 0, 0);
toDate.setDate(toDate.getDate() - 1);
- const todayMinDate = new Date();
+ const todayMinDate = Date.vnNew();
todayMinDate.setHours(0, 0, 0, 0);
- const todayMaxDate = new Date();
+ const todayMaxDate = Date.vnNew();
todayMaxDate.setHours(23, 59, 59, 59);
// Prevent closure for current day
@@ -32,7 +32,7 @@ module.exports = Self => {
throw new UserError('You cannot close tickets for today');
const tickets = await Self.rawSql(`
- SELECT
+ SELECT
t.id,
t.clientFk,
t.companyFk,
@@ -53,7 +53,7 @@ module.exports = Self => {
JOIN country co ON co.id = p.countryFk
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered')
- AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY)
+ AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY)
AND util.dayEnd(?)
AND t.refFk IS NULL
GROUP BY t.id
diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js
index a2add2e82..262b3fd74 100644
--- a/modules/ticket/back/methods/ticket/filter.js
+++ b/modules/ticket/back/methods/ticket/filter.js
@@ -137,7 +137,7 @@ module.exports = Self => {
Self.filter = async(ctx, filter, options) => {
const userId = ctx.req.accessToken.userId;
const conn = Self.dataSource.connector;
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const models = Self.app.models;
const args = ctx.args;
@@ -295,10 +295,10 @@ module.exports = Self => {
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
stmt = new ParameterizedSQL(`
- CREATE TEMPORARY TABLE tmp.sale_getProblems
+ CREATE TEMPORARY TABLE tmp.sale_getProblems
(INDEX (ticketFk))
ENGINE = MEMORY
- SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
+ SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
FROM tmp.filter f
LEFT JOIN alertLevel al ON al.id = f.alertLevel
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
@@ -350,7 +350,7 @@ module.exports = Self => {
const ticketsIndex = stmts.push(stmt) - 1;
stmts.push(
- `DROP TEMPORARY TABLE
+ `DROP TEMPORARY TABLE
tmp.filter,
tmp.ticket_problems`);
diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js
index 19571bb51..1e1646cba 100644
--- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js
+++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js
@@ -50,14 +50,14 @@ module.exports = Self => {
required: false
},
{
- arg: 'state',
- type: 'string',
+ arg: 'isNotValidated',
+ type: 'boolean',
description: 'Origin state',
required: false
},
{
- arg: 'futureState',
- type: 'string',
+ arg: 'futureIsNotValidated',
+ type: 'boolean',
description: 'Destination state',
required: false
},
@@ -92,13 +92,23 @@ module.exports = Self => {
case 'futureId':
return {'f.futureId': value};
case 'ipt':
- return {'f.ipt': value};
+ return {or:
+ [
+ {'f.ipt': {like: `%${value}%`}},
+ {'f.ipt': null}
+ ]
+ };
case 'futureIpt':
- return {'f.futureIpt': value};
- case 'state':
- return {'f.stateCode': {like: `%${value}%`}};
- case 'futureState':
- return {'f.futureStateCode': {like: `%${value}%`}};
+ return {or:
+ [
+ {'f.futureIpt': {like: `%${value}%`}},
+ {'f.futureIpt': null}
+ ]
+ };
+ case 'isNotValidated':
+ return {'f.isNotValidated': value};
+ case 'futureIsNotValidated':
+ return {'f.futureIsNotValidated': value};
}
});
diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js
index 4e9c22a24..9739f5985 100644
--- a/modules/ticket/back/methods/ticket/makeInvoice.js
+++ b/modules/ticket/back/methods/ticket/makeInvoice.js
@@ -26,7 +26,7 @@ module.exports = function(Self) {
Self.makeInvoice = async(ctx, ticketsIds, options) => {
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
- const date = new Date();
+ const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
const myOptions = {};
diff --git a/modules/ticket/back/methods/ticket/restore.js b/modules/ticket/back/methods/ticket/restore.js
index c9bb126fd..722c3294e 100644
--- a/modules/ticket/back/methods/ticket/restore.js
+++ b/modules/ticket/back/methods/ticket/restore.js
@@ -38,7 +38,7 @@ module.exports = Self => {
}]
}, myOptions);
- const now = new Date();
+ const now = Date.vnNew();
const maxDate = new Date(ticket.updated);
maxDate.setHours(maxDate.getHours() + 1);
@@ -56,7 +56,7 @@ module.exports = Self => {
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
}
- const fullYear = new Date().getFullYear();
+ const fullYear = Date.vnNew().getFullYear();
const newShipped = ticket.shipped;
const newLanded = ticket.landed;
newShipped.setFullYear(fullYear);
diff --git a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js
index 8b7e1685d..806f80227 100644
--- a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js
@@ -61,7 +61,7 @@ describe('ticket canBeInvoiced()', () => {
const ticket = await models.Ticket.findById(ticketId, null, options);
- const shipped = new Date();
+ const shipped = Date.vnNew();
shipped.setDate(shipped.getDate() + 1);
await ticket.updateAttribute('shipped', shipped, options);
diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js
index 3a9c2db50..d65c87654 100644
--- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js
@@ -4,8 +4,8 @@ const LoopBackContext = require('loopback-context');
describe('ticket componentUpdate()', () => {
const userID = 1101;
const ticketID = 11;
- const today = new Date();
- const tomorrow = new Date();
+ const today = Date.vnNew();
+ const tomorrow = Date.vnNew();
tomorrow.setDate(tomorrow.getDate() + 1);
@@ -19,11 +19,11 @@ describe('ticket componentUpdate()', () => {
beforeAll(async() => {
const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}});
deliveryComponentId = deliveryComponenet.id;
- componentOfSaleSeven = `SELECT value
- FROM vn.saleComponent
+ componentOfSaleSeven = `SELECT value
+ FROM vn.saleComponent
WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`;
- componentOfSaleEight = `SELECT value
- FROM vn.saleComponent
+ componentOfSaleEight = `SELECT value
+ FROM vn.saleComponent
WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`;
[componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven);
firstvalueBeforeChange = componentValue.value;
diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js
index 688b0de61..6cc1a3ad2 100644
--- a/modules/ticket/back/methods/ticket/specs/filter.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js
@@ -26,9 +26,9 @@ describe('ticket filter()', () => {
try {
const options = {transaction: tx};
- const yesterday = new Date();
+ const yesterday = Date.vnNew();
yesterday.setHours(0, 0, 0, 0);
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: {
@@ -54,10 +54,10 @@ describe('ticket filter()', () => {
try {
const options = {transaction: tx};
- const yesterday = new Date();
+ const yesterday = Date.vnNew();
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: {
diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js
index aab053127..11571bede 100644
--- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js
@@ -1,9 +1,9 @@
const models = require('vn-loopback/server/server').models;
describe('TicketFuture getTicketsAdvance()', () => {
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
- let tomorrow = new Date();
+ let tomorrow = Date.vnNew();
tomorrow.setDate(today.getDate() + 1);
it('should return the tickets passing the required data', async() => {
@@ -29,7 +29,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
}
});
- it('should return the tickets matching the origin grouped state', async() => {
+ it('should return the tickets matching the origin pending state', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
@@ -39,7 +39,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
dateFuture: tomorrow,
dateToAdvance: today,
warehouseFk: 1,
- state: 'OK'
+ futureIsNotValidated: true
};
const ctx = {req: {accessToken: {userId: 9}}, args};
@@ -54,7 +54,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
}
});
- it('should return the tickets matching the destination grouped state', async() => {
+ it('should return the tickets matching the destination pending state', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
@@ -64,13 +64,13 @@ describe('TicketFuture getTicketsAdvance()', () => {
dateFuture: tomorrow,
dateToAdvance: today,
warehouseFk: 1,
- futureState: 'FREE'
+ isNotValidated: true
};
const ctx = {req: {accessToken: {userId: 9}}, args};
const result = await models.Ticket.getTicketsAdvance(ctx, options);
- expect(result.length).toBeGreaterThan(0);
+ expect(result.length).toEqual(0);
await tx.rollback();
} catch (e) {
@@ -89,7 +89,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
dateFuture: tomorrow,
dateToAdvance: today,
warehouseFk: 1,
- ipt: 'Vertical'
+ ipt: 'V'
};
const ctx = {req: {accessToken: {userId: 9}}, args};
@@ -114,7 +114,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
dateFuture: tomorrow,
dateToAdvance: today,
warehouseFk: 1,
- tfIpt: 'Vertical'
+ tfIpt: 'V'
};
const ctx = {req: {accessToken: {userId: 9}}, args};
diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js
index 51639e304..44896493f 100644
--- a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js
@@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
describe('ticket getTicketsFuture()', () => {
- const today = new Date();
+ const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
it('should return the tickets passing the required data', async() => {
diff --git a/modules/ticket/back/methods/ticket/specs/merge.spec.js b/modules/ticket/back/methods/ticket/specs/merge.spec.js
index 275484f67..6b533e47c 100644
--- a/modules/ticket/back/methods/ticket/specs/merge.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/merge.spec.js
@@ -5,8 +5,8 @@ describe('ticket merge()', () => {
const tickets = [{
originId: 13,
destinationId: 12,
- originShipped: new Date(),
- destinationShipped: new Date(),
+ originShipped: Date.vnNew(),
+ destinationShipped: Date.vnNew(),
workerFk: 1
}];
diff --git a/modules/ticket/back/methods/ticket/specs/new.spec.js b/modules/ticket/back/methods/ticket/specs/new.spec.js
index fce7cdceb..0a2f93bc4 100644
--- a/modules/ticket/back/methods/ticket/specs/new.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/new.spec.js
@@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models;
let UserError = require('vn-loopback/util/user-error');
describe('ticket new()', () => {
- const today = new Date();
+ const today = Date.vnNew();
const ctx = {req: {accessToken: {userId: 1}}};
it('should throw an error if the client isnt frozen and isnt active', async() => {
diff --git a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js
index 5470382f9..1db1b6eaa 100644
--- a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js
@@ -8,7 +8,7 @@ describe('sale priceDifference()', () => {
try {
const options = {transaction: tx};
- const tomorrow = new Date();
+ const tomorrow = Date.vnNew();
tomorrow.setDate(tomorrow.getDate() + 1);
const ctx = {req: {accessToken: {userId: 1106}}};
@@ -45,8 +45,8 @@ describe('sale priceDifference()', () => {
const ctx = {req: {accessToken: {userId: 1106}}};
ctx.args = {
id: 1,
- landed: new Date(),
- shipped: new Date(),
+ landed: Date.vnNew(),
+ shipped: Date.vnNew(),
addressId: 121,
zoneId: 3,
warehouseId: 1
@@ -68,7 +68,7 @@ describe('sale priceDifference()', () => {
try {
const options = {transaction: tx};
- const tomorrow = new Date();
+ const tomorrow = Date.vnNew();
tomorrow.setDate(tomorrow.getDate() + 1);
const ctx = {req: {accessToken: {userId: 1106}}};
diff --git a/modules/ticket/back/methods/ticket/specs/restore.spec.js b/modules/ticket/back/methods/ticket/specs/restore.spec.js
index bd976d124..3b35ae2b4 100644
--- a/modules/ticket/back/methods/ticket/specs/restore.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/restore.spec.js
@@ -24,8 +24,8 @@ describe('ticket restore()', () => {
let error;
const tx = await app.models.Ticket.beginTransaction({});
- const now = new Date();
- now.setHours(now.getHours() - 1);
+ const now = Date.vnNew();
+ now.setHours(now.getHours() - 1.1);
try {
const options = {transaction: tx};
@@ -46,7 +46,7 @@ describe('ticket restore()', () => {
it('should restore the ticket making its state no longer deleted', async() => {
const tx = await app.models.Ticket.beginTransaction({});
- const now = new Date();
+ const now = Date.vnNew();
try {
const options = {transaction: tx};
diff --git a/modules/ticket/front/advance-search-panel/index.html b/modules/ticket/front/advance-search-panel/index.html
index e8d5dc60d..dfe1f6b08 100644
--- a/modules/ticket/front/advance-search-panel/index.html
+++ b/modules/ticket/front/advance-search-panel/index.html
@@ -39,26 +39,18 @@
-
-
- {{name}}
-
-
-
-
- {{name}}
-
-
+
+
+
+
{
- for (let state of res.data) {
- groupedStates.push({
- id: state.id,
- code: state.code,
- name: this.$t(state.code)
- });
- }
- this.groupedStates = groupedStates;
- });
- }
-
getItemPackingTypes() {
let itemPackingTypes = [];
const filter = {
diff --git a/modules/ticket/front/advance-search-panel/locale/es.yml b/modules/ticket/front/advance-search-panel/locale/es.yml
index 3dce7dae5..4ea2fc737 100644
--- a/modules/ticket/front/advance-search-panel/locale/es.yml
+++ b/modules/ticket/front/advance-search-panel/locale/es.yml
@@ -1 +1,3 @@
Advance tickets: Adelantar tickets
+Pending Origin: Pendiente origen
+Pending Destination: Pendiente destino
diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html
index f63c0fbf7..3dd52b909 100644
--- a/modules/ticket/front/advance/index.html
+++ b/modules/ticket/front/advance/index.html
@@ -32,8 +32,8 @@
|
- Origin |
- Destination |
+ Origin |
+ Destination |
@@ -43,19 +43,30 @@
check-field="checked">
|
+
+ |
ID
|
Date
|
-
+ |
IPT
|
State
|
-
+ |
+ Liters
+ |
+
+ Stock
+ |
+
+ Lines
+ |
+
Import
|
@@ -64,7 +75,7 @@
|
Date
|
-
+ |
IPT
|
@@ -73,13 +84,10 @@
|
Liters
|
-
- Stock
- |
Lines
|
-
+ |
Import
|
@@ -92,6 +100,13 @@
vn-click-stop>
+
+
+
+ |
|
+ {{::ticket.futureLiters | dashIfEmpty}} |
+ {{::ticket.hasStock | dashIfEmpty}} |
+ {{::ticket.futureLines | dashIfEmpty}} |
{{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}}
@@ -136,7 +154,6 @@
|
{{::ticket.liters | dashIfEmpty}} |
- {{::ticket.hasStock | dashIfEmpty}} |
{{::ticket.lines | dashIfEmpty}} |
diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js
index b770440f1..779ada81a 100644
--- a/modules/ticket/front/advance/index.js
+++ b/modules/ticket/front/advance/index.js
@@ -1,5 +1,6 @@
import ngModule from '../module';
import Section from 'salix/components/section';
+import './style.scss';
export default class Controller extends Section {
constructor($element, $) {
@@ -62,7 +63,7 @@ export default class Controller extends Section {
}
setDefaultFilter() {
- let today = new Date();
+ let today = Date.vnNew();
const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
this.filterParams = {
@@ -74,7 +75,7 @@ export default class Controller extends Section {
}
compareDate(date) {
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let timeTicket = new Date(date);
timeTicket.setHours(0, 0, 0, 0);
@@ -128,6 +129,11 @@ export default class Controller extends Section {
});
}
+ agencies(futureAgency, agency) {
+ return this.$t(`Origin agency`, {agency: futureAgency}) +
+ ' ' + this.$t(`Destination agency`, {agency: agency});
+ }
+
moveTicketsAdvance() {
let ticketsToMove = [];
this.checked.forEach(ticket => {
@@ -157,6 +163,10 @@ export default class Controller extends Section {
return {'liters': value};
case 'lines':
return {'lines': value};
+ case 'futureLiters':
+ return {'futureLiters': value};
+ case 'futureLines':
+ return {'futureLines': value};
case 'ipt':
return {'ipt': value};
case 'futureIpt':
diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js
index c5a04daee..6874f914b 100644
--- a/modules/ticket/front/advance/index.spec.js
+++ b/modules/ticket/front/advance/index.spec.js
@@ -26,14 +26,14 @@ describe('Component vnTicketAdvance', () => {
describe('compareDate()', () => {
it('should return warning when the date is the present', () => {
- let today = new Date();
+ 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 = new Date();
+ let futureDate = Date.vnNew();
futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate);
@@ -41,7 +41,7 @@ describe('Component vnTicketAdvance', () => {
});
it('should return undefined when the date is in the past', () => {
- let pastDate = new Date();
+ let pastDate = Date.vnNew();
pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate);
@@ -81,7 +81,7 @@ describe('Component vnTicketAdvance', () => {
describe('dateRange()', () => {
it('should return two dates with the hours at the start and end of the given date', () => {
- const now = new Date();
+ const now = Date.vnNew();
const today = now.getDate();
diff --git a/modules/ticket/front/advance/locale/es.yml b/modules/ticket/front/advance/locale/es.yml
index b444fbdd3..da22cd433 100644
--- a/modules/ticket/front/advance/locale/es.yml
+++ b/modules/ticket/front/advance/locale/es.yml
@@ -4,3 +4,6 @@ Advance confirmation: ¿Desea adelantar {{checked}} tickets?
Success: Tickets movidos correctamente
Lines: Líneas
Liters: Litros
+Item Packing Type: Encajado
+Origin agency: "Agencia origen: {{agency}}"
+Destination agency: "Agencia destino: {{agency}}"
diff --git a/modules/ticket/front/advance/style.scss b/modules/ticket/front/advance/style.scss
new file mode 100644
index 000000000..8fa9de438
--- /dev/null
+++ b/modules/ticket/front/advance/style.scss
@@ -0,0 +1,7 @@
+@import "variables";
+
+vn-ticket-advance{
+ vn-icon {
+ color: #f7931e
+ }
+}
diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js
index f532265e2..99782de44 100644
--- a/modules/ticket/front/basic-data/step-one/index.js
+++ b/modules/ticket/front/basic-data/step-one/index.js
@@ -75,8 +75,10 @@ class Controller extends Component {
}
set shipped(value) {
+ if (new Date(this.ticket.shipped).toDateString() != value.toDateString())
+ value.setHours(0, 0, 0, 0);
+
this.ticket.shipped = value;
- this.ticket.shipped.setHours(0, 0, 0, 0);
this.getLanded({
shipped: value,
addressFk: this.ticket.addressFk,
diff --git a/modules/ticket/front/basic-data/step-one/index.spec.js b/modules/ticket/front/basic-data/step-one/index.spec.js
index 2b14c18cc..30946dab0 100644
--- a/modules/ticket/front/basic-data/step-one/index.spec.js
+++ b/modules/ticket/front/basic-data/step-one/index.spec.js
@@ -67,7 +67,7 @@ describe('Ticket', () => {
jest.spyOn(controller, 'getShipped');
controller.ticket.addressFk = 99;
controller.addressId = 100;
- const landed = new Date();
+ const landed = Date.vnNew();
const expectedResult = {
landed: landed,
addressFk: 100,
@@ -101,7 +101,7 @@ describe('Ticket', () => {
describe('shipped() getter', () => {
it('should return the shipped property', () => {
- const shipped = new Date();
+ const shipped = Date.vnNew();
controller.ticket.shipped = shipped;
expect(controller.shipped).toEqual(shipped);
@@ -111,7 +111,7 @@ describe('Ticket', () => {
describe('shipped() setter', () => {
it('should set shipped property and call getLanded() method ', () => {
jest.spyOn(controller, 'getLanded');
- const shipped = new Date();
+ const shipped = Date.vnNew();
const expectedResult = {
shipped: shipped,
addressFk: 121,
@@ -126,7 +126,7 @@ describe('Ticket', () => {
describe('landed() getter', () => {
it('should return the landed property', () => {
- const landed = new Date();
+ const landed = Date.vnNew();
controller.ticket.landed = landed;
expect(controller.landed).toEqual(landed);
@@ -136,7 +136,7 @@ describe('Ticket', () => {
describe('landed() setter', () => {
it('should set shipped property and call getShipped() method ', () => {
jest.spyOn(controller, 'getShipped');
- const landed = new Date();
+ const landed = Date.vnNew();
const expectedResult = {
landed: landed,
addressFk: 121,
@@ -161,7 +161,7 @@ describe('Ticket', () => {
it('should set agencyModeId property and call getLanded() method', () => {
jest.spyOn(controller, 'getLanded');
controller.$.agencyMode = {selection: {warehouseFk: 1}};
- const shipped = new Date();
+ const shipped = Date.vnNew();
const agencyModeId = 8;
const expectedResult = {
shipped: shipped,
@@ -177,7 +177,7 @@ describe('Ticket', () => {
it('should do nothing if attempting to set the same agencyMode id', () => {
jest.spyOn(controller, 'getShipped');
- const landed = new Date();
+ const landed = Date.vnNew();
const agencyModeId = 7;
const expectedResult = {
landed: landed,
@@ -278,8 +278,8 @@ describe('Ticket', () => {
agencyModeFk: 1,
companyFk: 442,
warehouseFk: 1,
- shipped: new Date(),
- landed: new Date()
+ shipped: Date.vnNew(),
+ landed: Date.vnNew()
};
expect(controller.isFormInvalid()).toBeFalsy();
@@ -288,7 +288,7 @@ describe('Ticket', () => {
describe('onStepChange()', () => {
it('should call onStepChange method and return a NO_AGENCY_AVAILABLE signal error', async() => {
- let landed = new Date();
+ let landed = Date.vnNew();
landed.setHours(0, 0, 0, 0);
controller._ticket = {
@@ -299,7 +299,7 @@ describe('Ticket', () => {
agencyModeFk: 1,
companyFk: 442,
warehouseFk: 1,
- shipped: new Date(),
+ shipped: Date.vnNew(),
landed: landed
};
@@ -314,8 +314,8 @@ describe('Ticket', () => {
describe('getLanded()', () => {
it('should return an available landed date', async() => {
- const shipped = new Date();
- const expectedResult = {landed: new Date()};
+ const shipped = Date.vnNew();
+ const expectedResult = {landed: Date.vnNew()};
const params = {
shipped: shipped,
addressFk: 121,
@@ -336,8 +336,8 @@ describe('Ticket', () => {
describe('getShipped()', () => {
it('should return an available shipped date', async() => {
- const landed = new Date();
- const expectedResult = {shipped: new Date()};
+ const landed = Date.vnNew();
+ const expectedResult = {shipped: Date.vnNew()};
const params = {
landed: landed,
addressFk: 121,
@@ -358,7 +358,7 @@ describe('Ticket', () => {
describe('zoneWhere() getter', () => {
it('should return an object containing filter properties', async() => {
- const shipped = new Date();
+ const shipped = Date.vnNew();
controller.ticket.shipped = shipped;
const expectedResult = {
diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js
index f6001c6b8..ff029db78 100644
--- a/modules/ticket/front/descriptor-menu/index.js
+++ b/modules/ticket/front/descriptor-menu/index.js
@@ -177,7 +177,7 @@ class Controller extends Section {
get canRestoreTicket() {
const isDeleted = this.ticket.isDeleted;
- const now = new Date();
+ const now = Date.vnNew();
const maxDate = new Date(this.ticket.updated);
maxDate.setHours(maxDate.getHours() + 1);
diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js
index 67dc0affa..babc22038 100644
--- a/modules/ticket/front/descriptor-menu/index.spec.js
+++ b/modules/ticket/front/descriptor-menu/index.spec.js
@@ -43,7 +43,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
describe('canRestoreTicket() getter', () => {
it('should return true for a ticket deleted within the last hour', () => {
controller.ticket.isDeleted = true;
- controller.ticket.updated = new Date();
+ controller.ticket.updated = Date.vnNew();
const result = controller.canRestoreTicket;
@@ -51,7 +51,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
});
it('should return false for a ticket deleted more than one hour ago', () => {
- const pastHour = new Date();
+ const pastHour = Date.vnNew();
pastHour.setHours(pastHour.getHours() - 2);
controller.ticket.isDeleted = true;
diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js
index 7ffe2fe5e..2d4432fe8 100644
--- a/modules/ticket/front/expedition/index.js
+++ b/modules/ticket/front/expedition/index.js
@@ -4,7 +4,7 @@ import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $scope) {
super($element, $scope);
- this.landed = new Date();
+ this.landed = Date.vnNew();
this.newRoute = null;
}
diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js
index 5a538b1c8..71e32151c 100644
--- a/modules/ticket/front/expedition/index.spec.js
+++ b/modules/ticket/front/expedition/index.spec.js
@@ -76,7 +76,7 @@ describe('Ticket', () => {
it('should make a query and then call to the $state go() method', () => {
jest.spyOn(controller.$state, 'go').mockReturnThis();
- const landed = new Date();
+ const landed = Date.vnNew();
const ticket = {
clientFk: 1101,
landed: landed,
diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js
index 5fb2c8f82..81ef08825 100644
--- a/modules/ticket/front/future/index.js
+++ b/modules/ticket/front/future/index.js
@@ -57,7 +57,7 @@ export default class Controller extends Section {
}
setDefaultFilter() {
- const today = new Date();
+ const today = Date.vnNew();
this.filterParams = {
originDated: today,
@@ -68,7 +68,7 @@ export default class Controller extends Section {
}
compareDate(date) {
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let timeTicket = new Date(date);
timeTicket.setHours(0, 0, 0, 0);
diff --git a/modules/ticket/front/future/index.spec.js b/modules/ticket/front/future/index.spec.js
index c609a4891..188421298 100644
--- a/modules/ticket/front/future/index.spec.js
+++ b/modules/ticket/front/future/index.spec.js
@@ -2,7 +2,7 @@ import './index.js';
import crudModel from 'core/mocks/crud-model';
describe('Component vnTicketFuture', () => {
- const today = new Date();
+ const today = Date.vnNew();
let controller;
let $httpBackend;
@@ -32,7 +32,7 @@ describe('Component vnTicketFuture', () => {
});
it('should return sucess when the date is in the future', () => {
- let futureDate = new Date();
+ let futureDate = Date.vnNew();
futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate);
@@ -40,7 +40,7 @@ describe('Component vnTicketFuture', () => {
});
it('should return undefined when the date is in the past', () => {
- let pastDate = new Date();
+ let pastDate = Date.vnNew();
pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate);
diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js
index 3039a2a03..42332ccc8 100644
--- a/modules/ticket/front/index/index.js
+++ b/modules/ticket/front/index/index.js
@@ -90,7 +90,7 @@ export default class Controller extends Section {
}
compareDate(date) {
- let today = new Date();
+ let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let timeTicket = new Date(date);
timeTicket.setHours(0, 0, 0, 0);
diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js
index 03071654e..5046387b0 100644
--- a/modules/ticket/front/index/index.spec.js
+++ b/modules/ticket/front/index/index.spec.js
@@ -31,14 +31,14 @@ describe('Component vnTicketIndex', () => {
describe('compareDate()', () => {
it('should return warning when the date is the present', () => {
- let today = new Date();
+ 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 = new Date();
+ let futureDate = Date.vnNew();
futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate);
@@ -46,7 +46,7 @@ describe('Component vnTicketIndex', () => {
});
it('should return undefined when the date is in the past', () => {
- let pastDate = new Date();
+ let pastDate = Date.vnNew();
pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate);
diff --git a/modules/ticket/front/main/index.js b/modules/ticket/front/main/index.js
index 1b807216b..3f9482fc4 100644
--- a/modules/ticket/front/main/index.js
+++ b/modules/ticket/front/main/index.js
@@ -22,7 +22,7 @@ export default class Ticket extends ModuleMain {
$params.scopeDays = 1;
if (typeof $params.scopeDays === 'number') {
- const from = new Date();
+ const from = Date.vnNew();
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
diff --git a/modules/ticket/front/package/index.js b/modules/ticket/front/package/index.js
index ed13f12d8..fd67ce583 100644
--- a/modules/ticket/front/package/index.js
+++ b/modules/ticket/front/package/index.js
@@ -6,7 +6,7 @@ class Controller extends Section {
this.$.model.insert({
packagingFk: null,
quantity: null,
- created: new Date(),
+ created: Date.vnNew(),
ticketFk: this.$params.id
});
}
diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html
index 97f6a2a81..fe259cf87 100644
--- a/modules/ticket/front/sale/index.html
+++ b/modules/ticket/front/sale/index.html
@@ -22,6 +22,7 @@
disabled="!$ctrl.isEditable"
label="State"
value-field="code"
+ fields="['id', 'name', 'alertLevel', 'code']"
url="States/editableStates"
on-change="$ctrl.changeState(value)">
diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js
index 618d4727d..f3fb89d04 100644
--- a/modules/ticket/front/sale/index.js
+++ b/modules/ticket/front/sale/index.js
@@ -51,7 +51,7 @@ class Controller extends Section {
const hasClaimManagerRole = this.aclService.hasAny(['claimManager']);
- return landedPlusWeek >= new Date() || hasClaimManagerRole;
+ return landedPlusWeek >= Date.vnNew() || hasClaimManagerRole;
}
return false;
}
diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js
index fbee966fd..8585503cc 100644
--- a/modules/ticket/front/sale/index.spec.js
+++ b/modules/ticket/front/sale/index.spec.js
@@ -15,9 +15,9 @@ describe('Ticket', () => {
const ticket = {
id: 1,
clientFk: 1101,
- shipped: new Date(),
- landed: new Date(),
- created: new Date(),
+ shipped: Date.vnNew(),
+ landed: Date.vnNew(),
+ created: Date.vnNew(),
client: {salesPersonFk: 1},
address: {mobile: 111111111}
};
diff --git a/modules/ticket/front/search-panel/index.spec.js b/modules/ticket/front/search-panel/index.spec.js
index 41c32c047..df320b55b 100644
--- a/modules/ticket/front/search-panel/index.spec.js
+++ b/modules/ticket/front/search-panel/index.spec.js
@@ -38,7 +38,7 @@ describe('Ticket Component vnTicketSearchPanel', () => {
it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1;
- controller.from = new Date();
+ controller.from = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
@@ -49,7 +49,7 @@ describe('Ticket Component vnTicketSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
- controller.to = new Date();
+ controller.to = Date.vnNew();
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
@@ -58,8 +58,8 @@ describe('Ticket Component vnTicketSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
- controller.filter.from = new Date();
- controller.filter.to = new Date();
+ controller.filter.from = Date.vnNew();
+ controller.filter.to = Date.vnNew();
controller.scopeDays = 1;
diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html
index fe49a301f..af44ed67c 100644
--- a/modules/ticket/front/summary/index.html
+++ b/modules/ticket/front/summary/index.html
@@ -1,6 +1,6 @@
-
- Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}}
+ Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}}
({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}}
-
-
-
-
{{$ctrl.summary.client.salesPersonUser.name}}
-
@@ -47,11 +48,11 @@
{{$ctrl.summary.zone.name}}
-
-
{{$ctrl.summary.routeFk}}
@@ -66,17 +67,17 @@
-
-
-
| | |