From e6c44d74ebb1f71716860aabefceaaa0a1a546dc Mon Sep 17 00:00:00 2001 From: Juan Date: Wed, 28 Feb 2018 20:55:44 +0100 Subject: [PATCH 1/3] Client invoices --- client/client/src/invoices/invoices.html | 30 ++++++++++++++++++++++++ client/client/src/invoices/invoices.js | 7 ++++++ client/client/src/invoices/locale/es.yml | 4 ++++ 3 files changed, 41 insertions(+) create mode 100644 client/client/src/invoices/invoices.html create mode 100644 client/client/src/invoices/invoices.js create mode 100644 client/client/src/invoices/locale/es.yml diff --git a/client/client/src/invoices/invoices.html b/client/client/src/invoices/invoices.html new file mode 100644 index 000000000..2721605ee --- /dev/null +++ b/client/client/src/invoices/invoices.html @@ -0,0 +1,30 @@ + + + Invoices + + + + + + + + + + + + + + + + + + + + + + + +
{{::invoice.ref}}{{::invoice.issued | date:'dd/MM/yyyy'}}{{::invoice.amount | currency:'€':2}} €
No results
{{total | currency:'€':2}}
+ +
+
\ No newline at end of file diff --git a/client/client/src/invoices/invoices.js b/client/client/src/invoices/invoices.js new file mode 100644 index 000000000..52764c1d3 --- /dev/null +++ b/client/client/src/invoices/invoices.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import FilterClientList from '../filter-client-list'; + +ngModule.component('vnClientInvoices', { + template: require('./invoices.html'), + controller: FilterClientList +}); diff --git a/client/client/src/invoices/locale/es.yml b/client/client/src/invoices/locale/es.yml new file mode 100644 index 000000000..316986d41 --- /dev/null +++ b/client/client/src/invoices/locale/es.yml @@ -0,0 +1,4 @@ +Invoices: Facturas +Reference: Referencia +Issue date: Fecha de emisión +Amount: Total \ No newline at end of file From de145bd8148201f5dafd0a016e852090f7c03103 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 1 Mar 2018 14:01:45 +0100 Subject: [PATCH 2/3] #128 - Client invoices form --- client/client/routes.json | 9 +++ client/client/src/client.js | 1 + client/client/src/invoices/invoices.html | 66 +++++++++++-------- client/client/src/invoices/invoices.js | 10 ++- client/client/src/invoices/locale/es.yml | 1 + .../common/methods/invoiceOut/filter.js | 14 ++++ .../common/methods/invoiceOut/sumAmount.js | 27 ++++++++ services/client/common/models/invoice-out.js | 4 ++ .../{mandateType.json => mandate-type.json} | 0 9 files changed, 103 insertions(+), 29 deletions(-) create mode 100644 services/client/common/methods/invoiceOut/filter.js create mode 100644 services/client/common/methods/invoiceOut/sumAmount.js create mode 100644 services/client/common/models/invoice-out.js rename services/client/common/models/{mandateType.json => mandate-type.json} (100%) diff --git a/client/client/routes.json b/client/client/routes.json index a6fcb5036..7fb15d8db 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -179,6 +179,15 @@ "description": "Mandate", "icon": "pan_tool" } + }, + { + "url": "/invoices", + "state": "clientCard.invoices", + "component": "vn-client-invoices", + "menu": { + "description": "Invoices", + "icon": "insert_drive_file" + } } ] } diff --git a/client/client/src/client.js b/client/client/src/client.js index d61f4e4aa..9b4372f3b 100644 --- a/client/client/src/client.js +++ b/client/client/src/client.js @@ -19,3 +19,4 @@ import './credit-create/credit-create'; import './greuge-list/greuge-list'; import './greuge-create/greuge-create'; import './mandate/mandate'; +import './invoices/invoices'; diff --git a/client/client/src/invoices/invoices.html b/client/client/src/invoices/invoices.html index 2721605ee..95fc6ee61 100644 --- a/client/client/src/invoices/invoices.html +++ b/client/client/src/invoices/invoices.html @@ -1,30 +1,40 @@ - - - Invoices - - - - - - + + + + + Invoices + + + + + + - - - - - - - - - - - - - - - - -
{{::invoice.ref}}{{::invoice.issued | date:'dd/MM/yyyy'}}{{::invoice.amount | currency:'€':2}} €
No results
{{total | currency:'€':2}}
- -
+ + + + {{::invoice.ref}} + {{::invoice.issued | date:'dd/MM/yyyy' }} + {{::invoice.dued | date:'dd/MM/yyyy' }} + {{::invoice.amount | currency:'€':2}} + + + + No results + + + + + {{edit.model.sumAmount | currency:'€':2}} + + + +
\ No newline at end of file diff --git a/client/client/src/invoices/invoices.js b/client/client/src/invoices/invoices.js index 52764c1d3..6f1ea5df1 100644 --- a/client/client/src/invoices/invoices.js +++ b/client/client/src/invoices/invoices.js @@ -1,7 +1,15 @@ import ngModule from '../module'; import FilterClientList from '../filter-client-list'; +class Controller extends FilterClientList { + constructor($scope, $timeout, $state, $stateParams) { + super($scope, $timeout, $state); + $scope.$stateParams = $stateParams; + } +} +Controller.$inject = ['$scope', '$timeout', '$state', '$stateParams']; + ngModule.component('vnClientInvoices', { template: require('./invoices.html'), - controller: FilterClientList + controller: Controller }); diff --git a/client/client/src/invoices/locale/es.yml b/client/client/src/invoices/locale/es.yml index 316986d41..1f03f6318 100644 --- a/client/client/src/invoices/locale/es.yml +++ b/client/client/src/invoices/locale/es.yml @@ -1,4 +1,5 @@ Invoices: Facturas Reference: Referencia Issue date: Fecha de emisión +Due date: Vencimiento Amount: Total \ No newline at end of file diff --git a/services/client/common/methods/invoiceOut/filter.js b/services/client/common/methods/invoiceOut/filter.js new file mode 100644 index 000000000..0927f9b02 --- /dev/null +++ b/services/client/common/methods/invoiceOut/filter.js @@ -0,0 +1,14 @@ +module.exports = Self => { + Self.installMethod('filter', filterParams); + + function filterParams(params) { + return { + where: { + clientFk: params.clientFk + }, + skip: (params.page - 1) * params.size, + limit: params.size, + order: params.order, + }; + } +}; diff --git a/services/client/common/methods/invoiceOut/sumAmount.js b/services/client/common/methods/invoiceOut/sumAmount.js new file mode 100644 index 000000000..9f03687ff --- /dev/null +++ b/services/client/common/methods/invoiceOut/sumAmount.js @@ -0,0 +1,27 @@ +module.exports = Self => { + Self.remoteMethod('sumAmount', { + description: 'Returns the sum of invoices amount for a client', + accessType: 'READ', + accepts: [{ + arg: 'id', + description: 'The client Id', + type: 'number', + required: true, + http: {source: 'path'} + }], + returns: { + arg: 'sumAmount', + type: 'number' + }, + http: { + path: `/:id/sumAmount`, + verb: 'GET' + } + }); + + Self.sumAmount = async id => { + let query = `SELECT SUM(amount) AS sumAmount FROM vn.invoiceOut WHERE clientFk = ?`; + let result = await Self.rawSql(query, [id]); + return result[0].sumAmount; + }; +}; diff --git a/services/client/common/models/invoice-out.js b/services/client/common/models/invoice-out.js new file mode 100644 index 000000000..c4c5e0dbd --- /dev/null +++ b/services/client/common/models/invoice-out.js @@ -0,0 +1,4 @@ +module.exports = function(Self) { + require('../methods/invoiceOut/filter.js')(Self); + require('../methods/invoiceOut/sumAmount.js')(Self); +}; diff --git a/services/client/common/models/mandateType.json b/services/client/common/models/mandate-type.json similarity index 100% rename from services/client/common/models/mandateType.json rename to services/client/common/models/mandate-type.json From f6c6ee15969b7706777d4844078b6e5e52ed5c23 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Date: Thu, 1 Mar 2018 14:02:51 +0100 Subject: [PATCH 3/3] update fixtures adding data to vn.recovery --- services/db/04-fixtures.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/db/04-fixtures.sql b/services/db/04-fixtures.sql index 24f37a0ae..95dcd450a 100644 --- a/services/db/04-fixtures.sql +++ b/services/db/04-fixtures.sql @@ -446,4 +446,11 @@ INSERT INTO `vn`.`invoiceOut`(`id`, `ref`, `serial`, `amount`, `clientFk`, `crea VALUES ( 1, 'T1111111' , 'T', 500 , 1, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1), ( 2, 'V2222222' , 'V', 350.50 , 2, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1), - ( 3, 'E3333333' , 'E', 90.30 , 3, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1); \ No newline at end of file + ( 3, 'E3333333' , 'E', 90.30 , 3, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1); + +INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`) + VALUES + ( 1, '1', CURDATE(), date_add(CURDATE(),INTERVAL 1 MONTH), 50, 7), + ( 2, '2', CURDATE(), date_add(CURDATE(),INTERVAL 3 MONTH), 100, 1), + ( 3, '2', CURDATE(), date_add(CURDATE(),INTERVAL 1 MONTH), 50, 7), + ( 4, '3', CURDATE(), NULL, 50, 7); \ No newline at end of file