#7897 - masterTest_24_36 #2909
|
@ -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';
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue