From a14ba2862944e009ce342fb1dba0096aacba87f1 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 28 Mar 2019 11:55:23 +0100 Subject: [PATCH] #1263 invoiceOut.summary --- db/install/dump/fixtures.sql | 12 ++ front/module-import.js | 20 +-- modules/client/back/model-config.json | 3 - modules/client/back/models/invoice-out.js | 3 - modules/client/back/models/invoice-out.json | 58 --------- .../back/methods/invoiceOut}/download.js | 0 .../methods/invoiceOut/specs/summary.spec.js | 31 +++++ .../back/methods/invoiceOut/summary.js | 114 ++++++++++++++++++ modules/invoiceOut/back/model-config.json | 5 + modules/invoiceOut/back/models/invoiceOut.js | 4 + .../invoiceOut/back/models/invoiceOut.json | 71 +++++++++++ modules/invoiceOut/front/card/index.js | 11 +- modules/invoiceOut/front/index.js | 1 + modules/invoiceOut/front/index/index.html | 30 ++--- modules/invoiceOut/front/index/index.js | 12 +- modules/invoiceOut/front/routes.json | 17 ++- modules/invoiceOut/front/summary/index.html | 74 ++++++++++++ modules/invoiceOut/front/summary/index.js | 66 ++++++++++ .../invoiceOut/front/summary/index.spec.js | 41 +++++++ .../invoiceOut/front/summary/locale/es.yml | 15 +++ modules/invoiceOut/front/summary/style.scss | 10 ++ modules/item/back/model-config.json | 3 + modules/item/back/models/supplier.json | 78 ++++++++++++ .../ticket/back/methods/ticket/subtotal.js | 1 - modules/ticket/back/models/ticket.json | 3 +- package-lock.json | 74 +++++++++--- 26 files changed, 630 insertions(+), 127 deletions(-) delete mode 100644 modules/client/back/models/invoice-out.js delete mode 100644 modules/client/back/models/invoice-out.json rename modules/{client/back/methods/invoice-out => invoiceOut/back/methods/invoiceOut}/download.js (100%) create mode 100644 modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js create mode 100644 modules/invoiceOut/back/methods/invoiceOut/summary.js create mode 100644 modules/invoiceOut/back/model-config.json create mode 100644 modules/invoiceOut/back/models/invoiceOut.js create mode 100644 modules/invoiceOut/back/models/invoiceOut.json create mode 100644 modules/invoiceOut/front/summary/index.html create mode 100644 modules/invoiceOut/front/summary/index.js create mode 100644 modules/invoiceOut/front/summary/index.spec.js create mode 100644 modules/invoiceOut/front/summary/locale/es.yml create mode 100644 modules/invoiceOut/front/summary/style.scss create mode 100644 modules/item/back/models/supplier.json diff --git a/db/install/dump/fixtures.sql b/db/install/dump/fixtures.sql index 3293f0b57..8dae419b6 100644 --- a/db/install/dump/fixtures.sql +++ b/db/install/dump/fixtures.sql @@ -398,6 +398,18 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T3333333' WHERE id = 3; UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4; UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5; +INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`) + VALUES + (1, 100, 10, 4722000010), + (1, 200, 21, 4722000021), + (2, 100, 10, 4722000010), + (2, 200, 21, 4722000021), + (3, 100, 10, 4722000010), + (3, 200, 21, 4722000021), + (4, 100, 10, 4722000010), + (4, 200, 21, 4722000021), + (5, 100, 10, 4722000010), + (5, 200, 21, 4722000021); INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `created`) VALUES diff --git a/front/module-import.js b/front/module-import.js index fa656d221..21d468931 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -7,15 +7,15 @@ export default function moduleImport(moduleName) { //); switch(moduleName) { - case 'client' : return import('client/front'); - case 'item' : return import('item/front'); - case 'ticket' : return import('ticket/front'); - case 'order' : return import('order/front'); - case 'claim' : return import('claim/front'); - case 'agency' : return import('agency/front'); - case 'travel' : return import('travel/front'); - case 'worker' : return import('worker/front'); - case 'invoiceOut' : return import('invoiceOut/front'); - case 'route' : return import('route/front'); + case 'client' : return import('client/front'); + case 'item' : return import('item/front'); + case 'ticket' : return import('ticket/front'); + case 'order' : return import('order/front'); + case 'claim' : return import('claim/front'); + case 'agency' : return import('agency/front'); + case 'travel' : return import('travel/front'); + case 'worker' : return import('worker/front'); + case 'invoiceOut' : return import('invoiceOut/front'); + case 'route' : return import('route/front'); } } diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index ff4771330..c64db145f 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -50,9 +50,6 @@ "GreugeType": { "dataSource": "vn" }, - "InvoiceOut": { - "dataSource": "vn" - }, "Mandate": { "dataSource": "vn" }, diff --git a/modules/client/back/models/invoice-out.js b/modules/client/back/models/invoice-out.js deleted file mode 100644 index 1a69d0624..000000000 --- a/modules/client/back/models/invoice-out.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function(Self) { - require('../methods/invoice-out/download')(Self); -}; diff --git a/modules/client/back/models/invoice-out.json b/modules/client/back/models/invoice-out.json deleted file mode 100644 index ecbeb36b0..000000000 --- a/modules/client/back/models/invoice-out.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "InvoiceOut", - "base": "VnModel", - "options": { - "mysql": { - "table": "invoiceOut" - } - }, - "properties": { - "id": { - "id": true, - "type": "Number", - "description": "Identifier" - }, - "ref": { - "id": true, - "type": "String", - "required": true - }, - "serial": { - "type": "String" - }, - "issued": { - "type": "date" - }, - "amount": { - "type": "Number" - }, - "created": { - "type": "date" - }, - "dued": { - "type": "date" - }, - "booked": { - "type": "date" - }, - "hasPdf": { - "type": "Number", - "mysql": { - "columnName": "pdf" - } - } - }, - "relations": { - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - }, - "company": { - "type": "belongsTo", - "model": "Company", - "foreignKey": "companyFk", - "required": true - } - } -} diff --git a/modules/client/back/methods/invoice-out/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js similarity index 100% rename from modules/client/back/methods/invoice-out/download.js rename to modules/invoiceOut/back/methods/invoiceOut/download.js diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js new file mode 100644 index 000000000..6effd642b --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js @@ -0,0 +1,31 @@ +const app = require('vn-loopback/server/server'); + +describe('invoiceOut summary()', () => { + it('should return a summary object containing data from one invoiceOut', async() => { + let result = await app.models.InvoiceOut.summary(1); + + expect(result.invoiceOut.id).toEqual(1); + }); + + it(`should return a summary object containing data from it's tickets`, async() => { + let result = await app.models.InvoiceOut.summary(1); + + expect(result.invoiceOut.ref).toEqual('T1111111'); + expect(result.invoiceOut.tickets().length).toEqual(1); + }); + + it(`should return a summary object containing it's supplier country`, async() => { + let result = await app.models.InvoiceOut.summary(1); + + expect(result.invoiceOut.ref).toEqual('T1111111'); + expect(result.invoiceOut.supplier().id).toEqual(442); + expect(result.invoiceOut.supplier().countryFk).toEqual(1); + }); + + it(`should return a summary object containing idata from it's tax types`, async() => { + let result = await app.models.InvoiceOut.summary(1); + + expect(result.invoiceOut.ref).toEqual('T1111111'); + expect(result.invoiceOut.taxesBreakdown.length).toEqual(2); + }); +}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/summary.js b/modules/invoiceOut/back/methods/invoiceOut/summary.js new file mode 100644 index 000000000..6369f3ca1 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/summary.js @@ -0,0 +1,114 @@ +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +module.exports = Self => { + Self.remoteMethod('summary', { + description: 'The invoiceOut summary', + accessType: 'READ', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The invoiceOut id', + http: {source: 'path'} + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/summary`, + verb: 'GET' + } + }); + + Self.summary = async id => { + const conn = Self.dataSource.connector; + let summary = {}; + + const filter = { + fields: [ + 'id', + 'ref', + 'issued', + 'dued', + 'amount', + 'created', + 'booked', + 'clientFk', + 'companyFk', + 'hasPdf' + ], + where: {id: id}, + include: [ + { + relation: 'company', + scope: { + fields: ['id', 'code'] + } + }, + { + relation: 'supplier', + scope: { + fields: ['id', 'countryFk'] + } + }, + { + relation: 'client', + scope: { + fields: ['id', 'socialName'] + } + }, + { + relation: 'tickets' + } + ] + }; + + summary.invoiceOut = await Self.app.models.InvoiceOut.findOne(filter); + + let stmts = []; + + stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.ticket'); + + stmt = new ParameterizedSQL(` + CREATE TEMPORARY TABLE tmp.ticket + (INDEX (ticketFk)) ENGINE = MEMORY + SELECT id ticketFk FROM vn.ticket WHERE refFk=?`, [summary.invoiceOut.ref]); + stmts.push(stmt); + + stmts.push('CALL ticketGetTotal()'); + + let ticketTotalsIndex = stmts.push('SELECT * FROM tmp.ticketTotal') - 1; + + stmt = new ParameterizedSQL(` + SELECT tc.description as type, SUM(ROUND(s.quantity * s.price * (100 - s.discount) / 100,2)) AS base + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk + JOIN vn.country c ON c.id = itc.countryFK AND c.id = ? + LEFT JOIN vn.taxClass tc ON tc.id = itc.taxClassFk + WHERE t.refFk = ? + GROUP BY type`, [summary.invoiceOut.supplier().countryFk, summary.invoiceOut.ref]); + let invoiceOutTaxesIndex = stmts.push(stmt) - 1; + + stmts.push( + `DROP TEMPORARY TABLE + tmp.ticket, + tmp.ticketTotal`); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await conn.executeStmt(sql); + + totalMap = {}; + for (ticketTotal of result[ticketTotalsIndex]) + totalMap[ticketTotal.ticketFk] = ticketTotal.total; + + summary.invoiceOut.tickets().forEach(ticket => { + ticket.total = totalMap[ticket.id]; + }); + + summary.invoiceOut.taxesBreakdown = result[invoiceOutTaxesIndex]; + + return summary; + }; +}; diff --git a/modules/invoiceOut/back/model-config.json b/modules/invoiceOut/back/model-config.json new file mode 100644 index 000000000..f3492dbe6 --- /dev/null +++ b/modules/invoiceOut/back/model-config.json @@ -0,0 +1,5 @@ +{ + "InvoiceOut": { + "dataSource": "vn" + } +} diff --git a/modules/invoiceOut/back/models/invoiceOut.js b/modules/invoiceOut/back/models/invoiceOut.js new file mode 100644 index 000000000..a3edaa28f --- /dev/null +++ b/modules/invoiceOut/back/models/invoiceOut.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/invoiceOut/summary')(Self); + require('../methods/invoiceOut/download')(Self); +}; diff --git a/modules/invoiceOut/back/models/invoiceOut.json b/modules/invoiceOut/back/models/invoiceOut.json new file mode 100644 index 000000000..7990949e9 --- /dev/null +++ b/modules/invoiceOut/back/models/invoiceOut.json @@ -0,0 +1,71 @@ +{ + "name": "InvoiceOut", + "base": "VnModel", + "options": { + "mysql": { + "table": "invoiceOut" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "ref": { + "type": "String", + "required": true + }, + "serial": { + "type": "String" + }, + "issued": { + "type": "date" + }, + "amount": { + "type": "Number" + }, + "created": { + "type": "date" + }, + "dued": { + "type": "date" + }, + "booked": { + "type": "date" + }, + "hasPdf": { + "type": "Number", + "mysql": { + "columnName": "pdf" + } + } + }, + "relations": { + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "company": { + "type": "belongsTo", + "model": "Company", + "foreignKey": "companyFk", + "required": true + }, + "supplier": { + "type": "belongsTo", + "model": "Supplier", + "foreignKey": "companyFk", + "required": true + }, + "tickets": { + "type": "hasMany", + "model": "Ticket", + "foreignKey": "refFk", + "primaryKey": "ref" + } + } +} + + diff --git a/modules/invoiceOut/front/card/index.js b/modules/invoiceOut/front/card/index.js index 78a2497c7..a36de8750 100644 --- a/modules/invoiceOut/front/card/index.js +++ b/modules/invoiceOut/front/card/index.js @@ -14,15 +14,13 @@ export default class Controller { 'clientFk', 'companyFk' ], - where: {id: $stateParams.id}, include: [ { relation: 'company', scope: { fields: ['id', 'code'] } - }, - { + }, { relation: 'client', scope: { fields: ['id', 'socialName'] @@ -37,10 +35,9 @@ export default class Controller { } getCard() { - let json = encodeURIComponent(JSON.stringify(this.filter)); - this.$http.get(`/client/api/InvoiceOuts?filter=${json}`).then(response => { - this.invoiceOut = response.data[0]; - console.log(response.data[0]); + const params = {filter: this.filter}; + this.$http.get(`/api/InvoiceOuts/${this.$stateParams.id}`, {params}).then(response => { + this.invoiceOut = response.data; }); } diff --git a/modules/invoiceOut/front/index.js b/modules/invoiceOut/front/index.js index a4a6a0950..e037f3d21 100644 --- a/modules/invoiceOut/front/index.js +++ b/modules/invoiceOut/front/index.js @@ -2,5 +2,6 @@ export * from './module'; import './index/'; import './search-panel'; +import './summary'; import './card'; import './descriptor'; diff --git a/modules/invoiceOut/front/index/index.html b/modules/invoiceOut/front/index/index.html index ce1b50948..d33ca6ffc 100644 --- a/modules/invoiceOut/front/index/index.html +++ b/modules/invoiceOut/front/index/index.html @@ -3,7 +3,7 @@ url="/api/InvoiceOuts" filter="::$ctrl.filter" limit="20" - data="invoices" + data="invoicesOut" order="id ASC" auto-load="false"> @@ -35,26 +35,26 @@ - - {{::invoice.ref | dashIfEmpty}} - {{::invoice.issued | dateTime:'dd/MM/yyyy' | dashIfEmpty}} - {{::invoice.amount | currency: 'EUR': 2 | dashIfEmpty}} + ui-sref="invoiceOut.card.summary({id: {{::invoiceOut.id}}})"> + {{::invoiceOut.ref | dashIfEmpty}} + {{::invoiceOut.issued | dateTime:'dd/MM/yyyy' | dashIfEmpty}} + {{::invoiceOut.amount | currency: 'EUR': 2 | dashIfEmpty}} - {{::invoice.client.name | dashIfEmpty}} + ng-click="$ctrl.showClientDescriptor($event, invoiceOut.clientFk)"> + {{::invoiceOut.client.name | dashIfEmpty}} - {{::invoice.created | dateTime:'dd/MM/yyyy' | dashIfEmpty}} - {{::invoice.company.code | dashIfEmpty}} - {{::invoice.dued | dateTime:'dd/MM/yyyy' | dashIfEmpty}} + {{::invoiceOut.created | dateTime:'dd/MM/yyyy' | dashIfEmpty}} + {{::invoiceOut.company.code | dashIfEmpty}} + {{::invoiceOut.dued | dateTime:'dd/MM/yyyy' | dashIfEmpty}} @@ -62,7 +62,7 @@ @@ -77,7 +77,7 @@ vn-id="summary" class="dialog-summary"> - + diff --git a/modules/invoiceOut/front/index/index.js b/modules/invoiceOut/front/index/index.js index 901c68cb9..3f4996bfc 100644 --- a/modules/invoiceOut/front/index/index.js +++ b/modules/invoiceOut/front/index/index.js @@ -4,7 +4,7 @@ export default class Controller { constructor($scope, vnToken) { this.accessToken = vnToken.token; this.$ = $scope; - this.ticketSelected = null; + this.selectedInvoiceOut = null; this.filter = { include: [ @@ -51,9 +51,9 @@ export default class Controller { event.stopImmediatePropagation(); } - preview(event, claim) { - this.claimSelected = claim; - this.$.dialogSummaryClaim.show(); + preview(event, invoiceOut) { + this.selectedInvoiceOut = invoiceOut; + this.$.summary.show(); event.preventDefault(); event.stopImmediatePropagation(); } @@ -62,9 +62,11 @@ export default class Controller { this.$.popover.relocate(); } - openPdf(id) { + openPdf(id, event) { let url = `api/InvoiceOuts/${id}/download?access_token=${this.accessToken}`; window.open(url, '_blank'); + event.preventDefault(); + event.stopImmediatePropagation(); } } diff --git a/modules/invoiceOut/front/routes.json b/modules/invoiceOut/front/routes.json index f6ef89a7e..54d60fc7c 100644 --- a/modules/invoiceOut/front/routes.json +++ b/modules/invoiceOut/front/routes.json @@ -3,10 +3,10 @@ "name": "Invoices out", "icon": "icon-invoices1", "validations" : true, - "dependencies": ["client"], + "dependencies": ["client", "ticket"], "routes": [ { - "url": "/invoiceOut", + "url": "/invoice-out", "state": "invoiceOut", "abstract": true, "component": "ui-view", @@ -17,12 +17,21 @@ "url": "/index?q", "state": "invoiceOut.index", "component": "vn-invoice-out-index", - "description": "Invoices out" + "description": "Invoice out" + }, + { + "url": "/summary", + "state": "invoiceOut.card.summary", + "component": "vn-invoice-out-summary", + "description": "Summary", + "params": { + "invoice-out": "$ctrl.invoiceOut" + } }, { "url": "/:id", "state": "invoiceOut.card", - "abstract": false, + "abstract": true, "component": "vn-invoice-out-card" } ] diff --git a/modules/invoiceOut/front/summary/index.html b/modules/invoiceOut/front/summary/index.html new file mode 100644 index 000000000..810c847f5 --- /dev/null +++ b/modules/invoiceOut/front/summary/index.html @@ -0,0 +1,74 @@ + +
{{$ctrl.summary.invoiceOut.ref}} - {{$ctrl.summary.invoiceOut.client.socialName}}
+ + + + + + + + + + + + + + + + + + + + + + +

Ticket

+ + + + Ticket id + Alias + Amount + + + + + + + {{ticket.id | zeroFill:6}} + + + + + {{ticket.nickname}} + + + {{ticket.total | currency: 'EUR': 2}} + + + +
+
+
+ + + + \ No newline at end of file diff --git a/modules/invoiceOut/front/summary/index.js b/modules/invoiceOut/front/summary/index.js new file mode 100644 index 000000000..ed82242e8 --- /dev/null +++ b/modules/invoiceOut/front/summary/index.js @@ -0,0 +1,66 @@ +import ngModule from '../module'; +import './style.scss'; + +class Controller { + constructor($scope, $http, vnToken) { + this.accessToken = vnToken.token; + this.$http = $http; + this.$ = $scope; + } + + set invoiceOut(value) { + this._invoiceOut = value; + if (value && value.id) + this.getSummary(); + } + + get invoiceOut() { + return this._invoiceOut; + } + + openPdf(id, event) { + let url = `api/InvoiceOuts/${id}/download?access_token=${this.accessToken}`; + window.open(url, '_blank'); + event.preventDefault(); + event.stopImmediatePropagation(); + } + + getSummary() { + this.$http.get(`/api/InvoiceOuts/${this.invoiceOut.id}/summary`).then(response => { + this.summary = response.data; + }); + } + + showClientDescriptor(event, clientFk) { + this.$.clientDescriptor.clientFk = clientFk; + this.$.clientDescriptor.parent = event.target; + this.$.clientDescriptor.show(); + event.preventDefault(); + event.stopImmediatePropagation(); + } + + showTicketDescriptor(event, ticketFk) { + this.$.ticketDescriptor.ticketFk = ticketFk; + this.$.ticketDescriptor.parent = event.target; + this.$.ticketDescriptor.show(); + event.preventDefault(); + event.stopImmediatePropagation(); + } + + preview(event, invoiceOut) { + this.selectedInvoiceOut = invoiceOut; + this.$.invoiceOutSummaryDialog.show(); + event.preventDefault(); + event.stopImmediatePropagation(); + } +} + +Controller.$inject = ['$scope', '$http', 'vnToken']; + +ngModule.component('vnInvoiceOutSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + invoiceOut: '<' + } +}); diff --git a/modules/invoiceOut/front/summary/index.spec.js b/modules/invoiceOut/front/summary/index.spec.js new file mode 100644 index 000000000..34b306de8 --- /dev/null +++ b/modules/invoiceOut/front/summary/index.spec.js @@ -0,0 +1,41 @@ +import './index.js'; + +describe('Route', () => { + describe('Component summary', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('route')); + + beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnRouteSummary'); + controller.route = {id: 1}; + })); + + describe('getSummary()', () => { + it('should perform a query to set summary', () => { + $httpBackend.when('GET', `/api/Routes/1/summary`).respond(200, 24); + $httpBackend.expect('GET', `/api/Routes/1/summary`); + controller.getSummary(); + $httpBackend.flush(); + + expect(controller.summary).toEqual(24); + }); + }); + + describe('sumPackages()', () => { + it('should calculate the packages total', () => { + controller.summary = { + tickets: [ + {packages: 3}, + {packages: 1} + ] + }; + controller.sumPackages(); + + expect(controller.packagesTotal).toEqual(4); + }); + }); + }); +}); diff --git a/modules/invoiceOut/front/summary/locale/es.yml b/modules/invoiceOut/front/summary/locale/es.yml new file mode 100644 index 000000000..74ddf1df3 --- /dev/null +++ b/modules/invoiceOut/front/summary/locale/es.yml @@ -0,0 +1,15 @@ +Driver: Conductor +Vehicle: VehĂ­culo +Packages: Bultos +Starting time: H. Inicio +Finishing time: H. Fin +Km Start: Km de inicio +Km End: Km de fin +PC: CP +Date: Fecha +Created: Creada +Due: Vencimiento +Booked: Asentado +General VAT: IVA general +Reduced VAT: IVA reducido + diff --git a/modules/invoiceOut/front/summary/style.scss b/modules/invoiceOut/front/summary/style.scss new file mode 100644 index 000000000..aef44fbf9 --- /dev/null +++ b/modules/invoiceOut/front/summary/style.scss @@ -0,0 +1,10 @@ +@import "variables"; + + +vn-route-summary .summary { + max-width: $width-large; + + vn-icon[icon=insert_drive_file]{ + color: $color-font-secondary; + } +} \ No newline at end of file diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 6655bb28a..17351dc7a 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -64,5 +64,8 @@ }, "TaxType": { "dataSource": "vn" + }, + "Supplier": { + "dataSource": "vn" } } diff --git a/modules/item/back/models/supplier.json b/modules/item/back/models/supplier.json new file mode 100644 index 000000000..bc13e79b9 --- /dev/null +++ b/modules/item/back/models/supplier.json @@ -0,0 +1,78 @@ +{ + "name": "Supplier", + "base": "VnModel", + "options": { + "mysql": { + "table": "supplier" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "String" + }, + "account": { + "type": "Number" + }, + "countryFk": { + "type": "Number" + }, + "nif": { + "type": "String" + }, + "isFarmer": { + "type": "Boolean" + }, + "phone": { + "type": "Number" + }, + "retAccount": { + "type": "Number" + }, + "commision": { + "type": "Boolean" + }, + "created": { + "type": "Date" + }, + "poscodeFk": { + "type": "Number" + }, + "isActive": { + "type": "Boolean" + }, + "street": { + "type": "String" + }, + "city": { + "type": "String" + }, + "provinceFk": { + "type": "Number" + }, + "postCode": { + "type": "Number" + }, + "payMethodFk": { + "type": "Number" + }, + "payDemFk": { + "type": "Number" + }, + "nickname": { + "type": "String" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/subtotal.js b/modules/ticket/back/methods/ticket/subtotal.js index f1595e77b..0fd16fbdd 100644 --- a/modules/ticket/back/methods/ticket/subtotal.js +++ b/modules/ticket/back/methods/ticket/subtotal.js @@ -34,7 +34,6 @@ module.exports = Self => { subtotal += service.price * service.quantity; }); - return Math.round(subtotal * 100) / 100; }; }; diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index c60b98364..8e9ca5433 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -65,7 +65,8 @@ "invoiceOut": { "type": "belongsTo", "model": "InvoiceOut", - "foreignKey": "refFk" + "foreignKey": "refFk", + "primaryKey": "ref" }, "address": { "type": "belongsTo", diff --git a/package-lock.json b/package-lock.json index 7c6549a1c..c084d1979 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5180,7 +5180,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5201,12 +5202,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5221,17 +5224,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5348,7 +5354,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5360,6 +5367,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5374,6 +5382,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5381,12 +5390,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5405,6 +5416,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5485,7 +5497,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5497,6 +5510,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5582,7 +5596,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5618,6 +5633,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5637,6 +5653,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5680,12 +5697,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -10748,7 +10767,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -10791,7 +10811,8 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", @@ -10802,7 +10823,8 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -10919,7 +10941,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -10931,6 +10954,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -10953,12 +10977,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -10977,6 +11003,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -11057,7 +11084,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -11069,6 +11097,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -11154,7 +11183,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -11190,6 +11220,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -11209,6 +11240,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -11252,12 +11284,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } },