word movible
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
57e4b400c9
commit
f8a0094321
|
@ -1,15 +1,15 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_getAdvanceable`;
|
||||
DROP PROCEDURE IF EXISTS `vn`.`ticket_getMovable`;
|
||||
|
||||
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
|
||||
/**
|
||||
* 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 vDatedNew -> Nueva fecha
|
||||
* @return Sales con Avanzable
|
||||
* @return Sales con Movible
|
||||
*/
|
||||
DECLARE vDatedOld DATETIME;
|
||||
|
||||
|
@ -29,7 +29,7 @@ BEGIN
|
|||
s.discount,
|
||||
i.image,
|
||||
i.subName,
|
||||
il.stock + IFNULL(im.amount, 0) AS advanceable
|
||||
il.stock + IFNULL(im.amount, 0) AS movable
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
|
|
|
@ -134,11 +134,11 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
if (args.isWithoutNegatives) {
|
||||
const query = `CALL ticket_getAdvanceable(?,?,?)`;
|
||||
const query = `CALL ticket_getMovable(?,?,?)`;
|
||||
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) {
|
||||
const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions);
|
||||
args.id = newTicket.id;
|
||||
|
|
|
@ -110,14 +110,14 @@ module.exports = Self => {
|
|||
totalDifference: 0.00,
|
||||
};
|
||||
|
||||
// Get items advanceable
|
||||
let query = `CALL ticket_getAdvanceable(?,?,?)`;
|
||||
// Get items movable
|
||||
let query = `CALL ticket_getMovable(?,?,?)`;
|
||||
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();
|
||||
for (sale of salesAdvanceable)
|
||||
itemAdvanceable.set(sale.id, sale.advanceable ?? 0);
|
||||
const itemMovable = new Map();
|
||||
for (sale of salesMovable)
|
||||
itemMovable.set(sale.id, sale.movable ?? 0);
|
||||
|
||||
// Sale price component, one per sale
|
||||
query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`;
|
||||
|
@ -142,7 +142,7 @@ module.exports = Self => {
|
|||
|
||||
salesObj.totalUnitPrice += sale.price;
|
||||
salesObj.totalUnitPrice = round(salesObj.totalUnitPrice);
|
||||
sale.advanceable = itemAdvanceable.get(sale.id);
|
||||
sale.movable = itemMovable.get(sale.id);
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -60,7 +60,7 @@ describe('sale priceDifference()', () => {
|
|||
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({});
|
||||
|
||||
try {
|
||||
|
@ -83,8 +83,8 @@ describe('sale priceDifference()', () => {
|
|||
const firstItem = result.items[0];
|
||||
const secondtItem = result.items[1];
|
||||
|
||||
expect(firstItem.advanceable).toEqual(440);
|
||||
expect(secondtItem.advanceable).toEqual(1980);
|
||||
expect(firstItem.movable).toEqual(440);
|
||||
expect(secondtItem.movable).toEqual(1980);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<vn-tr>
|
||||
<vn-th number>Item</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>Price (PPU)</vn-th>
|
||||
<vn-th number>New (PPU)</vn-th>
|
||||
|
@ -35,8 +35,8 @@
|
|||
<vn-td number>
|
||||
<span
|
||||
class="chip"
|
||||
ng-class="{'alert': sale.quantity>sale.advanceable}">
|
||||
{{::sale.advanceable}}
|
||||
ng-class="{'alert': sale.quantity>sale.movable}">
|
||||
{{::sale.movable}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
||||
|
|
|
@ -69,7 +69,7 @@ class Controller extends Component {
|
|||
let haveNotNegatives = false;
|
||||
|
||||
this.ticket.sale.items.forEach(item => {
|
||||
if (item.quantity > item.advanceable)
|
||||
if (item.quantity > item.movable)
|
||||
haveNegatives = true;
|
||||
else
|
||||
haveNotNegatives = true;
|
||||
|
|
|
@ -73,12 +73,12 @@ describe('Ticket', () => {
|
|||
{
|
||||
item: 1,
|
||||
quantity: 2,
|
||||
advanceable: 1
|
||||
movable: 1
|
||||
},
|
||||
{
|
||||
item: 2,
|
||||
quantity: 1,
|
||||
advanceable: 5
|
||||
movable: 5
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -8,4 +8,4 @@ New price: Nuevo precio
|
|||
Price difference: Diferencia de precio
|
||||
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.
|
||||
Advanceable: Avanzable
|
||||
Movable: Movible
|
Loading…
Reference in New Issue