diff --git a/db/changes/10491-august/00-newSupplier_ACL.sql b/db/changes/10491-august/00-newSupplier_ACL.sql index f23f3026b..c88f3de3f 100644 --- a/db/changes/10491-august/00-newSupplier_ACL.sql +++ b/db/changes/10491-august/00-newSupplier_ACL.sql @@ -1,2 +1,2 @@ -INSERT INTO salix.ACL (model,property,accessType,principalId) +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) VALUES ('Supplier','newSupplier','WRITE','administrative'); diff --git a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql index d64cd3663..660f5e932 100644 --- a/db/changes/10491-august/00-newSupplier_Modify_supplier.sql +++ b/db/changes/10491-august/00-newSupplier_Modify_supplier.sql @@ -1,5 +1,5 @@ -ALTER TABLE vn.supplier MODIFY COLUMN payMethodFk tinyint(3) unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned DEFAULT NULL NULL; /* ------------------------------------------------------------------------------------------- */ -ALTER TABLE vn.supplier MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file +ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index 7cb292871..9d162557c 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -17,10 +17,17 @@ module.exports = Self => { } }); - Self.newSupplier = async(params, options) => { + Self.newSupplier = async params => { const models = Self.app.models; const myOptions = {}; + process.stdout.write(typeof(params)); + + if (typeof(params) == 'string') { + console.log('params was a string, why?'); + params = JSON.parse(params); + } + params.payDemFk = 1; if (!myOptions.transaction) { @@ -38,6 +45,7 @@ module.exports = Self => { }; } catch (e) { if (tx) await tx.rollback(); + params.e = e; return params; } }; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 69a32436e..982a1bb42 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -1,14 +1,19 @@ const app = require('vn-loopback/server/server'); describe('Supplier newSupplier()', () => { - const supplier = { + const newSupp = { name: 'TestSupplier-1' }; it('should create a new supplier containing only the name', async() => { - const result = await app.models.Supplier.newSupplier(supplier); + let result = await app.models.Supplier.newSupplier(JSON.stringify(newSupp)); - expect(result.payDemFk).toEqual('TestSupplier-1'); + expect(result.name).toEqual('TestSupplier-1'); expect(result.payDemFk).toEqual(1); + console.log(result); + + // const createdSupplier = await app.models.Supplier. + + // process.stdout.write(createdSupplier); }); }); diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js index 3104d73b5..bed14c826 100644 --- a/modules/supplier/front/create/index.js +++ b/modules/supplier/front/create/index.js @@ -14,7 +14,6 @@ class Controller extends Section { redirect(this.$.$ctrl); async function redirect(ctrl) { - await new Promise(r => setTimeout(r, 100)); window.location.href = `/#!/supplier/${ctrl.supplier.supplier.id}/fiscal-data`; } }