#6951 create ticket_cloneAll #2120

Merged
jorgep merged 11 commits from 6951-ticketCloneAll into dev 2024-03-25 07:48:20 +00:00
5 changed files with 59 additions and 2 deletions
Showing only changes of commit f044809f30 - Show all commits

View File

@ -15,7 +15,7 @@ BEGIN
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
CALL ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse);
CALL ticket_Clone(vTicketFk, vNewTicketFk);
UPDATE ticket
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),

View File

@ -0,0 +1,2 @@
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES('Ticket', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative');

View File

@ -0,0 +1,54 @@
module.exports = Self => {
Self.remoteMethodCtx('clone', {
description: 'clone a ticket and return the new ticket id',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'The ticket id',
http: {source: 'path'}
}, {
arg: 'shipped',
type: 'date',
}, {
arg: 'withWarehouse',
type: 'boolean',
}
],
returns: {
type: 'number',
root: true
},
http: {
path: `/:id/clone`,
verb: 'POST'
}
});
Self.clone = async(ctx, id, shipped, withWarehouse, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const [, [{clonedTicketId}]] = await Self.rawSql(`
CALL vn.ticket_CloneAll(?, ?, ?, @clonedTicketId);
SELECT @clonedTicketId clonedTicketId;`,
[id, shipped, withWarehouse], myOptions);
if (tx) await tx.commit();
return clonedTicketId;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -46,4 +46,6 @@ module.exports = function(Self) {
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
require('../methods/ticket/docuwareDownload')(Self);
require('../methods/ticket/myLastModified')(Self);
require('../methods/ticket/addSaleByCode')(Self);
require('../methods/ticket/clone')(Self);
};

View File

@ -1,5 +1,4 @@
module.exports = Self => {
require('./ticket-methods')(Self);
require('../methods/ticket/state')(Self);
require('../methods/ticket/addSaleByCode')(Self);
};