From 90a7c803fdc6e36bc7dd3b453312dea25907cdc4 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 12 Apr 2021 16:32:13 +0200 Subject: [PATCH] descriptor invoiceIn amount --- modules/invoiceIn/back/model-config.json | 3 ++ .../back/models/invoice-in-due-day.json | 33 +++++++++++++++++++ modules/invoiceIn/back/models/invoice-in.json | 5 +++ modules/invoiceIn/front/card/index.js | 20 ++++++++--- .../invoiceIn/front/descriptor/locale/es.yml | 3 -- 5 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 modules/invoiceIn/back/models/invoice-in-due-day.json delete mode 100644 modules/invoiceIn/front/descriptor/locale/es.yml diff --git a/modules/invoiceIn/back/model-config.json b/modules/invoiceIn/back/model-config.json index 7f95924a4..88d227ba3 100644 --- a/modules/invoiceIn/back/model-config.json +++ b/modules/invoiceIn/back/model-config.json @@ -1,5 +1,8 @@ { "InvoiceIn": { "dataSource": "vn" + }, + "InvoiceInDueDay": { + "dataSource": "vn" } } diff --git a/modules/invoiceIn/back/models/invoice-in-due-day.json b/modules/invoiceIn/back/models/invoice-in-due-day.json new file mode 100644 index 000000000..6c27dcd6c --- /dev/null +++ b/modules/invoiceIn/back/models/invoice-in-due-day.json @@ -0,0 +1,33 @@ +{ + "name": "InvoiceInDueDay", + "base": "VnModel", + "options": { + "mysql": { + "table": "invoiceInDueDay" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "invoiceInFk": { + "type": "number" + }, + "dueDated": { + "type": "date" + }, + "bankFk": { + "type": "number" + }, + "amount": { + "type": "number" + }, + "created": { + "type": "date" + } + } +} + + diff --git a/modules/invoiceIn/back/models/invoice-in.json b/modules/invoiceIn/back/models/invoice-in.json index 9bd37e569..af6490c8a 100644 --- a/modules/invoiceIn/back/models/invoice-in.json +++ b/modules/invoiceIn/back/models/invoice-in.json @@ -44,6 +44,11 @@ } }, "relations": { + "invoiceInDueDay": { + "type": "hasMany", + "model": "InvoiceInDueDay", + "foreignKey": "invoiceInFk" + }, "company": { "type": "belongsTo", "model": "Company", diff --git a/modules/invoiceIn/front/card/index.js b/modules/invoiceIn/front/card/index.js index 99e96ae90..84f415ce1 100644 --- a/modules/invoiceIn/front/card/index.js +++ b/modules/invoiceIn/front/card/index.js @@ -4,13 +4,23 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { const filter = { - include: { - relation: 'supplier' - } - }; + include: [ + { + relation: 'supplier' + }, + { + relation: 'invoiceInDueDay' + } + ]}; this.$http.get(`InvoiceIns/${this.$params.id}`, {filter}) - .then(res => this.invoiceIn = res.data); + .then(res => { + this.invoiceIn = res.data; + this.invoiceIn.amount = res.data.invoiceInDueDay.reduce( + (accumulator, currentValue) => { + return accumulator + (currentValue['amount'] || 0); + }, 0); + }); } } diff --git a/modules/invoiceIn/front/descriptor/locale/es.yml b/modules/invoiceIn/front/descriptor/locale/es.yml deleted file mode 100644 index 4788ec8aa..000000000 --- a/modules/invoiceIn/front/descriptor/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Entries list: Listado de entradas -Invoice list: Listado de facturas -InvoiceIn deleted: Factura eliminada \ No newline at end of file