7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
3 changed files with 20 additions and 15 deletions
Showing only changes of commit d5f09c2f75 - Show all commits

View File

@ -4,4 +4,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'employee'), ('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'employee'),
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','employee'), ('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','employee'),
('MachineWorker','add','READ','ALLOW','ROLE','employee'), ('MachineWorker','add','READ','ALLOW','ROLE','employee'),
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee'); ('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee'),
('SaleTracking','deleteTracking','WRITE','ALLOW','ROLE','employee');

View File

@ -10,12 +10,12 @@ module.exports = Self => {
description: 'The sale id' description: 'The sale id'
}, },
{ {
arg: 'stateCode', arg: 'stateCodes',
type: 'string' type: ['string']
} },
], ],
returns: { returns: {
type: ['object'], type: 'boolean',
root: true root: true
}, },
http: { http: {
@ -24,7 +24,7 @@ module.exports = Self => {
} }
}); });
Self.delete = async(saleFk, stateCode, options) => { Self.delete = async(saleFk, stateCodes, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -38,20 +38,24 @@ module.exports = Self => {
} }
try { try {
if (stateCode === 'PREPARED') { const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions);
const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions);
for (let itemShelvingSale of itemShelvingSales)
await itemShelvingSale.destroy(myOptions);
}
const state = await models.State.findOne({ for (let itemShelvingSale of itemShelvingSales)
where: {code: stateCode} await itemShelvingSale.destroy(myOptions);
const states = await models.State.find({
fields: ['id'],
where: {
code: {inq: stateCodes}
}
}, myOptions); }, myOptions);
const stateIds = states.map(state => state.id);
const filter = { const filter = {
where: { where: {
saleFk: saleFk, saleFk: saleFk,
stateFk: state.id stateFk: {inq: stateIds}
} }
}; };
const saleTrackings = await models.SaleTracking.find(filter, myOptions); const saleTrackings = await models.SaleTracking.find(filter, myOptions);

View File

@ -100,7 +100,7 @@ class Controller extends Section {
saleTrackingDel(sale, stateCode) { saleTrackingDel(sale, stateCode) {
const params = { const params = {
saleFk: sale.saleFk, saleFk: sale.saleFk,
stateCode: stateCode stateCodes: [stateCode]
}; };
this.$http.post(`SaleTrackings/delete`, params).then(() => { this.$http.post(`SaleTrackings/delete`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));