feat: refs #7710 pr revision
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javi Gallego 2024-08-23 14:28:25 +02:00
parent 340515968b
commit 32d36cda21
3 changed files with 30 additions and 9 deletions

View File

@ -0,0 +1,24 @@
DELETE FROM `salix`.`ACL`
WHERE `model` = 'Ticket'
AND `property` = 'refund'
AND `accessType` = 'WRITE'
AND `permission` = 'ALLOW'
AND `principalType` = 'ROLE'
AND `principalId` = 'salesAssistant';
UPDATE `salix`.`ACL`
SET `property` = 'cloneAll'
WHERE `model` = 'Ticket'
AND `property` = 'refund'
AND `accessType` = 'WRITE'
AND `permission` = 'ALLOW'
AND `principalType` = 'ROLE'
AND `principalId` IN ('invoicing', 'claimManager', 'logistic');
DELETE FROM `salix`.`ACL`
WHERE `model` = 'Ticket'
AND `property` = 'clone'
AND `accessType` = 'WRITE'
AND `permission` = 'ALLOW'
AND `principalType` = 'ROLE'
AND `principalId` = 'administrative';

View File

@ -82,7 +82,7 @@ module.exports = Self => {
myOptions.transaction = tx;
}
try {
const tickets = await models.Ticket.find({where: {refFk: refFk}}, myOptions);
const tickets = await models.Ticket.find({where: {refFk}}, myOptions);
const ticketsIds = tickets.map(ticket => ticket.id);
const refundTickets = await models.Ticket.cloneAll(ctx, ticketsIds, false, true, myOptions);

View File

@ -19,7 +19,7 @@ module.exports = Self => {
arg: 'negative',
type: 'boolean',
required: true,
description: 'Whether to invert quantities (for credit notes)'
description: 'true: invert quantities; false: keep as is.'
}
],
returns: {
@ -35,12 +35,9 @@ module.exports = Self => {
Self.cloneAll = async(ctx, ticketsIds, withWarehouse, negative, options) => {
const models = Self.app.models;
const myOptions = {};
const myOptions = typeof options == 'object' ? {...options} : {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
@ -55,9 +52,9 @@ module.exports = Self => {
models.TicketPackaging.find(filter, myOptions)
]);
const salesIds = sales.map(sale => sale.id);
const servicesIds = services.map(service => service.id);
const ticketPackagingIds = ticketPackaging.map(packaging => packaging.id);
const salesIds = sales.map(({id}) => id);
const servicesIds = services.map(({id}) => id);
const ticketPackagingIds = ticketPackaging.map(({id}) => id);
const clonedTickets = await models.Sale.clone(
ctx,