Merge branch 'dev' into 6948-bank
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-03-07 06:17:26 +00:00
commit 39b4e5db28
86 changed files with 2660 additions and 286 deletions

1
Jenkinsfile vendored
View File

@ -71,7 +71,6 @@ pipeline {
stage('Back') {
steps {
sh 'pnpm install --prefer-offline'
sh 'pnpx puppeteer browsers install chrome'
}
}
stage('Print') {

View File

@ -0,0 +1,31 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('assign', {
description: 'Assign a collection',
accessType: 'WRITE',
http: {
path: `/assign`,
verb: 'POST'
},
returns: {
type: ['object'],
root: true
},
});
Self.assign = async(ctx, options) => {
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
const [,, {collectionFk}] = await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
[userId], myOptions);
if (!collectionFk) throw new UserError('There are not picking tickets');
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
return collectionFk;
};
};

View File

@ -0,0 +1,157 @@
module.exports = Self => {
Self.remoteMethodCtx('getSales', {
description: 'Get sales from ticket or collection',
accessType: 'READ',
accepts: [
{
arg: 'collectionOrTicketFk',
type: 'number',
required: true
}, {
arg: 'print',
type: 'boolean',
required: true
}, {
arg: 'source',
type: 'string',
required: true
},
],
returns: {
type: 'Object',
root: true
},
http: {
path: `/getSales`,
verb: 'GET'
},
});
Self.getSales = async(ctx, collectionOrTicketFk, print, source, options) => {
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
const $t = ctx.req.__;
if (typeof options == 'object')
Object.assign(myOptions, options);
const [{id}] = await Self.rawSql('SELECT vn.ticket_get(?) as id',
[collectionOrTicketFk],
myOptions);
const [tickets] = await Self.rawSql('CALL vn.collection_getTickets(?)', [id], myOptions);
if (source) {
await Self.rawSql(
'CALL vn.ticketStateToday_setState(?,?)', [id, source], myOptions
);
}
const [sales] = await Self.rawSql('CALL vn.sale_getFromTicketOrCollection(?)',
[id], myOptions);
const isPicker = source != 'CHECKER';
const [placements] = await Self.rawSql('CALL vn.collectionPlacement_get(?, ?)',
[id, isPicker], myOptions
);
if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions);
for (let ticket of tickets) {
let observations = ticket.observaciones.split(' ');
for (let observation of observations) {
const salesPerson = ticket.salesPersonFk;
if (observation.startsWith('#') || observation.startsWith('@')) {
await models.Chat.send(ctx,
observation,
$t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
);
}
}
}
return getCollection(id, tickets, sales, placements, myOptions);
};
async function getCollection(id, tickets, sales, placements, options) {
const collection = {
collectionFk: id,
tickets: [],
};
for (let ticket of tickets) {
const {ticketFk} = ticket;
ticket.sales = [];
const barcodes = await getBarcodes(ticketFk, options);
await Self.rawSql(
'CALL util.log_add(?, ?, ?, ?, ?, ?, ?, ?)',
['vn', 'ticket', 'Ticket', ticketFk, ticketFk, 'select', null, null],
options
);
for (let sale of sales) {
if (sale.ticketFk == ticketFk) {
sale.placements = [];
for (const salePlacement of placements) {
if (salePlacement.saleFk == sale.saleFk && salePlacement.order) {
const placement = {
saleFk: salePlacement.saleFk,
itemFk: salePlacement.itemFk,
placement: salePlacement.placement,
shelving: salePlacement.shelving,
created: salePlacement.created,
visible: salePlacement.visible,
order: salePlacement.order,
grouping: salePlacement.grouping,
priority: salePlacement.priority,
saleOrder: salePlacement.saleOrder,
isPreviousPrepared: salePlacement.isPreviousPrepared,
itemShelvingSaleFk: salePlacement.itemShelvingSaleFk,
ticketFk: salePlacement.ticketFk,
id: salePlacement.id
};
sale.placements.push(placement);
}
}
sale.barcodes = [];
for (const barcode of barcodes) {
if (barcode.movementId == sale.saleFk) {
if (barcode.code) {
sale.barcodes.push(barcode.code);
sale.barcodes.push(`0 ${barcode.code}`);
}
if (barcode.id) {
sale.barcodes.push(barcode.id);
sale.barcodes.push(`0 ${barcode.id}`);
}
}
}
ticket.sales.push(sale);
}
}
collection.tickets.push(ticket);
}
return collection;
}
async function getBarcodes(ticketId, options) {
const query =
`SELECT s.id movementId,
b.code,
c.id
FROM vn.sale s
LEFT JOIN vn.itemBarcode b ON b.itemFk = s.itemFk
LEFT JOIN vn.buy c ON c.itemFk = s.itemFk
LEFT JOIN vn.entry e ON e.id = c.entryFk
LEFT JOIN vn.travel tr ON tr.id = e.travelFk
WHERE s.ticketFk = ?
AND tr.landed >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR)`;
return Self.rawSql(query, [ticketId], options);
}
};

View File

@ -0,0 +1,38 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('ticket assign()', () => {
let ctx;
let options;
let tx;
beforeEach(async() => {
ctx = {
req: {
accessToken: {userId: 1106},
headers: {origin: 'http://localhost'},
__: value => value
},
args: {}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: ctx.req
});
options = {transaction: tx};
tx = await models.Sale.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
it('should throw an error when there is not picking tickets', async() => {
try {
await models.Collection.assign(ctx, options);
} catch (e) {
expect(e.message).toEqual('There are not picking tickets');
}
});
});

View File

@ -0,0 +1,62 @@
const {models} = require('vn-loopback/server/server');
describe('collection getSales()', () => {
const collectionOrTicketFk = 999999;
const print = true;
const source = 'CHECKER';
beforeAll(() => {
ctx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'},
}
};
});
it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
const tx = await models.Collection.beginTransaction({});
const options = {transaction: tx};
try {
const collection = await models.Collection.getSales(ctx,
collectionOrTicketFk, print, source, options);
const [firstTicket] = collection.tickets;
const [firstSale] = firstTicket.sales;
const [firstPlacement] = firstSale.placements;
expect(collection.tickets.length).toBeTruthy();
expect(collection.collectionFk).toEqual(firstTicket.ticketFk);
expect(firstSale.ticketFk).toEqual(firstTicket.ticketFk);
expect(firstSale.placements.length).toBeTruthy();
expect(firstSale.barcodes.length).toBeTruthy();
expect(firstSale.saleFk).toEqual(firstPlacement.saleFk);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should print a sticker', async() => {
const tx = await models.Collection.beginTransaction({});
const options = {transaction: tx};
const query = 'SELECT * FROM printQueue pq JOIN printQueueArgs pqa ON pqa.printQueueFk = pq.id';
try {
const printQueueBefore = await models.Collection.rawSql(
query, [], options);
await models.Collection.getSales(ctx,
collectionOrTicketFk, true, source, options);
const printQueueAfter = await models.Collection.rawSql(
query, [], options);
expect(printQueueAfter.length).toEqual(printQueueBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -0,0 +1,132 @@
const {models} = require('vn-loopback/server/server');
describe('machineWorker updateInTime()', () => {
const itBoss = 104;
const davidCharles = 1106;
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
it('should throw an error if the plate does not exist', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
const plate = 'RE-123';
ctx.req.accessToken.userId = 1106;
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toContain('the plate does not exist');
await tx.rollback();
}
});
it('should grab a machine where is not in use', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
const plate = 'RE-003';
ctx.req.accessToken.userId = 1107;
try {
const totalBefore = await models.MachineWorker.find(null, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const totalAfter = await models.MachineWorker.find(null, options);
expect(totalAfter.length).toEqual(totalBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
describe('less than 12h', () => {
const plate = 'RE-001';
it('should trow an error if it is not himself', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = davidCharles;
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toContain('This machine is already in use');
await tx.rollback();
}
});
it('should throw an error if it is himself with a different machine', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = itBoss;
const plate = 'RE-003';
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('You are already using a machine');
await tx.rollback();
}
});
it('should set the out time if it is himself', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = itBoss;
try {
const isNotParked = await models.MachineWorker.findOne({
where: {workerFk: itBoss}
}, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const isParked = await models.MachineWorker.findOne({
where: {workerFk: itBoss}
}, options);
expect(isNotParked.outTime).toBeNull();
expect(isParked.outTime).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});
describe('equal or more than 12h', () => {
const plate = 'RE-002';
it('should set the out time and grab the machine', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = davidCharles;
const filter = {
where: {workerFk: davidCharles, machineFk: 2}
};
try {
const isNotParked = await models.MachineWorker.findOne(filter, options);
const totalBefore = await models.MachineWorker.find(null, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const isParked = await models.MachineWorker.findOne(filter, options);
const totalAfter = await models.MachineWorker.find(null, options);
expect(isNotParked.outTime).toBeNull();
expect(isParked.outTime).toBeDefined();
expect(totalAfter.length).toEqual(totalBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});
});

View File

@ -0,0 +1,77 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateInTime', {
description: 'Updates the corresponding registry if the worker has been registered in the last few hours',
accessType: 'WRITE',
accepts: [
{
arg: 'plate',
type: 'string',
}
],
http: {
path: `/updateInTime`,
verb: 'POST'
}
});
Self.updateInTime = async(ctx, plate, options) => {
const models = Self.app.models;
const userId = ctx.req.accessToken.userId;
const $t = ctx.req.__;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const machine = await models.Machine.findOne({
fields: ['id', 'plate'],
where: {plate}
}, myOptions);
if (!machine)
throw new Error($t('the plate does not exist', {plate}));
const machineWorker = await Self.findOne({
where: {
or: [{machineFk: machine.id}, {workerFk: userId}],
outTime: null,
}
}, myOptions);
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
const hoursDifference = (Date.vnNow() - machineWorker.inTime.getTime()) / (60 * 60 * 1000);
if (machineWorker) {
const isHimself = userId == machineWorker.workerFk;
const isSameMachine = machine.id == machineWorker.machineFk;
if (hoursDifference < maxHours && !isHimself)
throw new UserError($t('This machine is already in use.'));
if (hoursDifference < maxHours && isHimself && !isSameMachine)
throw new UserError($t('You are already using a machine'));
await machineWorker.updateAttributes({
outTime: Date.vnNew()
}, myOptions);
}
if (!machineWorker || hoursDifference >= maxHours)
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -0,0 +1,45 @@
module.exports = Self => {
Self.remoteMethodCtx('getVersion', {
description: 'gets app version data',
accessType: 'READ',
accepts: [{
arg: 'app',
type: 'string',
required: true
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getVersion`,
verb: 'GET'
}
});
Self.getVersion = async(ctx, app) => {
const {models} = Self.app;
const userId = ctx.req.accessToken.userId;
const workerFk = await models.WorkerAppTester.findOne({
where: {
workerFk: userId
}
});
let fields = ['id', 'appName'];
if (workerFk)
fields = fields.concat(['isVersionBetaCritical', 'versionBeta', 'urlBeta']);
else
fields = fields.concat(['isVersionCritical', 'version', 'urlProduction']);
const filter = {
where: {
appName: app
},
fields,
};
return Self.findOne(filter);
};
};

View File

@ -0,0 +1,29 @@
const {models} = require('vn-loopback/server/server');
describe('mobileAppVersionControl getVersion()', () => {
const appName = 'delivery';
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
}
};
});
it('should get the version app', async() => {
ctx.req.accessToken.userId = 9;
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
expect(version).toEqual('9.2');
expect(versionBeta).toBeUndefined();
});
it('should get the beta version app', async() => {
ctx.req.accessToken.userId = 66;
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
expect(versionBeta).toBeDefined();
expect(version).toBeUndefined();
});
});

View File

@ -79,9 +79,15 @@
"Language": {
"dataSource": "vn"
},
"Machine": {
"dataSource": "vn"
},
"MachineWorker": {
"dataSource": "vn"
},
"MachineWorkerConfig": {
"dataSource": "vn"
},
"MobileAppVersionControl": {
"dataSource": "vn"
},

View File

@ -3,4 +3,6 @@ module.exports = Self => {
require('../methods/collection/setSaleQuantity')(Self);
require('../methods/collection/previousLabel')(Self);
require('../methods/collection/getTickets')(Self);
require('../methods/collection/assign')(Self);
require('../methods/collection/getSales')(Self);
};

View File

@ -0,0 +1,18 @@
{
"name": "MachineWorkerConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.machineWorkerConfig"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"maxHours": {
"type": "number"
}
}
}

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/machine-worker/updateInTime')(Self);
};

18
back/models/machine.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "Machine",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.machine"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"plate": {
"type": "string"
}
}
}

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/mobile-app-version-control/getVersion')(Self);
};

View File

@ -0,0 +1,39 @@
{
"name": "MobileAppVersionControl",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.mobileAppVersionControl"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"appName": {
"type": "string"
},
"version": {
"type": "string"
},
"isVersionCritical": {
"type": "boolean"
},
"urlProduction": {
"type": "string"
},
"urlBeta": {
"type": "string"
},
"versionBeta": {
"type": "string"
},
"isVersionBetaCritical": {
"type": "boolean"
}
}
}

View File

@ -1239,6 +1239,7 @@ INSERT INTO `vn`.`train`(`id`, `name`)
INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPackingTypeFk`, `warehouseFk`, `sectorFk`, `labelerFk`)
VALUES
('1106', '1', '1', 'H', '1', '1', '1'),
('9', '2', '1', 'H', '1', '1', '1'),
('1107', '1', '1', 'V', '1', '1', '1');
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
@ -1819,17 +1820,14 @@ INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`)
VALUES
( 1, 'pending', 'Pendiente', 1, 1, 0),
( 2, 'managed', 'Gestionado', 72, 5, 0),
( 3, 'resolved', 'Resuelto', 72, 7, 0),
( 4, 'canceled', 'Anulado', 72, 6, 1),
( 5, 'incomplete', 'Incompleta', 1, 3, 1),
( 6, 'mana', 'Mana', 72, 4, 0),
( 7, 'lack', 'Faltas', 72, 2, 0);
( 5, 'incomplete', 'Incompleta', 1, 3, 1);
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `ticketFk`)
VALUES
(1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, 11),
(2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16),
(2, util.VN_CURDATE(), 4, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16),
(3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7),
(4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8);
@ -2729,10 +2727,10 @@ INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `m
(1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 'pending');
INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`)
INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`,`versionBeta`)
VALUES
('delivery', '9.2', 0),
('warehouse', '8.1', 0);
('delivery', '9.2', 0,'9.7'),
('warehouse', '8.1', 0,'8.3');
INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`)
VALUES
@ -3069,3 +3067,666 @@ INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentIns
UPDATE vn.department
SET workerFk = null;
-- NEW WAREHOUSE
INSERT INTO vn.packaging
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0);
INSERT IGNORE INTO vn.intrastat
SET id = 44219999,
description = 'Manufacturas de madera',
taxClassFk = 1,
taxCodeFk = 1;
INSERT IGNORE INTO vn.warehouse
SET id = 999,
name = 'TestingWarehouse',
hasAvailable = TRUE,
isForTicket = TRUE,
isInventory = TRUE,
hasUbications = TRUE,
hasProduction = TRUE;
INSERT IGNORE INTO vn.sector
SET id = 9991,
description = 'NormalSector',
warehouseFk = 999,
code = 'NS',
isPackagingArea = FALSE,
sonFk = NULL,
isMain = TRUE,
itemPackingTypeFk = NULL;
INSERT IGNORE INTO vn.sector
SET id = 9992,
description = 'PreviousSector',
warehouseFk = 999,
code = 'PS',
isPackagingArea = FALSE,
sonFk = NULL,
isMain = TRUE,
itemPackingTypeFk = NULL;
INSERT IGNORE INTO vn.sector
SET id = 9993,
description = 'MezaninneSector',
warehouseFk = 999,
code = 'MS',
isPackagingArea = FALSE,
sonFk = 9991,
isMain = TRUE,
itemPackingTypeFk = NULL;
INSERT INTO vn.parking (id,sectorFk, code, pickingOrder)
VALUES (4,9991, 'A-01-1', 1),
(5,9991, 'A-02-2', 2),
(6,9991, 'A-03-3', 3),
(7,9991, 'A-04-4', 4),
(8,9991, 'A-05-5', 5),
(9,9992, 'P-01-1', 6),
(10,9992, 'P-02-2', 7),
(11,9992, 'P-03-3', 8),
(12,9993, 'M-01-1', 9),
(13,9993, 'M-02-2', 10),
(14,9993, 'M-03-3', 11);
INSERT INTO vn.shelving (code, parkingFk, priority)
VALUES ('NAA', 4, 1),
('NBB', 5, 1),
('NCC', 6, 1),
('NDD', 7, 1),
('NEE', 8, 1),
('PAA', 9, 1),
('PBB', 10, 1),
('PCC', 11, 1),
('MAA', 12, 1),
('MBB', 13, 1),
('MCC', 14, 1);
INSERT IGNORE INTO vn.itemType
SET id = 999,
code = 'WOO',
name = 'Wood Objects',
categoryFk = 3,
workerFk = 103,
isInventory = TRUE,
life = 10,
density = 250,
itemPackingTypeFk = NULL,
temperatureFk = 'warm';
INSERT IGNORE INTO vn.travel
SET id = 99,
shipped = CURDATE(),
landed = CURDATE(),
warehouseInFk = 999,
warehouseOutFk = 1,
isReceived = TRUE;
INSERT INTO vn.entry
SET id = 999,
supplierFk = 791,
isConfirmed = TRUE,
dated = CURDATE(),
travelFk = 99,
companyFk = 442;
INSERT INTO vn.ticket
SET id = 999999,
clientFk = 2,
warehouseFk = 999,
shipped = CURDATE(),
nickname = 'Cliente',
addressFk = 1,
companyFk = 442,
agencyModeFk = 10,
landed = CURDATE();
INSERT INTO vn.collection
SET id = 10101010,
workerFk = 9;
INSERT IGNORE INTO vn.ticketCollection
SET id = 10101010,
ticketFk = 999999,
collectionFk = 10101010;
INSERT INTO vn.item
SET id = 999991,
name = 'Palito para pinchos',
`size` = 25,
stems = NULL,
category = 'EXT',
typeFk = 999,
longName = 'Palito para pinchos',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 6,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 9999991,
entryFk = 999,
itemFk = 999991,
quantity = 8,
buyingValue = 0.61,
stickers = 1,
packing = 20,
`grouping` = 1,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 50;
INSERT INTO vn.sale
SET id = 99991,
itemFk = 999991,
ticketFk = 999999,
concept = 'Palito para pinchos',
quantity = 3,
price = 1,
discount = 0;
INSERT INTO vn.item
SET id = 999992,
name = 'Madera verde',
`size` = 10,
stems = NULL,
category = 'EXT',
typeFk = 999,
longName = 'Madera verde',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 50,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 9999992,
entryFk = 999,
itemFk = 999992,
quantity = 40,
buyingValue = 0.62,
stickers = 1,
packing = 40,
`grouping` = 5,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 25;
INSERT INTO vn.sale
SET id = 99992,
itemFk = 999992,
ticketFk = 999999,
concept = 'Madera Verde',
quantity = 10,
price = 1,
discount = 0;
INSERT INTO vn.item
SET id = 999993,
name = 'Madera Roja/Morada',
`size` = 12,
stems = 2,
category = 'EXT',
typeFk = 999,
longName = 'Madera Roja/Morada',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 35,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 9999993,
entryFk = 999,
itemFk = 999993,
quantity = 20,
buyingValue = 0.63,
stickers = 2,
packing = 10,
`grouping` = 5,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 25;
INSERT INTO vn.itemShelving
SET id = 9931,
itemFk = 999993,
shelvingFk = 'NCC',
visible = 10,
`grouping` = 5,
packing = 10;
INSERT INTO vn.sale
SET id = 99993,
itemFk = 999993,
ticketFk = 999999,
concept = 'Madera Roja/Morada',
quantity = 15,
price = 1,
discount = 0;
INSERT INTO vn.item
SET id = 999994,
name = 'Madera Naranja',
`size` = 18,
stems = 1,
category = 'EXT',
typeFk = 999,
longName = 'Madera Naranja',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 160,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 9999994,
entryFk = 999,
itemFk = 999994,
quantity = 20,
buyingValue = 0.64,
stickers = 1,
packing = 20,
`grouping` = 4,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 25;
INSERT INTO vn.sale
SET id = 99994,
itemFk = 999994,
ticketFk = 999999,
concept = 'Madera Naranja',
quantity = 4,
price = 1,
discount = 0;
INSERT INTO vn.item
SET id = 999995,
name = 'Madera Amarilla',
`size` = 11,
stems = 5,
category = 'EXT',
typeFk = 999,
longName = 'Madera Amarilla',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 78,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 9999995,
entryFk = 999,
itemFk = 999995,
quantity = 4,
buyingValue = 0.65,
stickers = 1,
packing = 20,
`grouping` = 1,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 35;
INSERT INTO vn.sale
SET id = 99995,
itemFk = 999995,
ticketFk = 999999,
concept = 'Madera Amarilla',
quantity = 5,
price = 1,
discount = 0;
-- Palito naranja
INSERT INTO vn.item
SET id = 999998,
name = 'Palito naranja',
`size` = 11,
stems = 1,
category = 'EXT',
typeFk = 999,
longName = 'Palito naranja',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 78,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 9999998,
entryFk = 999,
itemFk = 999998,
quantity = 80,
buyingValue = 0.65,
stickers = 1,
packing = 200,
`grouping` = 30,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 35;
INSERT INTO vn.sale
SET id = 99998,
itemFk = 999998,
ticketFk = 999999,
concept = 'Palito naranja',
quantity = 60,
price = 1,
discount = 0;
-- Palito amarillo
INSERT INTO vn.item
SET id = 999999,
name = 'Palito amarillo',
`size` = 11,
stems = 1,
category = 'EXT',
typeFk = 999,
longName = 'Palito amarillo',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 78,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 9999999,
entryFk = 999,
itemFk = 999999,
quantity = 70,
buyingValue = 0.65,
stickers = 1,
packing = 500,
`grouping` = 10,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 35;
INSERT INTO vn.sale
SET id = 99999,
itemFk = 999999,
ticketFk = 999999,
concept = 'Palito amarillo',
quantity = 50,
price = 1,
discount = 0;
-- Palito azul
INSERT INTO vn.item
SET id = 1000000,
name = 'Palito azul',
`size` = 10,
stems = 1,
category = 'EXT',
typeFk = 999,
longName = 'Palito azul',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 78,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 10000000,
entryFk = 999,
itemFk = 1000000,
quantity = 75,
buyingValue = 0.65,
stickers = 2,
packing = 300,
`grouping` = 50,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 35;
INSERT INTO vn.sale
SET id = 100000,
itemFk = 1000000,
ticketFk = 999999,
concept = 'Palito azul',
quantity = 50,
price = 1,
discount = 0;
-- Palito rojo
INSERT INTO vn.item
SET id = 1000001,
name = 'Palito rojo',
`size` = 10,
stems = NULL,
category = 'EXT',
typeFk = 999,
longName = 'Palito rojo',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 78,
intrastatFk = 44219999;
INSERT INTO vn.buy
SET id = 10000001,
entryFk = 999,
itemFk = 1000001,
quantity = 12,
buyingValue = 0.65,
stickers = 2,
packing = 50,
`grouping` = 5,
groupingMode = 1,
packageFk = 94,
price1 = 1,
price2 = 1,
price3 = 1,
minPrice = 1,
weight = 35;
INSERT INTO vn.sale
SET id = 100001,
itemFk = 1000001,
ticketFk = 999999,
concept = 'Palito rojo',
quantity = 10,
price = 1,
discount = 0;
-- Previa
INSERT IGNORE INTO vn.item
SET id = 999996,
name = 'Bolas de madera',
`size` = 2,
stems = 4,
category = 'EXT',
typeFk = 999,
longName = 'Bolas de madera',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 20,
intrastatFk = 44219999;
INSERT vn.buy
SET id = 9999996,
entryFk = 999,
itemFk = 999996,
quantity = 5,
buyingValue = 3,
stickers = 1,
packing = 5,
`grouping` = 2,
groupingMode = 1,
packageFk = 94,
price1 = 7,
price2 = 7,
price3 = 7,
minPrice = 7,
weight = 80;
INSERT vn.sale
SET id = 99996,
itemFk = 999996,
ticketFk = 999999,
concept = 'Bolas de madera',
quantity = 4,
price = 7,
discount = 0,
isPicked = TRUE;
INSERT IGNORE INTO vn.item
SET id = 999997,
name = 'Palitos de polo MIX',
`size` = 14,
stems = NULL,
category = 'EXT',
typeFk = 999,
longName = 'Palitos de polo MIX',
itemPackingTypeFk = NULL,
originFk = 1,
weightByPiece = 20,
intrastatFk = 44219999;
INSERT vn.buy
SET id = 9999997,
entryFk = 999,
itemFk = 999997,
quantity = 100,
buyingValue = 3.2,
stickers = 1,
packing = 100,
`grouping` = 5,
groupingMode = 1,
packageFk = 94,
price1 = 7,
price2 = 7,
price3 = 7,
minPrice = 7,
weight = 80;
INSERT vn.sale
SET id = 99997,
itemFk = 999997,
ticketFk = 999999,
concept = 'Palitos de polo MIX',
quantity = 5,
price = 7,
discount = 0;
USE vn;
DELETE ish.* FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.warehouse w ON w.id = s.warehouseFk
WHERE w.name = 'TestingWarehouse';
INSERT INTO vn.itemShelving
(itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked)
VALUES
(999991, 'NAA', 8, '2023-09-20', 1, 20, NULL, 103, NULL),
(999998, 'NAA', 80, '2023-09-20', 10, 30, NULL, 103, NULL),
(1000001, 'NAA', 6, '2023-09-20', 3, 50, NULL, 103, NULL),
(1000000, 'NBB', 50, '2023-09-18', 25, 500, NULL, 103, NULL),
(999993, 'NBB', 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
(999999, 'NBB', 30, '2023-09-18', 10, 500, NULL, 103, NULL),
(999993, 'NCC', 25, '2023-09-20', 5, 10, NULL, 103, NULL),
(999997, 'NCC', 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
(999999, 'NCC', 40, '2023-09-20', 10, 500, NULL, 103, NULL),
(999995, 'NDD', 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
(999994, 'NDD', 48, '2023-09-19', 4, 20, NULL, 103, NULL),
(1000001, 'NEE', 6, '2023-09-21', 3, 50, NULL, 103, NULL),
(999992, 'NEE', 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
(1000000, 'NEE', 25, '2023-09-21', 25, 500, NULL, 103, NULL),
(999996, 'PAA', 5, '2023-09-27', 1, 5, NULL, 103, NULL),
(999997, 'PCC', 10, '2023-09-27', 5, 100, NULL, 103, NULL);
-- Previous for Bolas de madera
INSERT IGNORE INTO vn.sectorCollection
SET id = 99,
userFk = 1,
sectorFk = 9992;
INSERT IGNORE INTO vn.saleGroup
SET id = 4,
userFk = 1,
parkingFk = 9,
sectorFk = 9992;
INSERT IGNORE INTO vn.sectorCollectionSaleGroup
SET id = 9999,
sectorCollectionFk = 99,
saleGroupFk = 999;
INSERT vn.saleGroupDetail
SET id = 99991,
saleFk = 99996,
saleGroupFk = 999;
INSERT INTO vn.saleTracking
SET id = 7,
saleFk = 99996,
isChecked = TRUE,
workerFk = 103,
stateFk = 28;
INSERT IGNORE INTO vn.itemShelvingSale
SET id = 991,
itemShelvingFk = 9962,
saleFk = 99996,
quantity = 5,
userFk = 1;
UPDATE vn.ticket
SET zoneFk=1
WHERE id=999999;
UPDATE vn.collection
SET workerFk=9
WHERE id=10101010;
UPDATE vn.sale
SET isPicked =FALSE;
INSERT INTO vn.machineWorkerConfig(maxHours)
VALUES(12);
INSERT INTO vn.workerAppTester(workerFk) VALUES(66);
INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`)
VALUES
('RE-003', 'IRON', 'JPH-24', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
INSERT INTO vn.machineWorker(workerFk,machineFk,inTimed) VALUES (104,1,'2001-01-01 10:00:00.00.000');
UPDATE vn.buy SET itemOriginalFk = 1 WHERE id = 1;
UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5;
INSERT INTO vn.report (name) VALUES ('LabelCollection');

View File

@ -39,11 +39,11 @@ BEGIN
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.price2 > 0
AND b.quantity > 0
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,

View File

@ -13,15 +13,15 @@ BEGIN
DECLARE vWarehouseIn INT;
DECLARE vWarehouseOut INT;
DECLARE vCalcVisible INT;
DECLARE vInventoryDate DATE DEFAULT vn.getInventoryDate();
DECLARE vInventoryDate DATE DEFAULT getInventoryDate();
SELECT shipped, landed, warehouseInFk, warehouseOutFk
INTO vDateShipped, vDateLanded, vWarehouseIn, vWarehouseOut
FROM vn.travel t
JOIN vn.entry e ON e.travelFk = t.id
FROM travel t
JOIN entry e ON e.travelFk = t.id
WHERE e.id = vSelf;
CALL vn.rate_getPrices(vDateShipped, vWarehouseIn);
CALL rate_getPrices(vDateShipped, vWarehouseIn);
-- Traslado en almacen origen
CREATE OR REPLACE TEMPORARY TABLE tBuy
@ -84,7 +84,7 @@ BEGIN
WHERE a.available
ON DUPLICATE KEY UPDATE availableLanding = a.available;
ELSE
CALL vn.item_getStock(vWarehouseOut, vDateShipped, NULL);
CALL item_getStock(vWarehouseOut, vDateShipped, NULL);
CREATE OR REPLACE TEMPORARY TABLE tItem
(UNIQUE INDEX i USING HASH (itemFk))
@ -97,7 +97,7 @@ BEGIN
FROM tmp.itemList;
END IF;
CALL vn.buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
CREATE OR REPLACE TEMPORARY TABLE tTransfer
ENGINE = MEMORY
@ -145,26 +145,26 @@ BEGIN
b.id buyFkOrigin,
pa.returnCost,
b.weight
FROM vn.item i
FROM item i
JOIN tItem ti ON ti.itemFk = i.id
LEFT JOIN vn.producer p ON p.id = i.producerFk
LEFT JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN vn.origin o ON o.id = i.originFk
LEFT JOIN producer p ON p.id = i.producerFk
LEFT JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN tBuy lb ON lb.itemFk = i.id
LEFT JOIN vn.buy b ON b.id = lb.buyFk
LEFT JOIN vn.packaging pa ON pa.id = b.packagingFk
LEFT JOIN vn.entry e2 ON e2.id = b.entryFk
LEFT JOIN vn.supplier s ON s.id = e2.supplierFk
LEFT JOIN vn.entry e ON e.id = vSelf
LEFT JOIN vn.travel tr ON tr.id = e.travelFk
LEFT JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
LEFT JOIN vn.buy b2 ON b2.itemFk = i.id
LEFT JOIN buy b ON b.id = lb.buyFk
LEFT JOIN packaging pa ON pa.id = b.packagingFk
LEFT JOIN entry e2 ON e2.id = b.entryFk
LEFT JOIN supplier s ON s.id = e2.supplierFk
LEFT JOIN entry e ON e.id = vSelf
LEFT JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN agencyMode am ON am.id = tr.agencyModeFk
LEFT JOIN buy b2 ON b2.itemFk = i.id
AND b2.entryFk = vSelf
LEFT JOIN vn.packaging pa2 ON pa2.id = b.packagingFk
LEFT JOIN packaging pa2 ON pa2.id = b.packagingFk
LEFT JOIN tmp.rate r ON TRUE
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
LEFT JOIN vn.buy b3 ON b3.id = bufi.buyFk
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
WHERE ic.display
AND NOT e.isRaid
AND (ti.visible OR ti.available)
@ -172,11 +172,6 @@ BEGIN
CREATE INDEX tIndex USING HASH ON tTransfer (itemFk);
SET @carriage := 0;
SET @comission := 0;
SET @packaging := 0;
SET @rate3 := 0;
SET @cost := 0;
SELECT *,
quantity - MOD(quantity , `grouping`) subQuantity,
MOD(quantity, `grouping`) soll,

View File

@ -30,10 +30,11 @@ BEGIN
ish.visible,
p.sectorFk,
it.workerFk buyer,
CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage,
ic.url,
i.image,
ish.isChecked,
CASE
WHEN s.notPrepared > sm.parked THEN 0
WHEN IFNULL (s.notPrepared, 0) > sm.parked THEN 0
WHEN sm.visible > sm.parked THEN 1
ELSE 2
END priority
@ -43,7 +44,7 @@ BEGIN
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN (
LEFT JOIN (
SELECT s.itemFk, sum(s.quantity) notPrepared
FROM sale s
JOIN ticket t ON t.id = s.ticketFk

View File

@ -1,7 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getSimilar`(
vSelf INT,
vTicketFk INT,
vWarehouseFk INT,
vDated DATE,
vShowType BOOL
)
BEGIN
@ -10,11 +11,10 @@ BEGIN
* de veces usado y segun sus caracteristicas.
*
* @param vSelf Id de artículo
* @param vTicketFk Id de ticket
* @param vWarehouseFk Id de almacen
* @param vDated Fecha
* @param vShowType Mostrar tipos
*/
DECLARE vWarehouseFk INT;
DECLARE vShipped DATE;
DECLARE vCalcFk INT;
DECLARE vTypeFk INT;
DECLARE vPriority INT DEFAULT 1;
@ -31,11 +31,6 @@ BEGIN
DECLARE vValue7 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
DECLARE vValue8 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
SELECT warehouseFk, shipped
INTO vWarehouseFk, vShipped
FROM ticket
WHERE id = vTicketFk;
SELECT typeFk,
tag5,
value5,
@ -64,7 +59,7 @@ BEGIN
LEFT JOIN tag t ON t.id = it.tagFk
WHERE i.id = vSelf;
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
SELECT i.id itemFk,
i.longName,

View File

@ -27,7 +27,7 @@ BEGIN
s.quantity,
MAKETIME(pb.HH,pb.mm,0) etd,
pb.routeFk,
FLOOR(s.quantity / ish.packing) stickers,
FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
b.packagingFk
FROM sale s
@ -71,5 +71,3 @@ BEGIN
DROP TEMPORARY TABLE tmp.sale;
END$$
DELIMITER ;
CALL `vn`.`sale_getBoxPickingList`(1, curdate());

View File

@ -79,7 +79,10 @@ DECLARE vIsCollection BOOL;
IF(SUM(iss.quantity) IS NULL, 0, SUM(iss.quantity)) pickedQuantity,
MIN(iss.created) picked,
IF(sm.id, TRUE, FALSE) hasMistake,
sg.sectorFk
sg.sectorFk,
b.packing,
b.grouping,
o.code
FROM tmp.ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN ticket tt ON tt.id = t.id

View File

@ -15,7 +15,7 @@ BEGIN
JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.id = ts.alertLevel
WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered')
WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered'))
AND t.id = vTicketFk
AND t.refFk IS NULL
GROUP BY t.id);

View File

@ -0,0 +1,12 @@
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES
('Collection', 'assign', 'WRITE', 'ALLOW', 'ROLE', 'production'),
('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'production'),
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production'),
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','production'),
('SaleTracking','delete','WRITE','ALLOW','ROLE','production'),
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production'),
('SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'),
('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
('Sale', 'getFromSectorCollection', 'READ', 'ALLOW', 'ROLE', 'production'),
('ItemBarcode', 'delete', 'WRITE', 'ALLOW', 'ROLE', 'production');

View File

@ -0,0 +1,6 @@
-- Place your SQL code here
ALTER TABLE IF EXISTS vn2008.dock__ RENAME vn2008.dock;
ALTER TABLE IF EXISTS vn2008.dock COMMENT='';
ALTER TABLE IF EXISTS vn2008.Tramos__ RENAME vn2008.Tramos;
ALTER TABLE IF EXISTS vn2008.Tramos COMMENT='';

View File

@ -0,0 +1 @@
ALTER TABLE vn.warehouse AUTO_INCREMENT=92;

View File

@ -0,0 +1,8 @@
UPDATE vn.claim c
JOIN vn.claimState cs ON cs.id = c.claimStateFk
JOIN vn.claimState ns ON ns.code = 'resolved'
SET c.claimStateFk = ns.id
WHERE cs.code IN ('managed', 'mana', 'lack', 'relocation');
DELETE FROM vn.claimState
WHERE code IN ('managed', 'mana', 'lack', 'relocation');

View File

@ -0,0 +1,2 @@
-- Place your SQL code here
ALTER TABLE dipole.expedition_PrintOut MODIFY COLUMN street varchar(42) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT ' ' NOT NULL;

View File

@ -0,0 +1,8 @@
ALTER TABLE vn.department
ADD COLUMN pbxQueue varchar(128) CHARACTER
SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;
ALTER TABLE vn.department
ADD CONSTRAINT department_queue_FK
FOREIGN KEY (pbxQueue) REFERENCES pbx.queue(name) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -21,7 +21,7 @@ describe('Claim edit basic data path', () => {
});
it(`should edit claim state and observation fields`, async() => {
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado');
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Resuelto');
await page.clearInput(selectors.claimBasicData.packages);
await page.write(selectors.claimBasicData.packages, '2');
await page.waitToClick(selectors.claimBasicData.saveButton);
@ -48,7 +48,7 @@ describe('Claim edit basic data path', () => {
await page.waitForSelector(selectors.claimBasicData.claimState);
const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value');
expect(result).toEqual('Gestionado');
expect(result).toEqual('Resuelto');
});
it('should confirm the "is paid with mana" and "Pick up" checkbox are checked', async() => {

View File

@ -1,6 +1,7 @@
const LoopBackContext = require('loopback-context');
async function handleObserve(ctx) {
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
const httpCtx = LoopBackContext.getCurrentContext();
ctx.options.userId = httpCtx?.active?.accessToken?.userId;
}
module.exports = function(Self) {
let Mixin = {

View File

@ -209,5 +209,16 @@
"You cannot update these fields": "You cannot update these fields",
"CountryFK cannot be empty": "Country cannot be empty",
"You are not allowed to modify the alias": "You are not allowed to modify the alias",
"You already have the mailAlias": "You already have the mailAlias"
"You already have the mailAlias": "You already have the mailAlias",
"This machine is already in use.": "This machine is already in use.",
"the plate does not exist": "The plate {{plate}} does not exist",
"We do not have availability for the selected item": "We do not have availability for the selected item",
"You are already using a machine": "You are already using a machine",
"this state does not exist": "This state does not exist",
"The line could not be marked": "The line could not be marked",
"The sale cannot be tracked": "The sale cannot be tracked",
"Shelving not valid": "Shelving not valid",
"printerNotExists": "The printer does not exist",
"There are not picking tickets": "There are not picking tickets",
"ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)"
}

View File

@ -346,5 +346,6 @@
"You cannot update these fields": "No puedes actualizar estos campos",
"CountryFK cannot be empty": "El país no puede estar vacío",
"Cmr file does not exist": "El archivo del cmr no existe",
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias"
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas"
}

View File

@ -275,7 +275,7 @@ class VnMySQL extends MySQL {
}
invokeMethod(method, args, model, ctx, opts, cb) {
if (!this.isLoggable(model))
if (!this.isLoggable(model) && !opts?.userId)
return super[method].apply(this, args);
this.invokeMethodP(method, [...args], model, ctx, opts)
@ -287,11 +287,11 @@ class VnMySQL extends MySQL {
let tx;
if (!opts.transaction) {
tx = await Transaction.begin(this, {});
opts = Object.assign({transaction: tx, httpCtx: opts.httpCtx}, opts);
opts = Object.assign({transaction: tx}, opts);
}
try {
const userId = opts.httpCtx && opts.httpCtx.active?.accessToken?.userId;
const {userId} = opts;
if (userId) {
const user = await Model.app.models.VnUser.findById(userId, {fields: ['name']}, opts);
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);

View File

@ -3,7 +3,6 @@ module.exports = function(iban, countryCode) {
if (typeof iban != 'string') return false;
if (countryCode?.toLowerCase() != 'es') return true;
iban = iban.toUpperCase();
iban = trim(iban);
iban = iban.replace(/\s/g, '');

View File

@ -64,7 +64,7 @@ describe('claimstate isEditable()', () => {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: claimManagerId}}};
const result = await app.models.ClaimState.isEditable(ctx, 7, options);
const result = await app.models.ClaimState.isEditable(ctx, 5, options);
expect(result).toEqual(true);

View File

@ -21,12 +21,13 @@ describe('Update Claim', () => {
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
});
const newDate = Date.vnNew();
const claimManagerId = 72;
const originalData = {
ticketFk: 3,
clientFk: 1101,
ticketCreated: newDate,
workerFk: 18,
claimStateFk: 2,
claimStateFk: 5,
isChargedToMana: true,
responsibility: 4,
observation: 'observation'
@ -77,7 +78,6 @@ describe('Update Claim', () => {
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const pendingState = claimStatesMap.pending;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
@ -104,85 +104,7 @@ describe('Update Claim', () => {
}
});
it(`should success to update the claimState to 'managed' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const managedState = claimStatesMap.managed;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: managedState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'resolved' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const resolvedState = claimStatesMap.resolved;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: resolvedState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'canceled' and send a rocket message`, async() => {
it(`should success to update the claimState to 'canceled' and send two rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
@ -194,7 +116,6 @@ describe('Update Claim', () => {
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const canceledState = claimStatesMap.canceled;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
@ -212,46 +133,7 @@ describe('Update Claim', () => {
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should success to update the claimState to 'incomplete' and send a rocket message`, async() => {
const tx = await app.models.Claim.beginTransaction({});
try {
const options = {transaction: tx};
const newClaim = await app.models.Claim.create(originalData, options);
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
const incompleteState = 5;
const claimManagerId = 72;
const ctx = {
req: {
accessToken: {userId: claimManagerId},
headers: {origin: url}
},
args: {
observation: 'valid observation',
claimStateFk: incompleteState,
hasToPickUp: false
}
};
ctx.req.__ = i18n.__;
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
expect(updatedClaim.observation).toEqual(ctx.args.observation);
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(2);
await tx.rollback();
} catch (e) {

View File

@ -21,7 +21,7 @@ describe('Update Claim', () => {
clientFk: 1101,
ticketCreated: newDate,
workerFk: 18,
claimStateFk: 2,
claimStateFk: 1,
isChargedToMana: true,
responsibility: 4,
observation: 'observation'

View File

@ -33,6 +33,7 @@
<vn-horizontal>
<vn-textfield
label="IBAN"
ng-keyup="$ctrl.client.iban = $ctrl.client.iban.toUpperCase()"
ng-model="$ctrl.client.iban"
rule
on-change="$ctrl.autofillBic()"

View File

@ -37,7 +37,7 @@ describe('Entry filter()', () => {
const result = await models.Entry.filter(ctx, options);
expect(result.length).toEqual(8);
expect(result.length).toEqual(9);
await tx.rollback();
} catch (e) {
@ -81,7 +81,7 @@ describe('Entry filter()', () => {
const result = await models.Entry.filter(ctx, options);
expect(result.length).toEqual(7);
expect(result.length).toEqual(8);
await tx.rollback();
} catch (e) {

View File

@ -80,6 +80,6 @@ module.exports = Self => {
const content = toCSV(sales);
return [content, 'text/csv', `inline; filename="doc-${reference}.pdf"`];
return [content, 'text/csv', `inline; filename="doc-${reference}.csv"`];
};
};

View File

@ -0,0 +1,34 @@
module.exports = Self => {
Self.remoteMethod('delete', {
description: 'Delete an ItemBarcode by itemFk and code',
accessType: 'WRITE',
accepts: [
{
arg: 'barcode',
type: 'string',
required: true,
},
{
arg: 'itemFk',
type: 'number',
required: true,
}
],
http: {
path: `/delete`,
verb: 'DELETE'
}
});
Self.delete = async(barcode, itemFk, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
await Self.destroyAll({
code: barcode,
itemFk
}, myOptions);
};
};

View File

@ -0,0 +1,22 @@
const {models} = require('vn-loopback/server/server');
describe('itemBarcode delete()', () => {
it('should delete a record by itemFk and code', async() => {
const tx = await models.ItemBarcode.beginTransaction({});
const options = {transaction: tx};
const itemFk = 1;
const code = 1111111111;
try {
const itemsBarcodeBefore = await models.ItemBarcode.find({}, options);
await models.ItemBarcode.delete(code, itemFk, options);
const itemsBarcodeAfter = await models.ItemBarcode.find({}, options);
expect(itemsBarcodeBefore.length).toBeGreaterThan(itemsBarcodeAfter.length);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -0,0 +1,64 @@
module.exports = Self => {
Self.remoteMethod('getAlternative', {
description: 'Returns a list of items and possible alternative locations',
accessType: 'READ',
accepts: [{
arg: 'shelvingFk',
type: 'string',
required: true,
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getAlternative`,
verb: 'GET'
}
});
Self.getAlternative = async(shelvingFk, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const filterItemShelvings = {
fields: ['id', 'visible', 'itemFk', 'shelvingFk'],
where: {shelvingFk},
include: [
{
relation: 'item',
scope: {
fields: ['longName', 'name', 'size']
}
},
]
};
let itemShelvings = await models.ItemShelving.find(filterItemShelvings, myOptions);
if (itemShelvings) {
const [alternatives] = await models.ItemShelving.rawSql('CALL vn.itemShelving_getAlternatives(?)',
[shelvingFk], myOptions
);
return itemShelvings.map(itemShelving => {
const item = itemShelving.item();
const shelvings = alternatives.filter(alternative => alternative.itemFk == itemShelving.itemFk);
return {
id: itemShelving.id,
itemFk: itemShelving.itemFk,
name: item.name,
size: item.size,
longName: item.longName,
quantity: itemShelving.visible,
shelvings
};
});
}
};
};

View File

@ -0,0 +1,25 @@
const {models} = require('vn-loopback/server/server');
describe('itemShelving getAlternative()', () => {
beforeAll(async() => {
ctx = {
req: {
headers: {origin: 'http://localhost'},
}
};
});
it('should return a list of items without alternatives', async() => {
const shelvingFk = 'HEJ';
const itemShelvings = await models.ItemShelving.getAlternative(shelvingFk);
expect(itemShelvings[0].shelvings.length).toEqual(0);
});
it('should return an empty list', async() => {
const shelvingFk = 'ZZP';
const itemShelvings = await models.ItemShelving.getAlternative(shelvingFk);
expect(itemShelvings.length).toEqual(0);
});
});

View File

@ -0,0 +1,22 @@
const {models} = require('vn-loopback/server/server');
describe('itemShelving updateFromSale()', () => {
it('should update the quantity', async() => {
const tx = await models.ItemBarcode.beginTransaction({});
const options = {transaction: tx};
const saleFk = 2;
const filter = {where: {itemFk: 4, shelvingFk: 'HEJ'}
};
try {
const {visible: visibleBefore} = await models.ItemShelving.findOne(filter, options);
await models.ItemShelving.updateFromSale(saleFk, options);
const {visible: visibleAfter} = await models.ItemShelving.findOne(filter, options);
expect(visibleAfter).toEqual(visibleBefore + 5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -0,0 +1,48 @@
module.exports = Self => {
Self.remoteMethod('updateFromSale', {
description: 'Update the visible items',
accessType: 'WRITE',
accepts: [{
arg: 'saleFk',
type: 'number',
required: true,
}],
http: {
path: `/updateFromSale`,
verb: 'POST'
}
});
Self.updateFromSale = async(saleFk, options) => {
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const itemShelvingSale = await models.ItemShelvingSale.findOne({
where: {saleFk},
include: {relation: 'itemShelving'}
}, myOptions);
const itemShelving = itemShelvingSale.itemShelving();
const quantity = itemShelving.visible + itemShelvingSale.quantity;
await itemShelving.updateAttributes(
{visible: quantity},
myOptions
);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -0,0 +1,48 @@
module.exports = Self => {
Self.remoteMethod('get', {
description: 'Get the data from an item',
accessType: 'READ',
http: {
path: `/get`,
verb: 'GET'
},
accepts: [
{
arg: 'barcode',
type: 'number',
required: true,
},
{
arg: 'warehouseFk',
type: 'number',
required: true,
}
],
returns: {
type: ['object'],
root: true
},
});
Self.get = async(barcode, warehouseFk, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const models = Self.app.models;
const [[itemInfo]] = await Self.rawSql('CALL vn.item_getInfo(?, ?)', [barcode, warehouseFk], myOptions);
if (itemInfo) {
itemInfo.barcodes = await models.ItemBarcode.find({
fields: ['code'],
where: {
itemFk: itemInfo.id
}
});
}
return itemInfo;
};
};

View File

@ -0,0 +1,12 @@
const {models} = require('vn-loopback/server/server');
describe('item get()', () => {
const barcode = 1;
const warehouseFk = 1;
it('should get an item with several barcodes', async() => {
const card = await models.Item.get(barcode, warehouseFk);
expect(card).toBeDefined();
expect(card.barcodes.length).toBeTruthy();
});
});

View File

@ -1,5 +1,6 @@
module.exports = Self => {
require('../methods/item-barcode/toItem')(Self);
require('../methods/item-barcode/delete')(Self);
Self.validatesUniquenessOf('code', {
message: `Barcode must be unique`

View File

@ -2,4 +2,6 @@ module.exports = Self => {
require('../methods/item-shelving/deleteItemShelvings')(Self);
require('../methods/item-shelving/upsertItem')(Self);
require('../methods/item-shelving/getInventory')(Self);
require('../methods/item-shelving/getAlternative')(Self);
require('../methods/item-shelving/updateFromSale')(Self);
};

View File

@ -54,7 +54,8 @@
"shelving": {
"type": "belongsTo",
"model": "Shelving",
"foreignKey": "shelvingFk"
"foreignKey": "shelvingFk",
"primaryKey": "code"
}
}
}

View File

@ -17,6 +17,7 @@ module.exports = Self => {
require('../methods/item/buyerWasteEmail')(Self);
require('../methods/item/labelPdf')(Self);
require('../methods/item/setVisibleDiscard')(Self);
require('../methods/item/get')(Self);
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});

View File

@ -0,0 +1,56 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('addLog', {
description: 'Add a new log',
accessType: 'WRITE',
accepts: {
arg: 'code',
type: 'string',
required: true,
},
http: {
path: '/addLog',
verb: 'POST'
}
});
Self.addLog = async(ctx, code, options) => {
const userId = ctx.req.accessToken.userId;
const $t = ctx.req.__;
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const shelving = await Self.findOne({
where: {
code
}
}, myOptions);
if (!shelving) throw new UserError($t('Shelving not valid'));
await models.ShelvingLog.create({
changedModel: 'Shelving',
originFk: shelving.id,
changedModelId: shelving.id,
action: 'select',
userFk: userId
}, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -0,0 +1,46 @@
const {models} = require('vn-loopback/server/server');
describe('shelving addLog()', () => {
beforeAll(async() => {
ctx = {
req: {
headers: {origin: 'http://localhost'},
accessToken: {userId: 66},
__: value => value
}
};
});
it('should add a log', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const code = 'AA6';
try {
const shelvingLogsBefore = await models.ShelvingLog.find(null, options);
await models.Shelving.addLog(ctx, code, options);
const shelvingLogsAfter = await models.ShelvingLog.find(null, options);
expect(shelvingLogsAfter.length).toEqual(shelvingLogsBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should throw an error when the code does not exist', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const code = 'DXI345';
try {
await models.Shelving.addLog(ctx, code, options);
await tx.rollback();
} catch (e) {
expect(e.message).toEqual('Shelving not valid');
await tx.rollback();
}
});
});

View File

@ -1,3 +1,4 @@
module.exports = Self => {
require('../methods/shelving/getSummary')(Self);
require('../methods/shelving/addLog')(Self);
};

View File

@ -2,7 +2,7 @@
module.exports = Self => {
Self.remoteMethod('delete', {
description: 'Delete sale trackings and item shelving sales',
accessType: 'READ',
accessType: 'WRITE',
accepts: [
{
arg: 'saleFk',
@ -10,21 +10,17 @@ module.exports = Self => {
description: 'The sale id'
},
{
arg: 'stateCode',
type: 'string'
}
],
returns: {
type: ['object'],
root: true
arg: 'stateCodes',
type: ['string']
},
],
http: {
path: `/delete`,
verb: 'POST'
}
});
Self.delete = async(saleFk, stateCode, options) => {
Self.delete = async(saleFk, stateCodes, options) => {
const models = Self.app.models;
const myOptions = {};
let tx;
@ -38,20 +34,24 @@ module.exports = Self => {
}
try {
if (stateCode === 'PREPARED') {
const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions);
for (let itemShelvingSale of itemShelvingSales)
await itemShelvingSale.destroy(myOptions);
}
const state = await models.State.findOne({
where: {code: stateCode}
const states = await models.State.find({
fields: ['id'],
where: {
code: {inq: stateCodes}
}
}, myOptions);
const stateIds = states.map(state => state.id);
const filter = {
where: {
saleFk: saleFk,
stateFk: state.id
stateFk: {inq: stateIds}
}
};
const saleTrackings = await models.SaleTracking.find(filter, myOptions);
@ -59,8 +59,6 @@ module.exports = Self => {
await saleTracking.destroy(myOptions);
if (tx) await tx.commit();
return true;
} catch (e) {
if (tx) await tx.rollback();
throw e;

View File

@ -0,0 +1,106 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('setPicked', {
description: 'Add the sales line of the item and set the tracking.',
accessType: 'WRITE',
accepts: [
{
arg: 'saleFk',
type: 'number',
required: true
},
{
arg: 'originalQuantity',
type: 'number',
required: true
},
{
arg: 'code',
type: 'string',
required: true
},
{
arg: 'isChecked',
type: 'boolean',
required: true
},
{
arg: 'buyFk',
type: 'number',
required: true
},
{
arg: 'isScanned',
type: 'boolean',
},
{
arg: 'quantity',
type: 'number',
required: true
},
{
arg: 'itemShelvingFk',
type: 'number',
required: true
}
],
http: {
path: `/setPicked`,
verb: 'POST'
}
});
Self.setPicked = async(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned, quantity, itemShelvingFk, options) => {
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
await models.ItemShelvingSale.create({
itemShelvingFk,
saleFk,
quantity,
userFk: userId
}, myOptions);
const itemShelving = await models.ItemShelving.findById(itemShelvingFk, null, myOptions);
await itemShelving.updateAttributes({visible: itemShelving.visible - quantity}, myOptions);
await Self.updateAll(
{saleFk},
{isChecked: true},
myOptions
);
await Self.updateTracking(ctx, saleFk, originalQuantity, code, isChecked, null, isScanned, myOptions);
try {
const {itemOriginalFk} = await models.Buy.findById(buyFk, {fields: ['itemOriginalFk']}, myOptions);
if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
} catch (e) {
throw new UserError('The sale cannot be tracked');
}
if (tx) await tx.commit();
} catch (e) {
if (e.message == 'The sale cannot be tracked') {
if (tx) tx.commit();
throw e;
}
if (tx) await tx.rollback();
throw new UserError('The line could not be marked');
}
};
};

View File

@ -11,13 +11,12 @@ describe('sale-tracking delete()', () => {
const saleTrackingsBefore = await models.SaleTracking.find(null, options);
const saleFk = 1;
const stateCode = 'PREPARED';
const result = await models.SaleTracking.delete(saleFk, stateCode, options);
const stateCode = ['PREPARED'];
await models.SaleTracking.delete(saleFk, stateCode, options);
const itemShelvingsAfter = await models.ItemShelvingSale.find(null, options);
const saleTrackingsAfter = await models.SaleTracking.find(null, options);
expect(result).toEqual(true);
expect(saleTrackingsAfter.length).toBeLessThan(saleTrackingsBefore.length);
expect(itemShelvingsAfter.length).toBeLessThan(itemShelvingsBefore.length);

View File

@ -0,0 +1,114 @@
const {models} = require('vn-loopback/server/server');
describe('saleTracking setPicked()', () => {
const saleFk = 1;
const originalQuantity = 10;
const code = 'PREPARED';
const isChecked = true;
const buyFk = 1;
const isScanned = false;
const quantity = 1;
const itemShelvingFk = 1;
beforeAll(async() => {
ctx = {
req: {
accessToken: {userId: 104},
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
it('should throw an error if the line was not able to be marked', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const code = 'FAKESTATE';
try {
await models.SaleTracking.setPicked(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
quantity,
itemShelvingFk,
options
);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('The line could not be marked');
await tx.rollback();
}
});
it('should throw an error if there are duplicate salebuys', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
try {
await models.SaleTracking.setPicked(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
quantity,
itemShelvingFk,
options
);
await models.SaleTracking.setPicked(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
quantity,
itemShelvingFk,
options
);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('The sale cannot be tracked');
await tx.rollback();
}
});
it('should add an itemShelvingSale and Modify a saleTracking', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
try {
const itemShelvingSaleBefore = await models.ItemShelvingSale.find({}, options);
await models.SaleTracking.setPicked(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
quantity,
itemShelvingFk,
options
);
const itemShelvingSaleAfter = await models.ItemShelvingSale.find({}, options);
const saleTracking = await models.SaleTracking.findOne({where: {saleFk, isChecked: false}}, options);
expect(itemShelvingSaleAfter.length).toEqual(itemShelvingSaleBefore.length + 1);
expect(saleTracking.isChecked).toBeFalse();
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});

View File

@ -0,0 +1,104 @@
const {models} = require('vn-loopback/server/server');
describe('saleTracking updateTracking()', () => {
const saleFk = 1;
const originalQuantity = 10;
const code = 'PREPARED';
const isChecked = true;
const buyFk = 1;
const isScanned = false;
beforeAll(async() => {
ctx = {
req: {
accessToken: {userId: 104},
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
it('should throw an error if the state does not exist', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const code = 'FAKESTATE';
try {
await models.SaleTracking.updateTracking(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
options
);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('this state does not exist');
await tx.rollback();
}
});
it('should add a new saleTracking and saleBuy', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
try {
const saleTrackingBefore = await models.SaleTracking.find(null, options);
const saleBuyBefore = await models.SaleBuy.find(null, options);
await models.SaleTracking.updateTracking(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
options
);
const saleTrackingAfter = await models.SaleTracking.find(null, options);
const saleBuyAfter = await models.SaleBuy.find(null, options);
expect(saleTrackingAfter.length).toEqual(saleTrackingBefore.length + 1);
expect(saleBuyAfter.length).toEqual(saleBuyBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should only update a saleTracking', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const saleFk = 2;
try {
const saleTrackingBefore = await models.SaleTracking.find(null, options);
await models.SaleTracking.updateTracking(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
options
);
const saleTrackingAfter = await models.SaleTracking.find(null, options);
expect(saleTrackingAfter.length).toEqual(saleTrackingBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -0,0 +1,110 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateTracking', {
description: 'Modify a saleTracking record and, if applicable, add a corresponding record in saleBuy.',
accessType: 'WRITE',
accepts: [
{
arg: 'saleFk',
type: 'number',
required: true
},
{
arg: 'originalQuantity',
type: 'number',
required: true
},
{
arg: 'code',
type: 'string',
required: true
},
{
arg: 'isChecked',
type: 'boolean',
required: true
},
{
arg: 'buyFk',
type: 'number',
required: true
},
{
arg: 'isScanned',
type: 'boolean',
},
],
http: {
path: `/updateTracking`,
verb: 'POST'
}
});
Self.updateTracking = async(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned = null, options) => {
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
const myOptions = {userId};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const state = await models.State.findOne({
where: {code},
}, myOptions);
if (!state) throw new UserError('this state does not exist');
const uniqueAttributes = {
saleFk,
workerFk: userId,
stateFk: state?.id,
};
const attributes = {
isChecked,
originalQuantity,
isScanned
};
const saleTracking = await models.SaleTracking.findOne({
where: uniqueAttributes,
}, myOptions);
if (!saleTracking) {
await models.SaleTracking.create({
...uniqueAttributes,
...attributes
}, myOptions);
} else {
await saleTracking.updateAttributes({
...attributes
}, myOptions);
}
let isBuy;
if (buyFk) {
isBuy = await models.Buy.findOne({
where: {
id: buyFk,
itemOriginalFk: {
neq: null
}
}
}, myOptions);
}
if (isBuy)
await models.SaleBuy.create({saleFk, buyFk}, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -0,0 +1,61 @@
module.exports = Self => {
Self.remoteMethodCtx('getFromSectorCollection', {
description: 'Get sales from sector collection',
accessType: 'READ',
accepts: [
{
arg: 'sectorCollectionFk',
type: 'number',
required: true,
},
{
arg: 'sectorFk',
type: 'number',
required: true
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getFromSectorCollection`,
verb: 'GET'
},
});
Self.getFromSectorCollection = async(ctx, sectorCollectionFk, sectorFk, options) => {
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
if (typeof options == 'object') Object.assign(myOptions, options);
const [sales] = await Self.rawSql('CALL sectorCollection_getSale(?)', [sectorCollectionFk], myOptions);
const itemShelvings = [];
for (let sale of sales) {
const [carros] = await Self.rawSql(
'CALL vn.itemPlacementSupplyStockGetTargetList(?, ?)',
[sale.itemFk, sectorFk],
myOptions
);
itemShelvings.push({
id: sale.ticketFk,
itemFk: sale.itemFk,
longName: sale.longName,
packingType: sale.itemPackingTypeFk,
subName: sale.subName,
quantity: sale.quantity,
saldo: sale.quantity,
trabajador: sale.workerCode,
idMovimiento: sale.saleFk,
salesPersonFk: sale.salesPersonFk,
picked: sale.pickedQuantity,
carros
});
}
return itemShelvings;
};
};

View File

@ -0,0 +1,23 @@
const {models} = require('vn-loopback/server/server');
describe('sale getFromSectorCollection()', () => {
const sectorCollectionFk = 1;
const sectorFk = 1;
beforeAll(async() => {
ctx = {
req: {
headers: {origin: 'http://localhost'},
accessToken: {userId: 40}
}
};
});
it('should find an item and a shelving', async() => {
const options = {};
const itemShelvings = await models.Sale.getFromSectorCollection(ctx, sectorCollectionFk, sectorFk, options);
expect(itemShelvings.length).toEqual(1);
expect(itemShelvings[0].carros.length).toEqual(1);
});
});

View File

@ -0,0 +1,56 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('addSaleByCode', {
description: 'Add a collection',
accessType: 'WRITE',
accepts: [
{
arg: 'barcode',
type: 'string',
required: true
}, {
arg: 'quantity',
type: 'number',
required: true
}, {
arg: 'ticketFk',
type: 'number',
required: true
}, {
arg: 'warehouseFk',
type: 'number',
required: true
},
],
http: {
path: `/addSaleByCode`,
verb: 'POST'
},
});
Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => {
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const [[item]] = await Self.rawSql('CALL vn.item_getInfo(?,?)', [barcode, warehouseFk], myOptions);
if (!item?.available) throw new UserError('We do not have availability for the selected item');
await Self.rawSql('CALL vn.collection_addItem(?, ?, ?)', [item.id, quantity, ticketFk], myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -79,6 +79,6 @@ module.exports = Self => {
ORDER BY s.ticketFk, s.created`, [id]);
const content = toCSV(sales);
return [content, 'text/csv', `inline; filename="doc-${id}.pdf"`];
return [content, 'text/csv', `inline; filename="doc-${id}.csv"`];
};
};

View File

@ -0,0 +1,39 @@
const {models} = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
describe('Ticket addSaleByCode()', () => {
const quantity = 3;
const ticketFk = 13;
const warehouseFk = 1;
beforeAll(async() => {
activeCtx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'},
__: value => value
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
});
it('should add a new sale', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const code = '1111111111';
const salesBefore = await models.Sale.find(null, options);
await models.Ticket.addSaleByCode(activeCtx, code, quantity, ticketFk, warehouseFk, options);
const salesAfter = await models.Sale.find(null, options);
expect(salesAfter.length).toEqual(salesBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -50,14 +50,17 @@ describe('ticket setDeleted()', () => {
return value;
};
const ticketId = 23;
await models.Ticket.setDeleted(ctx, ticketId, options);
const [sectorCollection] = await models.Ticket.rawSql(
const [sectorCollectionBefore] = await models.Ticket.rawSql(
`SELECT COUNT(*) numberRows
FROM vn.sectorCollection`, [], options);
expect(sectorCollection.numberRows).toEqual(0);
await models.Ticket.setDeleted(ctx, ticketId, options);
const [sectorCollectionAfter] = await models.Ticket.rawSql(
`SELECT COUNT(*) numberRows
FROM vn.sectorCollection`, [], options);
expect(sectorCollectionAfter.numberRows).toEqual(sectorCollectionBefore.numberRows - 1);
await tx.rollback();
} catch (e) {

View File

@ -65,6 +65,9 @@
"SaleTracking": {
"dataSource": "vn"
},
"SaleBuy": {
"dataSource": "vn"
},
"State": {
"dataSource": "vn"
},

View File

@ -1,5 +1,6 @@
{
"name": "ExpeditionPallet",
"base": "VnModel",
"options": {
"mysql": {
"table": "expeditionPallet"
@ -10,13 +11,24 @@
"type": "number",
"id": true,
"description": "Identifier"
},
"built": {
"type": "date"
},
"position": {
"type": "number"
},
"isPrint": {
"type": "number"
}
},
"acls": [{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "production",
"permission": "ALLOW"
}]
"relations": {
"expeditionTruck": {
"type": "belongsTo",
"model": "ExpeditionTruck",
"foreignKey": "truckFk"
}
}
}

View File

@ -0,0 +1,34 @@
{
"name": "SaleBuy",
"base": "VnModel",
"options": {
"mysql": {
"table": "saleBuy"
}
},
"properties": {
"saleFk": {
"id": true,
"type": "number"
},
"buyFk": {
"type": "number"
},
"created": {
"type": "date"
}
},
"relations": {
"sale": {
"type": "belongsTo",
"model": "Sale",
"foreignKey": "saleFk"
},
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
}
}
}

View File

@ -3,4 +3,6 @@ module.exports = Self => {
require('../methods/sale-tracking/listSaleTracking')(Self);
require('../methods/sale-tracking/new')(Self);
require('../methods/sale-tracking/delete')(Self);
require('../methods/sale-tracking/updateTracking')(Self);
require('../methods/sale-tracking/setPicked')(Self);
};

View File

@ -26,6 +26,9 @@
},
"originalQuantity": {
"type": "number"
},
"isScanned": {
"type": "number"
}
},
"relations": {

View File

@ -12,6 +12,7 @@ module.exports = Self => {
require('../methods/sale/canEdit')(Self);
require('../methods/sale/usesMana')(Self);
require('../methods/sale/clone')(Self);
require('../methods/sale/getFromSectorCollection')(Self);
Self.validatesPresenceOf('concept', {
message: `Concept cannot be blank`

View File

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

View File

@ -100,7 +100,7 @@ class Controller extends Section {
saleTrackingDel(sale, stateCode) {
const params = {
saleFk: sale.saleFk,
stateCode: stateCode
stateCodes: [stateCode]
};
this.$http.post(`SaleTrackings/delete`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));

View File

@ -53,6 +53,9 @@
"Time": {
"dataSource": "vn"
},
"WorkerAppTester": {
"dataSource": "vn"
},
"WorkCenter": {
"dataSource": "vn"
},

View File

@ -1,4 +1,4 @@
module.exports = function(Self) {
module.exports = Self => {
Self.observe('after save', async function(ctx) {
const instance = ctx.data || ctx.instance;
const models = Self.app.models;

View File

@ -43,6 +43,12 @@
"type": "belongsTo",
"model": "Printer",
"foreignKey": "labelerFk"
},
"itemPackingType": {
"type": "belongsTo",
"model": "ItemPackingType",
"foreignKey": "itemPackingTypeFk",
"primaryKey": "code"
}
}
}

View File

@ -0,0 +1,22 @@
{
"name": "WorkerAppTester",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.workerAppTester"
}
},
"properties": {
"workerFk": {
"id": true,
"type": "number"
}
},
"relations": {
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
}
}
}

View File

@ -22,6 +22,7 @@
"log4js": "^6.7.0",
"mysql2": "^1.7.0",
"nodemailer": "^4.7.0",
"puppeteer": "^22.4.0",
"puppeteer-cluster": "^0.23.0",
"qrcode": "^1.4.2",
"strftime": "^0.10.0",

View File

@ -32,9 +32,12 @@ dependencies:
nodemailer:
specifier: ^4.7.0
version: 4.7.0
puppeteer:
specifier: ^22.4.0
version: 22.4.0
puppeteer-cluster:
specifier: ^0.23.0
version: 0.23.0(puppeteer@21.10.0)
version: 0.23.0(puppeteer@22.4.0)
qrcode:
specifier: ^1.4.2
version: 1.5.3
@ -100,16 +103,17 @@ packages:
to-fast-properties: 2.0.0
dev: false
/@puppeteer/browsers@1.9.1:
resolution: {integrity: sha512-PuvK6xZzGhKPvlx3fpfdM2kYY3P/hB1URtK8wA7XUJ6prn6pp22zvJHu48th0SGcHL9SutbPHrFuQgfXTFobWA==}
engines: {node: '>=16.3.0'}
/@puppeteer/browsers@2.1.0:
resolution: {integrity: sha512-xloWvocjvryHdUjDam/ZuGMh7zn4Sn3ZAaV4Ah2e2EwEt90N3XphZlSsU3n0VDc1F7kggCjMuH0UuxfPQ5mD9w==}
engines: {node: '>=18'}
hasBin: true
dependencies:
debug: 4.3.4
extract-zip: 2.0.1
progress: 2.0.3
proxy-agent: 6.3.1
tar-fs: 3.0.4
proxy-agent: 6.4.0
semver: 7.6.0
tar-fs: 3.0.5
unbzip2-stream: 1.4.3
yargs: 17.7.2
transitivePeerDependencies:
@ -243,6 +247,37 @@ packages:
resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==}
dev: false
/bare-events@2.2.1:
resolution: {integrity: sha512-9GYPpsPFvrWBkelIhOhTWtkeZxVxZOdb3VnFTCzlOo3OjvmTvzLoZFUT8kNFACx0vJej6QPney1Cf9BvzCNE/A==}
requiresBuild: true
dev: false
optional: true
/bare-fs@2.2.1:
resolution: {integrity: sha512-+CjmZANQDFZWy4PGbVdmALIwmt33aJg8qTkVjClU6X4WmZkTPBDxRHiBn7fpqEWEfF3AC2io++erpViAIQbSjg==}
requiresBuild: true
dependencies:
bare-events: 2.2.1
bare-os: 2.2.0
bare-path: 2.1.0
streamx: 2.15.6
dev: false
optional: true
/bare-os@2.2.0:
resolution: {integrity: sha512-hD0rOPfYWOMpVirTACt4/nK8mC55La12K5fY1ij8HAdfQakD62M+H4o4tpfKzVGLgRDTuk3vjA4GqGXXCeFbag==}
requiresBuild: true
dev: false
optional: true
/bare-path@2.1.0:
resolution: {integrity: sha512-DIIg7ts8bdRKwJRJrUMy/PICEaQZaPGZ26lsSx9MJSwIhSrcdHn7/C8W+XmnG/rKi6BaRcz+JO00CjZteybDtw==}
requiresBuild: true
dependencies:
bare-os: 2.2.0
dev: false
optional: true
/base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
dev: false
@ -326,12 +361,12 @@ packages:
lodash.some: 4.6.0
dev: false
/chromium-bidi@0.5.6(devtools-protocol@0.0.1232444):
resolution: {integrity: sha512-ber8smgoAs4EqSUHRb0I8fpx371ZmvsdQav8HRM9oO4fk5Ox16vQiNYXlsZkRj4FfvVL2dCef+zBFQixp+79CA==}
/chromium-bidi@0.5.12(devtools-protocol@0.0.1249869):
resolution: {integrity: sha512-sZMgEBWKbupD0Q7lyFu8AWkrE+rs5ycE12jFkGwIgD/VS8lDPtelPlXM7LYaq4zrkZ/O2L3f4afHUHL0ICdKog==}
peerDependencies:
devtools-protocol: '*'
dependencies:
devtools-protocol: 0.0.1232444
devtools-protocol: 0.0.1249869
mitt: 3.0.1
urlpattern-polyfill: 10.0.0
dev: false
@ -545,8 +580,8 @@ packages:
resolution: {integrity: sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==}
dev: false
/devtools-protocol@0.0.1232444:
resolution: {integrity: sha512-pM27vqEfxSxRkTMnF+XCmxSEb6duO5R+t8A9DEEJgy4Wz2RVanje2mmj99B6A3zv2r/qGfYlOvYznUhuokizmg==}
/devtools-protocol@0.0.1249869:
resolution: {integrity: sha512-Ctp4hInA0BEavlUoRy9mhGq0i+JSo/AwVyX2EFgZmV1kYB+Zq+EMBAn52QWu6FbRr10hRb6pBl420upbp4++vg==}
dev: false
/dijkstrajs@1.0.3:
@ -968,8 +1003,8 @@ packages:
statuses: 1.3.1
dev: false
/http-proxy-agent@7.0.0:
resolution: {integrity: sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==}
/http-proxy-agent@7.0.2:
resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==}
engines: {node: '>= 14'}
dependencies:
agent-base: 7.1.0
@ -987,8 +1022,8 @@ packages:
sshpk: 1.18.0
dev: false
/https-proxy-agent@7.0.2:
resolution: {integrity: sha512-NmLNjm6ucYwtcUmL7JQC1ZQ57LmHP4lT15FQ8D61nak1rO6DH+fz5qNK2Ap5UN4ZapYICE3/0KodcLYSPsPbaA==}
/https-proxy-agent@7.0.4:
resolution: {integrity: sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==}
engines: {node: '>= 14'}
dependencies:
agent-base: 7.1.0
@ -1258,6 +1293,13 @@ packages:
yallist: 3.1.1
dev: false
/lru-cache@6.0.0:
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
engines: {node: '>=10'}
dependencies:
yallist: 4.0.0
dev: false
/lru-cache@7.18.3:
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
engines: {node: '>=12'}
@ -1308,10 +1350,6 @@ packages:
resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==}
dev: false
/mkdirp-classic@0.5.3:
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
dev: false
/ms@0.7.1:
resolution: {integrity: sha512-lRLiIR9fSNpnP6TC4v8+4OU7oStC01esuNowdQ34L+Gk8e5Puoc88IqJ+XAY/B3Mn2ZKis8l8HX90oU8ivzUHg==}
dev: false
@ -1432,8 +1470,8 @@ packages:
agent-base: 7.1.0
debug: 4.3.4
get-uri: 6.0.2
http-proxy-agent: 7.0.0
https-proxy-agent: 7.0.2
http-proxy-agent: 7.0.2
https-proxy-agent: 7.0.4
pac-resolver: 7.0.0
socks-proxy-agent: 8.0.2
transitivePeerDependencies:
@ -1536,14 +1574,14 @@ packages:
ipaddr.js: 1.4.0
dev: false
/proxy-agent@6.3.1:
resolution: {integrity: sha512-Rb5RVBy1iyqOtNl15Cw/llpeLH8bsb37gM1FUfKQ+Wck6xHlbAhWGUFiTRHtkjqGTA5pSHz6+0hrPW/oECihPQ==}
/proxy-agent@6.4.0:
resolution: {integrity: sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==}
engines: {node: '>= 14'}
dependencies:
agent-base: 7.1.0
debug: 4.3.4
http-proxy-agent: 7.0.0
https-proxy-agent: 7.0.2
http-proxy-agent: 7.0.2
https-proxy-agent: 7.0.4
lru-cache: 7.18.3
pac-proxy-agent: 7.0.1
proxy-from-env: 1.1.0
@ -1572,26 +1610,26 @@ packages:
engines: {node: '>=6'}
dev: false
/puppeteer-cluster@0.23.0(puppeteer@21.10.0):
/puppeteer-cluster@0.23.0(puppeteer@22.4.0):
resolution: {integrity: sha512-108terIWDzPrQopmoYSPd5yDoy3FGJ2dNnoGMkGYPs6xtkdhgaECwpfZkzaRToMQPZibUOz0/dSSGgPEdXEhkQ==}
peerDependencies:
puppeteer: '>=1.5.0'
dependencies:
debug: 4.3.4
puppeteer: 21.10.0
puppeteer: 22.4.0
transitivePeerDependencies:
- supports-color
dev: false
/puppeteer-core@21.10.0:
resolution: {integrity: sha512-NVaqO3K462qwMuLO4Gurs/Mau1Wss+08QgNYzF0dIqZWMvpskrt/TbxbmHU+7zMTUOvPEq/lR4BLJmjMBgBGfQ==}
engines: {node: '>=16.13.2'}
/puppeteer-core@22.4.0:
resolution: {integrity: sha512-MZttAbttrxi6O/B//rY6zQihjFe/vXeCLb5YvKH2xG6yrcVESo0Hc5/Cv49omwZyZzAJ1BK8BnDeatDsj+3hMw==}
engines: {node: '>=18'}
dependencies:
'@puppeteer/browsers': 1.9.1
chromium-bidi: 0.5.6(devtools-protocol@0.0.1232444)
'@puppeteer/browsers': 2.1.0
chromium-bidi: 0.5.12(devtools-protocol@0.0.1249869)
cross-fetch: 4.0.0
debug: 4.3.4
devtools-protocol: 0.0.1232444
devtools-protocol: 0.0.1249869
ws: 8.16.0
transitivePeerDependencies:
- bufferutil
@ -1600,15 +1638,15 @@ packages:
- utf-8-validate
dev: false
/puppeteer@21.10.0:
resolution: {integrity: sha512-Y1yQjcLE00hHTDAmv3M3A6hhW0Ytjdp6xr6nyjl7FZ7E7hzp/6Rsw80FbaTJzJHFCplBNi082wrgynbmD7RlYw==}
engines: {node: '>=16.13.2'}
/puppeteer@22.4.0:
resolution: {integrity: sha512-tR+JsDbA2qD1DqRX4F9k9SxQhk6UzcaCN+Qux7+WrDceS7wcR7tlFmMNB8+g8zE4Fmr/iRTOtf5wNnTW9cGUFQ==}
engines: {node: '>=18'}
hasBin: true
requiresBuild: true
dependencies:
'@puppeteer/browsers': 1.9.1
'@puppeteer/browsers': 2.1.0
cosmiconfig: 9.0.0
puppeteer-core: 21.10.0
puppeteer-core: 22.4.0
transitivePeerDependencies:
- bufferutil
- encoding
@ -1640,6 +1678,7 @@ packages:
/queue-tick@1.0.1:
resolution: {integrity: sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==}
requiresBuild: true
dev: false
/randombytes@2.1.0:
@ -1729,6 +1768,14 @@ packages:
hasBin: true
dev: false
/semver@7.6.0:
resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==}
engines: {node: '>=10'}
hasBin: true
dependencies:
lru-cache: 6.0.0
dev: false
/send@0.14.1:
resolution: {integrity: sha512-1Ru269QpUVUgD32Y9jdyBXiX+pHYuYnTzR17w+DhyOWvGMPjJILrnLhl9c4LQjtIy2BSAa6Ykq0ZdGcAjaXlwQ==}
engines: {node: '>= 0.8.0'}
@ -1950,12 +1997,14 @@ packages:
engines: {node: '>= 0.4'}
dev: false
/tar-fs@3.0.4:
resolution: {integrity: sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==}
/tar-fs@3.0.5:
resolution: {integrity: sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==}
dependencies:
mkdirp-classic: 0.5.3
pump: 3.0.0
tar-stream: 3.1.7
optionalDependencies:
bare-fs: 2.2.1
bare-path: 2.1.0
dev: false
/tar-stream@3.1.7:
@ -2200,6 +2249,10 @@ packages:
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
dev: false
/yallist@4.0.0:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
dev: false
/yargs-parser@18.1.3:
resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}
engines: {node: '>=6'}

View File

@ -40,17 +40,6 @@ table.repeatable > tbody > tr > td {
padding-top: 0.5em;
}
section.text-area {
margin-top: 1em;
padding: 0.19em;
padding-left: 1em;
padding-right: 1em;
background-color: #e5e5e5;
& > p {
word-break: break-all;
}
}
.route-block {
margin-bottom: 100px;
page-break-after: always;

View File

@ -128,8 +128,8 @@
</tr>
</tbody>
</table>
<div v-if="ticket.description" class="text-area">
<p>{{ticket.description}}</p>
<div v-if="ticket.description">
<p style="word-break: break-all">{{ticket.description}}</p>
</div>
</div>
</div>

View File

@ -1,4 +1,5 @@
const vnReport = require('../../../core/mixins/vn-report.js');
const UserError = require('vn-loopback/util/user-error');
module.exports = {
name: 'invoice-incoterms',
@ -7,7 +8,10 @@ module.exports = {
this.invoice = await this.findOneFromDef('invoice', [this.reference]);
this.checkMainEntity(this.invoice);
this.client = await this.findOneFromDef('client', [this.reference]);
this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
this.incoterms =
await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
if (!this.incoterms)
throw new UserError(`The address of the customer must have information about Incoterms and Customs Agent`);
},
props: {
reference: {