#6276 createNewWarehouse methods migrated from silex to salix #1850

Merged
jorgep merged 158 commits from 6276-createNewWarehouse into dev 2024-03-06 11:32:11 +00:00
5 changed files with 57 additions and 9 deletions
Showing only changes of commit efb8bc46c6 - Show all commits

View File

@ -211,7 +211,6 @@
"You are already using a machine": "You are already using a machine",
"This worker does not exist": "This worker does not exist",
"this state does not exist": "This state does not exist",
"The line could not be marked": "The line could not be marked"
"The line could not be marked": "The line could not be marked",
"The sale can not be tracked": "The sale can not be tracked"
}

View File

@ -348,5 +348,6 @@
"this state does not exist": "Este estado no existe",
"Este estado no existe": "Este estado no existe",
"The line could not be marked": "No se ha podido marcar la línea",
"No se ha podido marcar la línea": "No se ha podido marcar la línea"
"No se ha podido marcar la línea": "No se ha podido marcar la línea",
"The sale can not be tracked": "La línea no puede ser rastreada"
}

View File

@ -89,10 +89,17 @@ module.exports = Self => {
try {
const buy = await models.Buy.findById(buyFk, myOptions);
if (buy.itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
} catch (e) {}
} catch (e) {
throw new UserError($t('The sale can not be tracked'));
}
if (tx) await tx.commit();
} catch (e) {
if (e.message == $t('The sale can not be tracked')) {
if (tx) tx.commit();
throw e;
}
if (tx) await tx.rollback();
throw new UserError($t('The line could not be marked'));
}

View File

@ -1,5 +1,5 @@
const {models} = require('vn-loopback/server/server');
describe('saleTracking mark()', () => {
fdescribe('saleTracking mark()', () => {
const saleFk = 1;
const originalQuantity = 10;
const code = 'PREPARED';
@ -46,6 +46,44 @@ describe('saleTracking mark()', () => {
}
});
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.mark(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
quantity,
itemShelvingFk,
options
);
await models.SaleTracking.mark(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
quantity,
itemShelvingFk,
options
);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('The sale can not 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};

View File

@ -30,7 +30,9 @@ module.exports = Self => {
if (typeof options == 'object') Object.assign(myOptions, options);
const sales = await Self.rawSql(
const sales = await Self.rawSql('CALL sectorCollection_getSale(?)', [sectorCollectionFk], myOptions);
/* const sales = await Self.rawSql(
`SELECT s.ticketFk,
s.itemFk,
i.longName,
@ -52,13 +54,14 @@ module.exports = Self => {
JOIN client c ON c.id=t.clientFk
LEFT JOIN itemShelvingSaleSum iss ON iss.saleFk = s.id
WHERE scsg.sectorCollectionFk = ?
AND st.workerFk = ?;`, [sectorCollectionFk, userId]);
AND st.workerFk = ?;`, [sectorCollectionFk, userId]); */
const itemShelvings = [];
for (let sale of sales) {
const [carros] = await Self.rawSql(
'CALL vn.itemPlacementSupplyStockGetTargetList(?, ?)',
[sale.itemFk, sectorFk]
[sale.itemFk, sectorFk],
myOptions
);
itemShelvings.push({