예제 #1
0
        public void can_get_all_inventory_adjustment_transaction_types()
        {
            var sut = AdjustmentTransactionType.AsList();

            Assert.That(sut.Where(a => a.Direction == "IN").Count() > 0,
                        "Unable to get adjustment types with IN direction!");

            Assert.That(sut.Where(a => a.Direction == "OUT").Count() > 0,
                        "Unable to get adjustment types with OUT direction!");
        }
        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));
        }
예제 #3
0
        private void LoadSourceTypes()
        {
            var sourceTypes = Scout.Core.Service <IInventoryService>()
                              .GetAllAdjustmentTransactionTypes()
                              .Where(s => s.Direction == "IN" && !s.Code.Contains("PARTS")).ToList();

            var poSource = new AdjustmentTransactionType("PURREC", "Purchase Order", "IN");

            sourceTypes.Add(poSource);

            sourceTypeLookup.Properties.ValueMember   = "Code";
            sourceTypeLookup.Properties.DisplayMember = "Description";
            sourceTypeLookup.Properties.DataSource    = sourceTypes;

            if (string.IsNullOrEmpty(m_po.SourceType))
            {
                m_po.SourceType = poSource.Code;
            }
        }
예제 #4
0
        private static void WriteQtyAdjustmentTransaction(IMaterialItem item, int adjustmentQty, string comments, AdjustmentTransactionType sourceType)
        {
            if (item == null)
            {
                return;
            }

            string itemLocation = "";

            if (item is MaterialWarehouseItem)
            {
                itemLocation = item.RackLocation ?? item.Domain.FullLocation;
            }
            else if (item is MaterialConsumableItem)
            {
                itemLocation = item.Shopfloorline.FullLocation;
            }

            Part        part  = item.Part;
            Transaction trans = TransactionFactory.CreateTransaction(part.Session, sourceType.Code);

            trans.TransType = sourceType.Code;

            if (sourceType.Direction == "IN")
            {
                trans.ArrivalLocation = itemLocation;
            }
            else
            {
                trans.DepartLocation = itemLocation;
            }

            trans.Part      = part;
            trans.Qty       = adjustmentQty;
            trans.TransRef  = "Material Qty Adjustment";
            trans.TransBy   = Security.UserSecurity.CurrentUser.Login;
            trans.TransDate = DateTime.Now;
            trans.Item      = InventoryRepository.GetItemRecordById(trans.Session, "LRAWMATERIALS000");
            trans.Comments  = comments;
        }
예제 #5
0
        public static bool AdjustMaterialConsumableItem(Part part, Shopfloorline sfl, int qty, string comments, AdjustmentTransactionType sourceType, MessageListener messages)
        {
            var repo       = Scout.Core.Data.GetRepository(part.Session);
            var consumable = new MaterialsConsumableInventory(repo);

            MaterialConsumableItem item;

            try
            {
                if (sourceType.Direction == "IN")
                {
                    item = consumable.IncreaseItemQty(part, sfl, qty);
                }
                else
                {
                    item = consumable.DecreaseItemQty(part, sfl, qty);
                }

                WriteQtyAdjustmentTransaction(item, qty, comments, sourceType);


                return(repo.Save());
            }
            catch (Exception ex)
            {
                Scout.Core.UserInteraction.Dialog.ShowMessage(ex.Message, UserMessageType.Error);
                return(false);
            }
        }
예제 #6
0
        public static bool AdjustMaterialWarehouseItem(Part part, Domain domain, string rackLocation, int qty, string comments, AdjustmentTransactionType sourceType, MessageListener messageListener)
        {
            var repo = Scout.Core.Data.GetRepository(part.Session);
            var whse = new MaterialsWarehouseInventory(repo);

            MaterialWarehouseItem item;

            try
            {
                // Adjust the quantity
                if (sourceType.Direction == "IN")
                {
                    item = whse.IncreaseItemQuantity(part, domain, rackLocation, qty);
                }
                else
                {
                    item = whse.DecreaseItemQuantity(part, domain, rackLocation, qty);
                }

                // Write the transaction
                WriteQtyAdjustmentTransaction(item, qty, comments, sourceType);

                return(repo.Save());
            }
            catch (Exception ex)
            {
                Scout.Core.UserInteraction.Dialog.ShowMessage(ex.Message, UserMessageType.Error);
                return(false);
            }
        }
예제 #7
0
 public IEnumerable <AdjustmentTransactionType> GetAllAdjustmentTransactionTypes()
 {
     return(AdjustmentTransactionType.AsList());
 }
예제 #8
0
 private void LoadLists()
 {
     sourceTypeLookUp.Properties.DataSource = AdjustmentTransactionType.AsList().Where(t => t.Direction == "OUT").ToList();
 }
예제 #9
0
        public void can_prefix_adjustment_source_type_codes()
        {
            var list = AdjustmentTransactionType.AsList();

            Assert.That(list.PrefixCodesWith("MATL")[0].Code.StartsWith("MATL"));
        }