Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7406-workerFormation
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-06-12 07:51:01 +02:00
commit 60d4372996
7 changed files with 39 additions and 13 deletions

View File

@ -0,0 +1,11 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimRatio_afterUpdate`
AFTER UPDATE ON `claimRatio`
FOR EACH ROW
BEGIN
INSERT INTO clientRate(clientFk, `value`)
VALUES(NEW.clientFk, NEW.priceIncreasing)
ON DUPLICATE KEY UPDATE
`value` = VALUES(`value`);
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
INSERT INTO salix.ACL
SET
model = 'Ticket',
property = 'editZone',
accessType = 'WRITE',
permission = 'ALLOW',
principalType = 'ROLE',
principalId = 'buyer';

View File

@ -48,7 +48,8 @@ module.exports = Self => {
'weight',
'buyingValue',
'price2',
'price3'
'price3',
'printedStickers'
],
include: {
relation: 'item',

View File

@ -11,7 +11,7 @@ export default class Controller extends Section {
fields: ['id', 'countryFk', 'taxClassFk'],
include: [{
relation: 'country',
scope: {fields: ['country']}
scope: {fields: ['name']}
}]
};

View File

@ -26,6 +26,7 @@ module.exports = Self => {
const models = Self.app.models;
const myOptions = {};
let tx;
let newStateOrder;
if (typeof options == 'object')
Object.assign(myOptions, options);
@ -40,11 +41,16 @@ module.exports = Self => {
throw new UserError('State cannot be blank');
if (params.stateFk) {
const {code} = await models.State.findById(params.stateFk, {fields: ['code']}, myOptions);
const {code, order} = await models.State.findById(
params.stateFk,
{fields: ['code', 'order']},
myOptions);
params.code = code;
newStateOrder = order;
} else {
const {id} = await models.State.findOne({where: {code: params.code}}, myOptions);
const {id, order} = await models.State.findOne({where: {code: params.code}}, myOptions);
params.stateFk = id;
newStateOrder = order;
}
if (!params.userFk) {
@ -75,7 +81,9 @@ module.exports = Self => {
}, myOptions);
const salesPersonFk = ticket.client().salesPersonFk;
if (salesPersonFk) {
const stateChecked = await models.State.findOne({fields: ['order'], where: {code: 'CHECKED'}});
if (salesPersonFk && newStateOrder >= stateChecked.order) {
const sales = await Self.rawSql(`
SELECT DISTINCT s.id,
s.itemFk,
@ -83,17 +91,9 @@ module.exports = Self => {
s.originalQuantity AS oldQuantity,
s.quantity AS newQuantity
FROM vn.sale s
JOIN vn.saleTracking st ON st.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.ticketState ts ON ts.ticketFk = t.id
JOIN vn.state s2 ON s2.id = ts.stateFk
WHERE s.ticketFk = ?
AND st.isChecked
AND s.originalQuantity IS NOT NULL
AND s.originalQuantity <> s.quantity
AND s2.\`order\` < (SELECT \`order\` FROM vn.state WHERE code = 'CHECKED')
ORDER BY st.created DESC
`, [params.ticketFk], myOptions);
let changes = '';

View File

@ -56,6 +56,7 @@ module.exports = Self => {
const filter = {
include: [
{relation: 'warehouse', scope: {fields: ['name']}},
{relation: 'ticketCollections', scope: {fields: ['collectionFk']}},
{relation: 'agencyMode', scope: {fields: ['name']}},
{relation: 'zone', scope: {fields: ['name']}},
{relation: 'client',

View File

@ -152,6 +152,11 @@
"type": "belongsTo",
"model": "Cmr",
"foreignKey": "cmrFk"
},
"ticketCollections": {
"type": "hasMany",
"model": "TicketCollection",
"foreignKey": "ticketFk"
}
}
}