getUserConfig now gets default company and warehouse with dynamic code
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b02d7b3a3b
commit
d440a631c8
|
@ -13,14 +13,22 @@ module.exports = function(Self) {
|
|||
});
|
||||
|
||||
Self.getUserConfig = async ctx => {
|
||||
let userConfig = await Self.app.models.UserConfig.findOne({
|
||||
const models = Self.app.models;
|
||||
|
||||
let userConfig = await models.UserConfig.findOne({
|
||||
where: {userFk: ctx.req.accessToken.userId}
|
||||
});
|
||||
|
||||
const companyFilter = {where: {code: 'VNL'}};
|
||||
const company = await models.Company.findOne(companyFilter);
|
||||
|
||||
const warehouseFilter = {where: {code: 'ALG'}};
|
||||
const warehouse = await models.Warehouse.findOne(warehouseFilter);
|
||||
|
||||
if (!userConfig) {
|
||||
let newConfig = {
|
||||
warehouseFk: 1,
|
||||
companyFk: 442,
|
||||
warehouseFk: warehouse.id,
|
||||
companyFk: company.id,
|
||||
userFk: ctx.req.accessToken.userId
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
"name": {
|
||||
"type": "String"
|
||||
},
|
||||
"code": {
|
||||
"type": "String"
|
||||
},
|
||||
"isInventory": {
|
||||
"type": "Number"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE `vn`.`warehouse`
|
||||
ADD `code` VARCHAR(3) NULL AFTER name;
|
||||
|
||||
UPDATE `vn`.`warehouse` SET `code` = 'ALG' WHERE `id` = 60;
|
|
@ -125,13 +125,13 @@ INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
|
|||
(1, 'Main Warehouse'),
|
||||
(2, 'Silla');
|
||||
|
||||
INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`)
|
||||
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`)
|
||||
VALUES
|
||||
(1, 'Warehouse One', 1, 1, 1, 1, 1, 1, 1, 2, 1),
|
||||
(2, 'Warehouse Two', 1, 1, 1, 1, 0, 0, 1, 2, 13),
|
||||
(3, 'Warehouse Three', 1, 1, 1, 1, 0, 0, 0, 2, 1),
|
||||
(4, 'Warehouse Four', 1, 1, 1, 1, 0, 0, 0, 2, 1),
|
||||
(5, 'Warehouse Five', 1, 1, 1, 1, 0, 0, 0, 2, 1);
|
||||
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1),
|
||||
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13),
|
||||
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1),
|
||||
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1),
|
||||
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1);
|
||||
|
||||
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`)
|
||||
VALUES
|
||||
|
|
Loading…
Reference in New Issue