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() => {