Thursday, 3 March 2016

Auto Reserve using x++ code

static void autoReserve(Args _args)
{
    InventUpd_Reservation   reservation;
    SalesLine               salesLine = SalesLine::findInventTransId('013371');
    InventMovement          movement = InventMovement::construct(salesLine);

    InventQty               reserveQuantity = salesLine.QtyOrdered - abs(movement.transIdSum().reserved());

    if (reserveQuantity > 0)
    {
        reservation = InventUpd_Reservation::newMovement(
                                        movement,
                                        -reserveQuantity,
                                        true /*mayBeReduced */);

        reservation.updateNow();
    }
}

No comments:

Post a Comment