master to test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
9ab850b34d
commit
7704256079
|
@ -172,4 +172,4 @@
|
|||
"Comment added to client": "Comment added to client",
|
||||
"This ticket is already a refund": "This ticket is already a refund",
|
||||
"A claim with that sale already exists": "A claim with that sale already exists"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ module.exports = Self => {
|
|||
const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions);
|
||||
if (!isDeliveryBoss) {
|
||||
const zoneShipped = await models.Agency.getShipped(
|
||||
ctx,
|
||||
args.landed,
|
||||
args.addressFk,
|
||||
args.agencyModeFk,
|
||||
|
|
|
@ -100,7 +100,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
if (!args.shipped && args.landed) {
|
||||
const shippedResult = await models.Agency.getShipped(args.landed,
|
||||
const shippedResult = await models.Agency.getShipped(ctx, args.landed,
|
||||
address.id, args.agencyModeId, args.warehouseId, myOptions);
|
||||
args.shipped = (shippedResult && shippedResult.shipped) || args.landed;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ module.exports = Self => {
|
|||
const isDeliveryBoss = await models.VnUser.hasRole(userId, 'deliveryBoss', myOptions);
|
||||
if (!isDeliveryBoss) {
|
||||
const zoneShipped = await models.Agency.getShipped(
|
||||
ctx,
|
||||
args.landed,
|
||||
args.addressId,
|
||||
args.agencyModeId,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getShipped', {
|
||||
Self.remoteMethodCtx('getShipped', {
|
||||
description: 'Returns the first shipped possible for params',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
|
@ -34,18 +34,22 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getShipped = async(landed, addressFk, agencyModeFk, warehouseFk, options) => {
|
||||
Self.getShipped = async(ctx, landed, addressFk, agencyModeFk, warehouseFk, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const stmts = [];
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const isProductionAssistant = await models.VnUser.hasRole(userId, 'productionAssi', myOptions);
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`CALL vn.zone_getShipped(?, ?, ?, TRUE)`, [
|
||||
`CALL vn.zone_getShipped(?, ?, ?, ?)`, [
|
||||
landed,
|
||||
addressFk,
|
||||
agencyModeFk
|
||||
agencyModeFk,
|
||||
isProductionAssistant
|
||||
]
|
||||
));
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('agency getShipped()', () => {
|
||||
const employeeId = 1;
|
||||
const ctx = {req: {accessToken: {userId: employeeId}}};
|
||||
|
||||
it('should return a shipment date', async() => {
|
||||
const landed = Date.vnNew();
|
||||
landed.setDate(landed.getDate() + 1);
|
||||
|
@ -12,8 +15,7 @@ describe('agency getShipped()', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Agency.getShipped(landed, addressFk, agencyModeFk, warehouseFk, options);
|
||||
const result = await models.Agency.getShipped(ctx, landed, addressFk, agencyModeFk, warehouseFk, options);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
|
||||
|
@ -37,7 +39,7 @@ describe('agency getShipped()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.Agency.getShipped(landed, addressFk, agencyModeFk, warehouseFk, options);
|
||||
const result = await models.Agency.getShipped(ctx, landed, addressFk, agencyModeFk, warehouseFk, options);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
|
|
Loading…
Reference in New Issue