From 287caf24b12d0db752b897afb09a50f3c29c4808 Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 16 Oct 2018 14:44:48 +0200 Subject: [PATCH] new model receipt and update fixtures --- services/client/common/models/receipt.json | 63 +++++++++++++++++++ services/client/server/model-config.json | 3 + services/db/install/dump/fixtures.sql | 7 +++ .../methods/client/specs/getCard.spec.js | 2 +- .../methods/client/specs/getDebt.spec.js | 2 +- .../methods/client/specs/summary.spec.js | 2 +- 6 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 services/client/common/models/receipt.json diff --git a/services/client/common/models/receipt.json b/services/client/common/models/receipt.json new file mode 100644 index 000000000..ad18ff44d --- /dev/null +++ b/services/client/common/models/receipt.json @@ -0,0 +1,63 @@ +{ + "name": "Receipt", + "base": "VnModel", + "options": { + "mysql": { + "table": "receipt" + } +}, +"properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "ref": { + "id": true, + "type": "String", + "required": true + }, + "amountPaid": { + "type": "Number" + }, + "amountUnpaid": { + "type": "Number" + }, + "payed": { + "type": "date" + }, + "worcreated": { + "type": "date" + }, + "isConciliate": { + "type": "date" + } +}, +"relations": { + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "company": { + "type": "belongsTo", + "model": "Company", + "foreignKey": "companyFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "bank": { + "type": "belongsTo", + "model": "Bank", + "foreignKey": "bankFk" + }, + "invoice": { + "type": "belongsTo", + "model": "InvoiceOut", + "foreignKey": "invoiceFk" + } + } +} \ No newline at end of file diff --git a/services/client/server/model-config.json b/services/client/server/model-config.json index 4793077d3..ba216c886 100644 --- a/services/client/server/model-config.json +++ b/services/client/server/model-config.json @@ -61,5 +61,8 @@ }, "ClientRisk": { "dataSource": "vn" + }, + "Receipt": { + "dataSource": "vn" } } diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql index adb0059ff..65b2c5853 100644 --- a/services/db/install/dump/fixtures.sql +++ b/services/db/install/dump/fixtures.sql @@ -1002,3 +1002,10 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (9, 1, 442); + +INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `amountUnpaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) + VALUES + (1, 'Cobro web', 100.50, 0.00, CURDATE(), 9, 1, 101, CURDATE(), 442, 1), + (2, 'Cobro web', 200.50, 0.00, CURDATE(), 9, 1, 101, CURDATE(), 442, 1), + (3, 'Cobro en efectivo', 300.00, 100.00, CURDATE(), 9, 1, 102, CURDATE(), 442, 0), + (4, 'Cobro en efectivo', 400.00, -50.00, CURDATE(), 9, 1, 103, CURDATE(), 442, 0); \ No newline at end of file diff --git a/services/loopback/common/methods/client/specs/getCard.spec.js b/services/loopback/common/methods/client/specs/getCard.spec.js index eb43128f6..70574a332 100644 --- a/services/loopback/common/methods/client/specs/getCard.spec.js +++ b/services/loopback/common/methods/client/specs/getCard.spec.js @@ -7,6 +7,6 @@ describe('Client card', () => { expect(result.id).toEqual(101); expect(result.name).toEqual('Bruce Wayne'); - expect(result.debt).toEqual(880.1); + expect(result.debt).toEqual(579.1); }); }); diff --git a/services/loopback/common/methods/client/specs/getDebt.spec.js b/services/loopback/common/methods/client/specs/getDebt.spec.js index 550a98055..f888254a1 100644 --- a/services/loopback/common/methods/client/specs/getDebt.spec.js +++ b/services/loopback/common/methods/client/specs/getDebt.spec.js @@ -4,7 +4,7 @@ describe('client getDebt()', () => { it('should return the client debt', async() => { let result = await app.models.Client.getDebt(101); - expect(result.debt).toEqual(880.1); + expect(result.debt).toEqual(579.1); }); }); diff --git a/services/loopback/common/methods/client/specs/summary.spec.js b/services/loopback/common/methods/client/specs/summary.spec.js index 3314bb7a1..44c1e4145 100644 --- a/services/loopback/common/methods/client/specs/summary.spec.js +++ b/services/loopback/common/methods/client/specs/summary.spec.js @@ -17,7 +17,7 @@ describe('client summary()', () => { it('should return a summary object containing debt', async() => { let result = await app.models.Client.summary(101); - expect(result.debt.debt).toEqual(880.1); + expect(result.debt.debt).toEqual(579.1); }); it('should return a summary object containing averageInvoiced', async() => {