This commit is contained in:
parent
0fd6a6360c
commit
f044809f30
|
@ -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),
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Ticket', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('./ticket-methods')(Self);
|
||||
require('../methods/ticket/state')(Self);
|
||||
require('../methods/ticket/addSaleByCode')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue