Example #1
0
        public ShipmentScript(
            IMapper <ShipmentFacts, Shipment> shipmentMapper,
            IMapper <Shipment, Transaction> transactionMapper)
        {
            ExecutionHelpers.ThrowIfNull(() => shipmentMapper, "Shipment Mapper cannot be null");
            ExecutionHelpers.ThrowIfNull(() => transactionMapper, "Transaction Mapper cannot be null");

            ShipmentMapper    = shipmentMapper;
            TransactionMapper = transactionMapper;
        }
        public bool Undo(RepairComponent rc, Transaction transaction)
        {
            var part = m_repo.Get <Part>(p => p.Id == transaction.Part.Id);
            var sfl  = m_repo.Get <Shopfloorline>(s => s.Label == transaction.DepartLocation);

            var transType = new AdjustmentTransactionType("MATLUNDO", "Service part consumption reversed", "IN");

            ExecutionHelpers.ThrowIfNull(() => rc, "Cannot find repair record for this transaction.");

            rc.ConsumptionId = default(int);

            return(MaterialService.AdjustMaterialConsumableItem
                       (part, sfl, transaction.Qty, "Service part consumption reversed.", transType, null));
        }
        public MaterialConsumableItem DecreaseItemQty(Part part, Shopfloorline sfl, int qty)
        {
            MaterialConsumableItem item = null;
            Expression <Func <MaterialConsumableItem, bool> > criteria =
                mci => mci.Part.Id == part.Id && mci.Shopfloorline.Id == sfl.Id && mci.Qty > 0;

            ExecutionHelpers.ThrowIfNull(
                () => item = m_repository.Get(criteria),
                "Consumable item not found"
                );

            item.DecreaseQty(qty);

            return(item);
        }