initial back test created, modified DB statetments
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pau 2022-10-17 12:07:34 +02:00
parent a4243e14c5
commit 70c9c3d788
5 changed files with 20 additions and 8 deletions

View File

@ -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'); VALUES ('Supplier','newSupplier','WRITE','administrative');

View File

@ -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; ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;

View File

@ -17,10 +17,17 @@ module.exports = Self => {
} }
}); });
Self.newSupplier = async(params, options) => { Self.newSupplier = async params => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; 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; params.payDemFk = 1;
if (!myOptions.transaction) { if (!myOptions.transaction) {
@ -38,6 +45,7 @@ module.exports = Self => {
}; };
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
params.e = e;
return params; return params;
} }
}; };

View File

@ -1,14 +1,19 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('Supplier newSupplier()', () => { describe('Supplier newSupplier()', () => {
const supplier = { const newSupp = {
name: 'TestSupplier-1' name: 'TestSupplier-1'
}; };
it('should create a new supplier containing only the name', async() => { 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); expect(result.payDemFk).toEqual(1);
console.log(result);
// const createdSupplier = await app.models.Supplier.
// process.stdout.write(createdSupplier);
}); });
}); });

View File

@ -14,7 +14,6 @@ class Controller extends Section {
redirect(this.$.$ctrl); redirect(this.$.$ctrl);
async function redirect(ctrl) { async function redirect(ctrl) {
await new Promise(r => setTimeout(r, 100));
window.location.href = `/#!/supplier/${ctrl.supplier.supplier.id}/fiscal-data`; window.location.href = `/#!/supplier/${ctrl.supplier.supplier.id}/fiscal-data`;
} }
} }