word movible
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-01-26 08:54:48 +01:00
parent 57e4b400c9
commit f8a0094321
8 changed files with 25 additions and 25 deletions

View File

@ -1,15 +1,15 @@
DROP PROCEDURE IF EXISTS `vn`.`ticket_getAdvanceable`; DROP PROCEDURE IF EXISTS `vn`.`ticket_getMovable`;
DELIMITER $$ DELIMITER $$
$$ $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticket_getAdvanceable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT) CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT)
BEGIN BEGIN
/** /**
* Cálcula el stock avanzable para los artículos de un ticket * Cálcula el stock movible para los artículos de un ticket
* *
* @param vTicketFk -> Ticket * @param vTicketFk -> Ticket
* @param vDatedNew -> Nueva fecha * @param vDatedNew -> Nueva fecha
* @return Sales con Avanzable * @return Sales con Movible
*/ */
DECLARE vDatedOld DATETIME; DECLARE vDatedOld DATETIME;
@ -29,7 +29,7 @@ BEGIN
s.discount, s.discount,
i.image, i.image,
i.subName, i.subName,
il.stock + IFNULL(im.amount, 0) AS advanceable il.stock + IFNULL(im.amount, 0) AS movable
FROM ticket t FROM ticket t
JOIN sale s ON s.ticketFk = t.id JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk

View File

@ -134,11 +134,11 @@ module.exports = Self => {
} }
if (args.isWithoutNegatives) { if (args.isWithoutNegatives) {
const query = `CALL ticket_getAdvanceable(?,?,?)`; const query = `CALL ticket_getMovable(?,?,?)`;
const params = [args.id, args.shipped, args.warehouseFk]; const params = [args.id, args.shipped, args.warehouseFk];
const [salesAdvanceable] = await Self.rawSql(query, params, myOptions); const [salesMovable] = await Self.rawSql(query, params, myOptions);
const salesNewTicket = salesAdvanceable.filter(sale => (sale.advanceable ?? 0) >= sale.quantity); const salesNewTicket = salesMovable.filter(sale => (sale.movable ?? 0) >= sale.quantity);
if (salesNewTicket.length) { if (salesNewTicket.length) {
const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions); const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions);
args.id = newTicket.id; args.id = newTicket.id;

View File

@ -110,14 +110,14 @@ module.exports = Self => {
totalDifference: 0.00, totalDifference: 0.00,
}; };
// Get items advanceable // Get items movable
let query = `CALL ticket_getAdvanceable(?,?,?)`; let query = `CALL ticket_getMovable(?,?,?)`;
let params = [args.id, args.shipped, args.warehouseId]; let params = [args.id, args.shipped, args.warehouseId];
const [salesAdvanceable] = await Self.rawSql(query, params, myOptions); const [salesMovable] = await Self.rawSql(query, params, myOptions);
const itemAdvanceable = new Map(); const itemMovable = new Map();
for (sale of salesAdvanceable) for (sale of salesMovable)
itemAdvanceable.set(sale.id, sale.advanceable ?? 0); itemMovable.set(sale.id, sale.movable ?? 0);
// Sale price component, one per sale // Sale price component, one per sale
query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`; query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`;
@ -142,7 +142,7 @@ module.exports = Self => {
salesObj.totalUnitPrice += sale.price; salesObj.totalUnitPrice += sale.price;
salesObj.totalUnitPrice = round(salesObj.totalUnitPrice); salesObj.totalUnitPrice = round(salesObj.totalUnitPrice);
sale.advanceable = itemAdvanceable.get(sale.id); sale.movable = itemMovable.get(sale.id);
} }
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -60,7 +60,7 @@ describe('sale priceDifference()', () => {
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`)); expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
}); });
it('should return ticket advanceable', async() => { it('should return ticket movable', async() => {
const tx = await models.Ticket.beginTransaction({}); const tx = await models.Ticket.beginTransaction({});
try { try {
@ -83,8 +83,8 @@ describe('sale priceDifference()', () => {
const firstItem = result.items[0]; const firstItem = result.items[0];
const secondtItem = result.items[1]; const secondtItem = result.items[1];
expect(firstItem.advanceable).toEqual(440); expect(firstItem.movable).toEqual(440);
expect(secondtItem.advanceable).toEqual(1980); expect(secondtItem.movable).toEqual(1980);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -9,7 +9,7 @@
<vn-tr> <vn-tr>
<vn-th number>Item</vn-th> <vn-th number>Item</vn-th>
<vn-th class="align-center">Description</vn-th> <vn-th class="align-center">Description</vn-th>
<vn-th number>Advanceable</vn-th> <vn-th number>Movable</vn-th>
<vn-th number>Quantity</vn-th> <vn-th number>Quantity</vn-th>
<vn-th number>Price (PPU)</vn-th> <vn-th number>Price (PPU)</vn-th>
<vn-th number>New (PPU)</vn-th> <vn-th number>New (PPU)</vn-th>
@ -35,8 +35,8 @@
<vn-td number> <vn-td number>
<span <span
class="chip" class="chip"
ng-class="{'alert': sale.quantity>sale.advanceable}"> ng-class="{'alert': sale.quantity>sale.movable}">
{{::sale.advanceable}} {{::sale.movable}}
</span> </span>
</vn-td> </vn-td>
<vn-td number>{{::sale.quantity}}</vn-td> <vn-td number>{{::sale.quantity}}</vn-td>

View File

@ -69,7 +69,7 @@ class Controller extends Component {
let haveNotNegatives = false; let haveNotNegatives = false;
this.ticket.sale.items.forEach(item => { this.ticket.sale.items.forEach(item => {
if (item.quantity > item.advanceable) if (item.quantity > item.movable)
haveNegatives = true; haveNegatives = true;
else else
haveNotNegatives = true; haveNotNegatives = true;

View File

@ -73,12 +73,12 @@ describe('Ticket', () => {
{ {
item: 1, item: 1,
quantity: 2, quantity: 2,
advanceable: 1 movable: 1
}, },
{ {
item: 2, item: 2,
quantity: 1, quantity: 1,
advanceable: 5 movable: 5
} }
] ]
} }

View File

@ -8,4 +8,4 @@ New price: Nuevo precio
Price difference: Diferencia de precio Price difference: Diferencia de precio
Without create negatives: Sin crear negativos Without create negatives: Sin crear negativos
Clone this ticket with the changes and only sales availables: Clona este ticket con los cambios y solo las ventas disponibles. Clone this ticket with the changes and only sales availables: Clona este ticket con los cambios y solo las ventas disponibles.
Advanceable: Avanzable Movable: Movible