Merge branch 'dev' into 6897-entryMigration
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-06-13 06:51:09 +00:00
commit 2dc7e75aee
5 changed files with 40 additions and 13 deletions

View File

@ -1711,7 +1711,7 @@ INSERT INTO `ACL` VALUES (570,'InvoiceOut','canCreatePdf','WRITE','ALLOW','ROLE'
INSERT INTO `ACL` VALUES (571,'Supplier','editPayMethodCheck','WRITE','ALLOW','ROLE','financial');
INSERT INTO `ACL` VALUES (572,'Worker','isTeamBoss','WRITE','ALLOW','ROLE','teamBoss');
INSERT INTO `ACL` VALUES (573,'Worker','forceIsSubordinate','READ','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (574,'Claim','editState','WRITE','ALLOW','ROLE','claimManager');
INSERT INTO `ACL` VALUES (574,'Claim','editPickup','WRITE','ALLOW','ROLE','claimManager');
INSERT INTO `ACL` VALUES (577,'Claim','findOne','READ','ALLOW','ROLE','salesPerson');
INSERT INTO `ACL` VALUES (579,'Claim','updateClaim','WRITE','ALLOW','ROLE','salesPerson');
INSERT INTO `ACL` VALUES (580,'Claim','regularizeClaim','WRITE','ALLOW','ROLE','claimManager');

View File

@ -3126,6 +3126,18 @@ INSERT INTO `vn`.`entryDms`(`entryFk`, `dmsFk`, `editorFk`)
VALUES
(1, 9, 9);
INSERT INTO vn.entryType (code,description,isInformal)
VALUES ('devaluation','Devaluation',0),
('internal','Internal',1),
('inventory','Inventory',1),
('life','Life',1),
('packaging','Packaging',0),
('payment','Refund',0),
('product','Product',0),
('regularization','Regularization',1),
('return','Return',0),
('transport','Delivery',0);
INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentInstruccions,specialAgreements,companyFk,addressToFk,addressFromFk,supplierFk,packagesList,merchandiseDetail,state)
VALUES (1,'123456A','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',442,1,2,1,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'),
(2,'123456N','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',69,3,4,2,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'),

View File

@ -13,7 +13,15 @@ trig:BEGIN
LEAVE trig;
END IF;
CALL entry_isEditable(OLD.entryFk);
IF NOT (NEW.entryFk <=> OLD.entryFk) OR
NOT (NEW.quantity <=> OLD.quantity) OR
NOT (NEW.buyingValue <=> OLD.buyingValue) OR
NOT (NEW.packing <=> OLD.packing)
THEN
CALL entry_isEditable(OLD.entryFk);
END IF;
SET NEW.editorFk = account.myUser_getId();
SELECT defaultEntry INTO vDefaultEntry

View File

@ -7,10 +7,21 @@ BEGIN
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
DECLARE vTotalBuy INT;
IF NEW.isBooked = OLD.isBooked THEN
IF NEW.isBooked = OLD.isBooked AND (
NOT (NEW.supplierFk <=> OLD.supplierFk) OR
NOT (NEW.dated <=> OLD.dated) OR
NOT (NEW.invoiceNumber <=> OLD.invoiceNumber) OR
NOT (NEW.travelFk <=> OLD.travelFk) OR
NOT (NEW.companyFk <=> OLD.companyFk) OR
NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR
NOT (NEW.invoiceAmount <=> OLD.invoiceAmount) OR
NOT (NEW.typeFk <=> OLD.typeFk)
) THEN
CALL entry_isEditable(OLD.id);
ELSE
IF NEW.isBooked THEN
SELECT COUNT(*) INTO vTotalBuy
FROM buy

View File

@ -69,30 +69,26 @@ module.exports = Self => {
}
}
}, myOptions);
// Get sales person from claim client
const salesPerson = claim.client().salesPersonUser();
const changedPickup = args.pickup != claim.pickup;
const changedPickup = args.pickup && args.pickup != claim.pickup;
// Validate when claimState has been changed
if (args.claimStateFk) {
const canEditOldState = await models.ClaimState.isEditable(ctx, claim.claimStateFk, myOptions);
const canEditNewState = await models.ClaimState.isEditable(ctx, args.claimStateFk, myOptions);
const canEditState = await models.ACL.checkAccessAcl(ctx, 'Claim', 'editState', 'WRITE');
const canEditPickup = await models.ACL.checkAccessAcl(ctx, 'Claim', 'editPickup', 'WRITE');
if (!canEditOldState || !canEditNewState || changedPickup && !canEditState)
if (!canEditOldState || !canEditNewState || (changedPickup && !canEditPickup))
throw new UserError(`You don't have enough privileges to change that field`);
}
delete args.ctx;
const updatedClaim = await claim.updateAttributes(args, myOptions);
// When pickup has been changed
const salesPerson = claim.client().salesPersonUser();
if (salesPerson) {
if (changedPickup && updatedClaim.pickup)
await notifyPickUp(ctx, salesPerson.id, claim);
// When claimState has been changed
if (args.claimStateFk) {
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
await notifyStateChange(ctx, salesPerson.id, claim, newState.description);
@ -113,7 +109,7 @@ module.exports = Self => {
async function notifyStateChange(ctx, workerId, claim, newState) {
const models = Self.app.models;
const url = await models.Url.getUrl();
const $t = ctx.req.__; // $translate
const $t = ctx.req.__;
const message = $t(`Claim state has changed to`, {
claimId: claim.id,