public void SubmitChanges(InventoryTransferNote document, BasicConfig config)
        {

            int sequence = 0;
            var envelope = new CommandEnvelope();
            envelope.Initialize(document);
            List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute();
            var createCommand = commandsToExecute.OfType<CreateCommand>().First();
            envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand));
            //_commandRouter.RouteDocumentCommand(createCommand);
            _auditLogWFManager.AuditLogEntry("Inventory Transfer", string.Format("Created Inventory Transfer: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name));

            var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>();
            foreach (var _item in lineItemCommands)
            {
                var item = _item as AddInventoryTransferNoteLineItemCommand;
                envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item));
               // _commandRouter.RouteDocumentCommand(_item);
                _auditLogWFManager.AuditLogEntry("Inventory Transfer", string.Format("Transferred Product: {0}; Quantity: {1}; for Inventory Transfer: {2};", item.ProductId, item.Qty, document.Id));
            }
            var co = commandsToExecute.OfType<ConfirmCommand>().First();
            envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co));
            //_commandRouter.RouteDocumentCommand(co);
            _commandEnvelopeRouter.RouteCommandEnvelope(envelope);
            _auditLogWFManager.AuditLogEntry("Inventory Transfer", string.Format("Confirmed Inventory Transfer: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name));
        }
 public void Submit(InventoryTransferNote note)
 {
     int sequence = 0;
     var envelope = new CommandEnvelope();
     envelope.Initialize(note);
     List<DocumentCommand> commandsToExecute = note.GetDocumentCommandsToExecute();
     var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault();
     if (createCommand != null)
     {
         envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand));
     }
     var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>();
     foreach (var _item in lineItemCommands)
     {
         envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item));
     }
     var co = commandsToExecute.OfType<ConfirmCommand>().First();
     if(co !=null)
     {
         envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co));
     }
     AddToMongoDB(envelope);
 }
 public void SubmitToWF(InventoryTransferNote ian)
 {
     _transferNoteWfManager.SubmitChanges(ian, null);
 }
示例#4
0
 public void ConfirmCommandITN()
 {
     using (var container = NestedContainer)
     {
         BasicConfig config = container.GetInstance<IConfigService>().Load();
         IConfirmInventoryTransferNoteWFManager _confirmInventoryTransferNoteWFManager =
             Using<IConfirmInventoryTransferNoteWFManager>(container);
        
         if (SaveITN())
             if (note != null && note.LineItems.Any())
             {
                 note.Confirm();
                 _confirmInventoryTransferNoteWFManager.SubmitChanges(note,config);
                 note = null;
                 ClearViewModel();
                 MessageBox.Show("Successfully Confirmed", "Information", MessageBoxButton.OK);
                 ConfirmNavigatingAway = false;
                 SendNavigationRequestMessage(new Uri("/views/Reports/InventoryIssuesReport.xaml",
                                                      UriKind.Relative));
             }
             else
             {
                 throw new Exception("Inventory wasn't tranfered ");
             }
     }
 }
示例#5
0
        private bool SaveITN()
        {
            using (var container = NestedContainer)
            {

                ICostCentreRepository _costCentreService = Using<ICostCentreRepository>(container);
               
                IConfigService _configService = Using<IConfigService>(container);
                IProductRepository _productService = Using<IProductRepository>(container);
                IInventorySerialsWorkFlow _inventorySerialsService = Using<IInventorySerialsWorkFlow>(container);
                IInventoryRepository _inventoryService = Using<IInventoryRepository>(container);
                IInventoryTransferNoteFactory _inventoryTransferNoteFactory = Using<IInventoryTransferNoteFactory>(container);
                if (LineItems.Count <= 0)
                {
                    MessageBox.Show("Add products to issue first");
                    return false;
                }
                string msg = "";
                var transferTo = _costCentreService.GetById(SelectedSaleMan.CostCentre);
                var transferFrom = _costCentreService.GetById(_configService.Load().CostCentreId);
                note = null;
                foreach (var item in LineItems)
                {
                    var inventory = _inventoryService.GetByProductIdAndWarehouseId(item.ProductId, transferFrom.Id);
                    if (inventory == null)
                    {
                        msg += "Product : " + item.ProductName + " Required(" + item.Qty +
                               ") inventory is not available(0)\n";
                    }
                    else if (inventory != null && inventory.Balance < item.Qty)
                    {
                        msg += "Product : " + item.ProductName + " Required(" + item.Qty +
                               ") inventory is not available(" + inventory.Balance + ")\n";
                    }
                }
                if (msg != "")
                {
                    MessageBox.Show("Make sure you have this inventory\n" + msg, "Inventory Transfer",
                                    MessageBoxButton.OK);
                    return false;
                }
                var cc = _costCentreService.GetById(_configService.Load().CostCentreId);
                note = _inventoryTransferNoteFactory.Create(cc,
                                                            _configService.Load().CostCentreApplicationId,
                                                            SelectedSaleMan, transferTo, cc, "");

                List<InventoryTransferNoteLineItem> ListitnLineitem = new List<InventoryTransferNoteLineItem>();
                foreach (EditItnViewModelInventoryTransfer item in LineItems)
                {
                    InventoryTransferNoteLineItem itnLineitem = _inventoryTransferNoteFactory.CreateLineItem(item.ProductId, item.Qty, 0, 0, "");
                    ListitnLineitem.Add(itnLineitem);
                }

                foreach (var i in ListitnLineitem)
                {
                    note.AddLineItem(i);
                }
                //note._SetLineItems(ListitnLineitem);
                var list = _inventorySerialNumbersList
                    .Select(n => new InventorySerials(n.SerialsId)
                                     {
                                         CostCentreRef = new CostCentreRef {Id = note.DocumentRecipientCostCentre.Id},
                                         DocumentId = note.Id,
                                         ProductRef = new ProductRef {ProductId = n.ProductId,},
                                         From = n.From,
                                         To = n.To
                                     }).ToList();
                _inventorySerialsService.SubmitInventorySerials(list);
                return true;
            }
        }