@@ -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/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/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/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/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/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..94f6db09c 100644
--- a/modules/route/front/index/index.js
+++ b/modules/route/front/index/index.js
@@ -34,12 +34,22 @@ 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() {
diff --git a/modules/route/front/index/index.spec.js b/modules/route/front/index/index.spec.js
index 05dd56433..c1f414d5e 100644
--- a/modules/route/front/index/index.spec.js
+++ b/modules/route/front/index/index.spec.js
@@ -44,17 +44,15 @@ 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();
});
});
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/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/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/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/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/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js
index aab053127..7d3bc174d 100644
--- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js
@@ -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/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..a29d2db97 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, $) {
@@ -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/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/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/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 @@
-
-
-
| | |