feat: refs #7404 fixtures and translates
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Pablo Natek 2024-09-16 09:00:46 +02:00
parent 8607a60ca7
commit cc1cd0563f
3 changed files with 32 additions and 22 deletions

View File

@ -183,7 +183,7 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0), (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0),
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1), (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1),
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
(6, 'Warehouse six', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), (6, 'Warehouse six', 'VNH', 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0), (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0); (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0);

View File

@ -235,5 +235,6 @@
"Cannot add holidays on this day": "Cannot add holidays on this day", "Cannot add holidays on this day": "Cannot add holidays on this day",
"Cannot send mail": "Cannot send mail", "Cannot send mail": "Cannot send mail",
"CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`",
"This postcode already exists": "This postcode already exists" "This postcode already exists": "This postcode already exists",
"This buyer has already made a reservation for this date": "This buyer has already made a reservation for this date"
} }

View File

@ -3,6 +3,11 @@ module.exports = Self => {
description: 'Returns the stock bought for a given date', description: 'Returns the stock bought for a given date',
accessType: 'READ', accessType: 'READ',
accepts: [{ accepts: [{
arg: 'workerFk',
type: 'number',
description: 'The id for a buyer',
},
{
arg: 'dated', arg: 'dated',
type: 'date', type: 'date',
description: 'The date to filter', description: 'The date to filter',
@ -18,7 +23,7 @@ module.exports = Self => {
} }
}); });
Self.getStockBought = async(dated = Date.vnNew()) => { Self.getStockBought = async(workerFk, dated = Date.vnNew()) => {
const models = Self.app.models; const models = Self.app.models;
const today = Date.vnNew(); const today = Date.vnNew();
dated.setHours(0, 0, 0, 0); dated.setHours(0, 0, 0, 0);
@ -27,26 +32,30 @@ module.exports = Self => {
if (dated.getTime() === today.getTime()) if (dated.getTime() === today.getTime())
await models.StockBought.rawSql(`CALL vn.stockBought_calculate()`); await models.StockBought.rawSql(`CALL vn.stockBought_calculate()`);
return models.StockBought.find( const filter = {
{ where: {
where: { dated: dated
dated: dated },
}, include: [
include: [ {
{ relation: 'worker',
relation: 'worker', scope: {
scope: { include: [
include: [ {
{ relation: 'user',
relation: 'user', scope: {
scope: { fields: ['id', 'name']
fields: ['id', 'name']
}
} }
] }
} ]
} }
] }
}); ]
};
if (workerFk) filter.where.workerFk = workerFk;
console.log('workerFk: ', workerFk);
return models.StockBought.find(filter);
}; };
}; };