From 3ae520d2470ed481108bb5116333769cfe6347a3 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 21 Jun 2021 09:10:47 +0000 Subject: [PATCH 1/8] 2847 - Driver route now shows item packaging type --- loopback/server/datasources.json | 39 +-- modules/client/front/summary/index.js | 2 + .../reports/driver-route/driver-route.html | 293 +++++++++--------- .../reports/driver-route/driver-route.js | 2 +- .../reports/driver-route/locale/es.yml | 1 + .../reports/driver-route/sql/tickets.sql | 19 +- 6 files changed, 184 insertions(+), 172 deletions(-) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 87fff60e15..0df03882c3 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -18,20 +18,15 @@ "acquireTimeout": 20000 }, "osticket": { - "connector": "vn-mysql", - "database": "vn", - "debug": false, - "host": "localhost", - "port": "3306", - "username": "root", - "password": "root" + "connector": "memory", + "timezone": "local" }, "tempStorage": { "name": "tempStorage", "connector": "loopback-component-storage", - "provider": "filesystem", + "provider": "filesystem", "root": "./storage/tmp", - "maxFileSize": "262144000", + "maxFileSize": "262144000", "allowedContentTypes": [ "application/x-7z-compressed", "application/x-zip-compressed", @@ -41,17 +36,17 @@ "application/zip", "application/rar", "multipart/x-zip", - "image/png", - "image/jpeg", + "image/png", + "image/jpeg", "image/jpg" ] }, "dmsStorage": { "name": "dmsStorage", "connector": "loopback-component-storage", - "provider": "filesystem", + "provider": "filesystem", "root": "./storage/dms", - "maxFileSize": "262144000", + "maxFileSize": "262144000", "allowedContentTypes": [ "application/x-7z-compressed", "application/x-zip-compressed", @@ -61,32 +56,32 @@ "application/zip", "application/rar", "multipart/x-zip", - "image/png", - "image/jpeg", + "image/png", + "image/jpeg", "image/jpg" ] }, "imageStorage": { "name": "imageStorage", "connector": "loopback-component-storage", - "provider": "filesystem", + "provider": "filesystem", "root": "./storage/image", - "maxFileSize": "52428800", + "maxFileSize": "52428800", "allowedContentTypes": [ - "image/png", - "image/jpeg", + "image/png", + "image/jpeg", "image/jpg" ] }, "invoiceStorage": { "name": "invoiceStorage", "connector": "loopback-component-storage", - "provider": "filesystem", + "provider": "filesystem", "root": "./storage/pdfs/invoice", - "maxFileSize": "52428800", + "maxFileSize": "52428800", "allowedContentTypes": [ "application/octet-stream", "application/pdf" ] } -} +} \ No newline at end of file diff --git a/modules/client/front/summary/index.js b/modules/client/front/summary/index.js index 113fd2ab26..8144e9266b 100644 --- a/modules/client/front/summary/index.js +++ b/modules/client/front/summary/index.js @@ -59,6 +59,8 @@ class Controller extends Summary { stateColor(ticket) { const ticketState = ticket.ticketState; + if (!ticketState) return; + if (ticketState.code === 'OK') return 'success'; else if (ticketState.code === 'FREE') diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index bad1bf1790..1168d18e86 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -1,163 +1,166 @@ - - - - - + + +
- - - -
-
-

{{$t('route')}} {{route.id}}

-
-
{{$t('information')}}
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
{{$t('route')}}{{route.id}}{{$t('driver')}}{{route.userNickName}}
{{$t('date')}}{{route.created | date('%d-%m-%Y')}}{{$t('vehicle')}}{{route.vehicleTradeMark}} {{route.vehicleModel}}
{{$t('time')}}{{route.time | date('%H:%M')}}{{route.plateNumber}}
{{$t('volume')}}{{route.m3}}{{$t('agency')}}{{route.agencyName}}
-
- - - - - - - - - - - - - - - -
-

Hora inicio

-
-

Hora fin

-
-

Km inicio

-
-

Km fin

-
-
- -
-
-
- -
-
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - -
{{$t('order')}}{{$t('ticket')}}{{$t('client')}}{{$t('address')}}{{$t('packages')}}
{{ticket.priority}}{{ticket.id}}{{ticket.clientFk}} {{ticket.addressName}} - {{ticket.addressFk.toString().substr(0, ticket.addressFk.toString().length - 3)}} - - {{ticket.addressFk.toString().substr(-3, 3)}} - - {{ticket.packages}}
-
+ + + + + + - - -
+ + + +
+
+

{{$t('route')}} {{route.id}}

+
+
{{$t('information')}}
+
- - - - + + + + - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - +
{{$t('street')}}{{ticket.street}}{{$t('postcode')}}{{ticket.postalCode}}{{$t('route')}}{{route.id}}{{$t('driver')}}{{route.userNickName}}
{{$t('city')}}{{ticket.city}}{{$t('date')}}{{route.created | date('%d-%m-%Y')}}{{$t('vehicle')}}{{route.vehicleTradeMark}} {{route.vehicleModel}}
{{$t('time')}}{{route.time | date('%H:%M')}}{{route.plateNumber}}
{{$t('volume')}}{{route.m3}} {{$t('agency')}}{{ticket.ticketAgency}}
{{$t('mobile')}}{{ticket.mobile}}{{$t('phone')}}{{ticket.phone}}
{{$t('warehouse')}}{{ticket.warehouseName}}{{$t('salesPerson')}}{{ticket.salesPersonName}}
{{$t('import')}}{{ticket.import | currency('EUR', $i18n.locale)}}{{route.agencyName}}
-
-

{{ticket.description}}

-

{{$t('stowaway')}}: {{ticket.shipFk}}

+
+ + + + + + + + + + + + + + + +
+

Hora inicio

+
+

Hora fin

+
+

Km inicio

+
+

Km fin

+
+
+ +
+
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
{{$t('order')}}{{$t('ticket')}}{{$t('client')}}{{$t('address')}}{{$t('packages')}}{{$t('packagingType')}}
{{ticket.priority}}{{ticket.id}}{{ticket.clientFk}} {{ticket.addressName}} + {{ticket.addressFk.toString().substr(0, + ticket.addressFk.toString().length - 3)}} + + {{ticket.addressFk.toString().substr(-3, 3)}} + + {{ticket.packages}}{{ticket.itemPackingTypes}}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{$t('street')}}{{ticket.street}}{{$t('postcode')}}{{ticket.postalCode}}
{{$t('city')}}{{ticket.city}}{{$t('agency')}}{{ticket.ticketAgency}}
{{$t('mobile')}}{{ticket.mobile}}{{$t('phone')}}{{ticket.phone}}
{{$t('warehouse')}}{{ticket.warehouseName}}{{$t('salesPerson')}}{{ticket.salesPersonName}}
{{$t('import')}}{{ticket.import | currency('EUR', $i18n.locale)}}
+
+

{{ticket.description}}

+

{{$t('stowaway')}}: {{ticket.shipFk}}

+
+
+
- - - -
- +
+ + + +
+ + \ No newline at end of file diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js index 39b5d44e9f..0b26382393 100755 --- a/print/templates/reports/driver-route/driver-route.js +++ b/print/templates/reports/driver-route/driver-route.js @@ -30,7 +30,7 @@ module.exports = { return this.rawSqlFromDef('routes', [routesId]); }, fetchTickets(routesId) { - return this.rawSqlFromDef('tickets', [routesId]); + return this.rawSqlFromDef('tickets', [routesId, routesId]); } }, components: { diff --git a/print/templates/reports/driver-route/locale/es.yml b/print/templates/reports/driver-route/locale/es.yml index 7b86f527f9..4f0f3ac3c2 100644 --- a/print/templates/reports/driver-route/locale/es.yml +++ b/print/templates/reports/driver-route/locale/es.yml @@ -10,6 +10,7 @@ order: Orden client: Cliente address: Consignatario packages: Bultos +packagingType: Encajado street: Dirección postcode: Código Postal city: Ciudad diff --git a/print/templates/reports/driver-route/sql/tickets.sql b/print/templates/reports/driver-route/sql/tickets.sql index 1bdaf31a5c..8806a04739 100644 --- a/print/templates/reports/driver-route/sql/tickets.sql +++ b/print/templates/reports/driver-route/sql/tickets.sql @@ -18,8 +18,9 @@ SELECT am.name ticketAgency, tob.description, s.shipFk, - u.nickName salesPersonName -FROM route r + u.nickName salesPersonName, + ipkg.itemPackingTypes +FROM route r LEFT JOIN ticket t ON t.routeFk = r.id LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN client c ON c.id = t.clientFk @@ -30,5 +31,15 @@ FROM route r LEFT JOIN warehouse wh ON wh.id = t.warehouseFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk LEFT JOIN stowaway s ON s.id = t.id -WHERE r.id IN(?) -ORDER BY t.priority, t.id \ No newline at end of file + LEFT JOIN ( + SELECT t.id AS ticketFk, + GROUP_CONCAT(DISTINCT(i.itemPackingTypeFk)) AS itemPackingTypes + FROM route r + JOIN ticket t ON t.routeFk = r.id + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE r.id IN (?) + GROUP BY t.id + ) ipkg ON ipkg.ticketFk = t.id +WHERE r.id IN (?) +ORDER BY t.priority, t.id; \ No newline at end of file From 2469540f661c906e107ef4ad4a671a857f55eaac Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 30 Jun 2021 10:48:19 +0200 Subject: [PATCH 2/8] item category filter is now working again --- .../back/methods/invoiceOut/filter.js | 24 +++--- modules/item/back/methods/item/filter.js | 81 +++++++++++-------- .../back/methods/item/specs/filter.spec.js | 63 +++++++++++---- modules/item/front/index/index.html | 6 +- 4 files changed, 111 insertions(+), 63 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/filter.js b/modules/invoiceOut/back/methods/invoiceOut/filter.js index 5df3f76b8e..3496c92963 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/filter.js +++ b/modules/invoiceOut/back/methods/invoiceOut/filter.js @@ -10,73 +10,73 @@ module.exports = Self => { accepts: [ { arg: 'filter', - type: 'Object', + type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} }, { arg: 'search', - type: 'String', + type: 'string', description: 'Searchs the invoiceOut by id', http: {source: 'query'} }, { arg: 'clientFk', - type: 'Integer', + type: 'integer', description: 'The client id', http: {source: 'query'} }, { arg: 'fi', - type: 'String', + type: 'string', description: 'The client fiscal id', http: {source: 'query'} }, { arg: 'hasPdf', - type: 'Boolean', + type: 'boolean', description: 'Whether the the invoiceOut has PDF or not', http: {source: 'query'} }, { arg: 'amount', - type: 'Number', + type: 'number', description: 'The amount filter', http: {source: 'query'} }, { arg: 'min', - type: 'Number', + type: 'number', description: 'The minimun amount flter', http: {source: 'query'} }, { arg: 'max', - type: 'Number', + type: 'number', description: 'The maximun amount flter', http: {source: 'query'} }, { arg: 'issued', - type: 'Date', + type: 'date', description: 'The issued date filter', http: {source: 'query'} }, { arg: 'created', - type: 'Date', + type: 'date', description: 'The created date filter', http: {source: 'query'} }, { arg: 'dued', - type: 'Date', + type: 'date', description: 'The due date filter', http: {source: 'query'} } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index eba0b0f918..1c7b6cd778 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -10,48 +10,57 @@ module.exports = Self => { accepts: [ { arg: 'filter', - type: 'Object', + type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', - }, { + }, + { arg: 'tags', - type: ['Object'], + type: ['object'], description: 'List of tags to filter with', - }, { + }, + { arg: 'search', - type: 'String', + type: 'string', description: `If it's and integer searchs by id, otherwise it searchs by name`, - }, { + }, + { arg: 'id', - type: 'Integer', + type: 'integer', description: 'Item id', - }, { + }, + { arg: 'categoryFk', - type: 'Integer', + type: 'integer', description: 'Category id', - }, { + }, + { arg: 'typeFk', - type: 'Integer', + type: 'integer', description: 'Type id', - }, { + }, + { arg: 'isActive', - type: 'Boolean', + type: 'boolean', description: 'Whether the the item is or not active', - }, { + }, + { arg: 'salesPersonFk', - type: 'Integer', + type: 'integer', description: 'The buyer of the item', - }, { + }, + { arg: 'description', - type: 'String', + type: 'string', description: 'The item description', - }, { + }, + { arg: 'stemMultiplier', - type: 'Integer', + type: 'integer', description: 'The item multiplier', } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -60,23 +69,28 @@ module.exports = Self => { } }); - Self.filter = async(ctx, filter) => { - let conn = Self.dataSource.connector; + Self.filter = async(ctx, filter, options) => { + const conn = Self.dataSource.connector; + let myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + let codeWhere; if (ctx.args.search) { - let items = await Self.app.models.ItemBarcode.find({ + const items = await Self.app.models.ItemBarcode.find({ where: {code: ctx.args.search}, fields: ['itemFk'] - }); - let itemIds = []; + }, myOptions); + const itemIds = []; for (const item of items) itemIds.push(item.itemFk); codeWhere = {'i.id': {inq: itemIds}}; } - let where = buildFilter(ctx.args, (param, value) => { + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) @@ -90,8 +104,8 @@ module.exports = Self => { return {'i.stemMultiplier': value}; case 'typeFk': return {'i.typeFk': value}; - case 'category': - return {'ic.name': value}; + case 'categoryFk': + return {'ic.id': value}; case 'salesPersonFk': return {'it.workerFk': value}; case 'origin': @@ -104,7 +118,7 @@ module.exports = Self => { }); filter = mergeFilters(filter, {where}); - let stmts = []; + const stmts = []; let stmt; stmt = new ParameterizedSQL( @@ -130,7 +144,7 @@ module.exports = Self => { it.workerFk AS buyerFk, u.name AS userName, ori.code AS origin, - ic.name AS category, + ic.name AS categoryFk, intr.description AS intrastat, b.grouping, b.packing, @@ -173,9 +187,10 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makePagination(filter)); - let itemsIndex = stmts.push(stmt) - 1; - let sql = ParameterizedSQL.join(stmts, ';'); - let result = await conn.executeStmt(sql); + const itemsIndex = stmts.push(stmt) - 1; + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); + return itemsIndex === 0 ? result : result[itemsIndex]; }; }; diff --git a/modules/item/back/methods/item/specs/filter.spec.js b/modules/item/back/methods/item/specs/filter.spec.js index 72175ccc4e..340bc0db2b 100644 --- a/modules/item/back/methods/item/specs/filter.spec.js +++ b/modules/item/back/methods/item/specs/filter.spec.js @@ -2,29 +2,62 @@ const app = require('vn-loopback/server/server'); describe('item filter()', () => { it('should return 1 result filtering by id', async() => { - let filter = {}; - let result = await app.models.Item.filter({args: {filter: filter, search: 1}}); + const tx = await app.models.Item.beginTransaction({}); + const options = {transaction: tx}; - expect(result.length).toEqual(1); - expect(result[0].id).toEqual(1); + try { + const filter = {}; + const ctx = {args: {filter: filter, search: 1}}; + const result = await app.models.Item.filter(ctx, filter, options); + + expect(result.length).toEqual(1); + expect(result[0].id).toEqual(1); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should return 1 result filtering by barcode', async() => { - let filter = {}; - let result = await app.models.Item.filter({args: {filter: filter, search: 4444444444}}); + const tx = await app.models.Item.beginTransaction({}); + const options = {transaction: tx}; - expect(result.length).toEqual(1); - expect(result[0].id).toEqual(2); + try { + const filter = {}; + const ctx = {args: {filter: filter, search: 4444444444}}; + const result = await app.models.Item.filter(ctx, filter, options); + + expect(result.length).toEqual(1); + expect(result[0].id).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should return 2 results using filter and tags', async() => { - let filter = { - order: 'isActive ASC, name', - limit: 8 - }; - let tags = [{value: 'medical box', tagFk: 58}]; - let result = await app.models.Item.filter({args: {filter: filter, typeFk: 5, tags: tags}}); + const tx = await app.models.Item.beginTransaction({}); + const options = {transaction: tx}; - expect(result.length).toEqual(2); + try { + const filter = { + order: 'isActive ASC, name', + limit: 8 + }; + const tags = [{value: 'medical box', tagFk: 58}]; + const ctx = {args: {filter: filter, typeFk: 5, tags: tags}}; + const result = await app.models.Item.filter(ctx, filter, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); }); diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index bcebaee484..b119e68f5d 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -20,7 +20,7 @@ Size Niche Type - Category + Category Intrastat Origin Buyer @@ -67,8 +67,8 @@ {{::item.typeName}} - - {{::item.category}} + + {{::item.categoryFk}} {{::item.intrastat}} From c8bfc911c2a51cfcce8affb99f90438bc79459bd Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 1 Jul 2021 08:33:56 +0200 Subject: [PATCH 3/8] 2974 - Get amount unpaid from customer_risk --- modules/client/front/balance/create/index.html | 3 ++- print/templates/reports/receipt/sql/receipt.sql | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/client/front/balance/create/index.html b/modules/client/front/balance/create/index.html index 81be143829..357ae5d03d 100644 --- a/modules/client/front/balance/create/index.html +++ b/modules/client/front/balance/create/index.html @@ -60,7 +60,8 @@ + label="Delivered amount" + step="0.01"> Date: Thu, 1 Jul 2021 08:41:04 +0200 Subject: [PATCH 4/8] Reformat rollback --- print/templates/reports/driver-route/driver-route.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index 1168d18e86..eed85e1d73 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -1,6 +1,5 @@ - @@ -155,12 +154,13 @@ - +
- \ No newline at end of file From d09ab13ba1fdbda9d7ed026c1d0e51322261ab5f Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 1 Jul 2021 09:56:22 +0200 Subject: [PATCH 5/8] Replaced customer_risk with clientRisk --- print/templates/reports/receipt/sql/receipt.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/print/templates/reports/receipt/sql/receipt.sql b/print/templates/reports/receipt/sql/receipt.sql index 6b0611f39d..b8f5a41124 100644 --- a/print/templates/reports/receipt/sql/receipt.sql +++ b/print/templates/reports/receipt/sql/receipt.sql @@ -6,6 +6,6 @@ SELECT r.companyFk FROM receipt r JOIN client c ON c.id = r.clientFk - JOIN bi.customer_risk cr ON cr.customer_id = c.id - AND cr.company_id = r.companyFk + JOIN vn.clientRisk cr ON cr.clientFk = c.id + AND cr.companyFk = r.companyFk WHERE r.id = ? \ No newline at end of file From c2112f907ebb13b0a3270a9f70f63599f7d103ae Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 1 Jul 2021 09:57:17 +0200 Subject: [PATCH 6/8] Removed bi from export --- db/export-structure.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/db/export-structure.sh b/db/export-structure.sh index e2a5a618b1..c5c65ef343 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -3,7 +3,6 @@ SCHEMAS=( account bs - bi cache edi hedera From 243636ccf6445856d0726262041be60d95a7ab74 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 1 Jul 2021 12:34:30 +0200 Subject: [PATCH 7/8] item category name as category --- modules/item/back/methods/item/filter.js | 2 +- modules/item/front/index/index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 1c7b6cd778..dca808aa30 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -144,7 +144,7 @@ module.exports = Self => { it.workerFk AS buyerFk, u.name AS userName, ori.code AS origin, - ic.name AS categoryFk, + ic.name AS category, intr.description AS intrastat, b.grouping, b.packing, diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index b119e68f5d..713eba6a97 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -67,8 +67,8 @@ {{::item.typeName}} - - {{::item.categoryFk}} + + {{::item.category}} {{::item.intrastat}} From be850571d996a179efedfe1442376c42fc4ffb79 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 1 Jul 2021 13:14:36 +0200 Subject: [PATCH 8/8] updated the field name --- modules/item/front/index/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 713eba6a97..bcebaee484 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -20,7 +20,7 @@ Size Niche Type - Category + Category Intrastat Origin Buyer