From 471da0f4da25634cba7176114e3acffac44fe451 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 7 Sep 2021 11:55:26 +0200 Subject: [PATCH] fix(clone): invoiceIn clone now adds (2) to the ref --- e2e/paths/09-invoice-in/02_descriptor.spec.js | 3 +-- modules/invoiceIn/back/methods/invoice-in/clone.js | 3 ++- .../invoiceIn/back/methods/invoice-in/specs/clone.spec.js | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/e2e/paths/09-invoice-in/02_descriptor.spec.js b/e2e/paths/09-invoice-in/02_descriptor.spec.js index 00ed49ec9..02bbce7ac 100644 --- a/e2e/paths/09-invoice-in/02_descriptor.spec.js +++ b/e2e/paths/09-invoice-in/02_descriptor.spec.js @@ -1,8 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -// #3082 clone is broken due to a strange trigger from production -xdescribe('InvoiceIn descriptor path', () => { +describe('InvoiceIn descriptor path', () => { let browser; let page; diff --git a/modules/invoiceIn/back/methods/invoice-in/clone.js b/modules/invoiceIn/back/methods/invoice-in/clone.js index 35478b045..18df53a95 100644 --- a/modules/invoiceIn/back/methods/invoice-in/clone.js +++ b/modules/invoiceIn/back/methods/invoice-in/clone.js @@ -52,10 +52,11 @@ module.exports = Self => { const issued = new Date(sourceInvoiceIn.issued); issued.setMonth(issued.getMonth() + 1); + const clonedRef = sourceInvoiceIn.supplierRef + '(2)'; const clone = await models.InvoiceIn.create({ serial: sourceInvoiceIn.serial, - supplierRef: sourceInvoiceIn.supplierRef, + supplierRef: clonedRef, supplierFk: sourceInvoiceIn.supplierFk, issued: issued, currencyFk: sourceInvoiceIn.currencyFk, diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js index 71e3c2f6d..e0f191962 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; -// #3082 clone is broken due to a strange trigger from production -xdescribe('invoiceIn clone()', () => { +describe('invoiceIn clone()', () => { it('should return the cloned invoiceIn and also clone invoiceInDueDays and invoiceInTaxes if there are any referencing the invoiceIn', async() => { const userId = 1; const ctx = { @@ -18,7 +17,7 @@ xdescribe('invoiceIn clone()', () => { try { const clone = await models.InvoiceIn.clone(ctx, 1, options); - expect(clone.supplierRef).toEqual('1234'); + expect(clone.supplierRef).toEqual('1234(2)'); const invoiceInTaxes = await models.InvoiceInTax.find({where: {invoiceInFk: clone.id}}, options);