diff --git a/client/client/routes.json b/client/client/routes.json
index 13f7f90e4..173224037 100644
--- a/client/client/routes.json
+++ b/client/client/routes.json
@@ -180,6 +180,15 @@
"icon": "pan_tool"
}
},
+ {
+ "url": "/invoices",
+ "state": "clientCard.invoices",
+ "component": "vn-client-invoices",
+ "menu": {
+ "description": "Invoices",
+ "icon": "insert_drive_file"
+ }
+ },
{
"url": "/recovery",
"abstract": true,
diff --git a/client/client/src/client.js b/client/client/src/client.js
index fe4f75d1a..935a33b43 100644
--- a/client/client/src/client.js
+++ b/client/client/src/client.js
@@ -19,6 +19,7 @@ import './credit-create/credit-create';
import './greuge-list/greuge-list';
import './greuge-create/greuge-create';
import './mandate/mandate';
+import './invoices/invoices';
import './summary/client-summary';
import './recovery-list/recovery-list';
import './recovery-create/recovery-create';
diff --git a/client/client/src/invoices/invoices.html b/client/client/src/invoices/invoices.html
new file mode 100644
index 000000000..95fc6ee61
--- /dev/null
+++ b/client/client/src/invoices/invoices.html
@@ -0,0 +1,40 @@
+
+
+
+
+ Invoices
+
+
+
+
+
+
+
+
+
+
+ {{::invoice.ref}}
+ {{::invoice.issued | date:'dd/MM/yyyy' }}
+ {{::invoice.dued | date:'dd/MM/yyyy' }}
+ {{::invoice.amount | currency:'€':2}}
+
+
+
+ No results
+
+
+
+
+
+
+
\ 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..6f1ea5df1
--- /dev/null
+++ b/client/client/src/invoices/invoices.js
@@ -0,0 +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: Controller
+});
diff --git a/client/client/src/invoices/locale/es.yml b/client/client/src/invoices/locale/es.yml
new file mode 100644
index 000000000..1f03f6318
--- /dev/null
+++ b/client/client/src/invoices/locale/es.yml
@@ -0,0 +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
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