public void SubmitChanges(PaymentNote document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); _auditLogWFManager.AuditLogEntry("PaymentNote", string.Format("Created PaymentNote: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } var co = commandsToExecute.OfType<ConfirmCommand>().FirstOrDefault(); if (co != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("PaymentNote", string.Format("Confirmed PaymentNote: {0}; From: {1}; To: {2}", document.Id, document.DocumentIssuerCostCentre.Name, document.DocumentRecipientCostCentre.Name)); }
public void SubmitChanges(CreditNote document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand= commandsToExecute.OfType<CreateCommand>().FirstOrDefault(); if (createCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); // _commandRouter.RouteDocumentCommand(createCommand); List<AfterCreateCommand> lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>().ToList(); foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); //_commandRouter.RouteDocumentCommand(item); } ConfirmCreditNoteCommand confirmCreditNoteCommand = commandsToExecute.OfType<ConfirmCreditNoteCommand>().FirstOrDefault(); if (confirmCreditNoteCommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCreditNoteCommand)); // _commandRouter.RouteDocumentCommand(confirmCreditNoteCommand); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
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 SubmitChanges(InventoryAdjustmentNote document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); envelope.OtherRecipientCostCentreList.Add(Guid.NewGuid()); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().First(); // _commandRouter.RouteDocumentCommand(createCommand); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence,createCommand)); _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Created IAN document: {0};", document.Id)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var _item in lineItemCommands) { var item = _item as AddInventoryAdjustmentNoteLineItemCommand; envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Adjusted Product: {1}; quantity from: {2}; to: {3}; for IAN document: {0};", document.Id, item.ProductId, item.Actual, item.Actual)); } var co = commandsToExecute.OfType<ConfirmCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("Inventory Adjustment", string.Format("Confirmed IAN document: {0};", document.Id)); }
public void BreakBulk(Guid productId, Guid costcentreId, decimal qty, BasicConfig config) { throw new Exception("Dont think that we need to implement on hosted environment??"); //Product product = _productRepository.GetById(productId); //if (!(product is ConsolidatedProduct)) // return; //inventory adjust consolidated product down //inventory adjust consolidated products up }
public void SubmitChanges(DisbursementNote document,BasicConfig config ) { //send commands var coc = new CreateDisbursementNoteCommand( Guid.NewGuid(), document.Id, document.DocumentIssuerUser.Id, config.CostCentreId, 0, document.DocumentIssuerCostCentreApplicationId, document.DocumentIssuerCostCentre.Id, document.DocumentRecipientCostCentre.Id, document.DocumentIssuerUser.Id, document.DocumentParentId,document.DocumentDateIssued, document.DocumentReference ); _commandRouter.RouteDocumentCommand(coc); _auditLogWFManager.AuditLogEntry("Disbursment Note", string.Format("Created Disbursement Note document: {0}", document.Id)); foreach (var item in document.LineItems) { var ali = new AddDisbursementNoteLineItemCommand( Guid.NewGuid(), document.Id, document.DocumentIssuerUser.Id, document.DocumentIssuerCostCentre.Id, 0, config.CostCentreApplicationId, 0, item.Product.Id, item.Qty, item.Value,document.DocumentParentId); _commandRouter.RouteDocumentCommand(ali); _auditLogWFManager.AuditLogEntry("Disbursment Note", string.Format("Added Product: {1}; Quantity: {2}; Value: {3}; to Disbursement Note document: {0}", document.Id,item.Product.Description,item.Qty,item.Value)); } var co = new ConfirmDisbursementNoteCommand(Guid.NewGuid(), document.Id, document.DocumentIssuerUser.Id, document.DocumentIssuerCostCentre.Id, 0, config.CostCentreApplicationId,document.DocumentParentId); _commandRouter.RouteDocumentCommand(co); _auditLogWFManager.AuditLogEntry("Disbursment Note", string.Format("Confirmed Disbursement Note document: {0}", document.Id)); }
public void SubmitChanges(Receipt document,BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand; //= commandsToExecute.OfType<CreateCommand>().First(); if (TryGetCreateCommand(commandsToExecute, out createCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); // _commandRouter.RouteDocumentCommand(createCommand); _auditLogWFManager.AuditLogEntry("Receipt", string.Format("Created Receipt: {0}; for invoice: {1}", document.Id, document.InvoiceId)); } List<AfterCreateCommand> lineItemCommands; if (TryGetAfterCreateCommands(commandsToExecute, out lineItemCommands)) { foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(item); var _item = item as AddReceiptLineItemCommand; _auditLogWFManager.AuditLogEntry("Receipt", string.Format( "Added Product type: {0}; Quantity: {1}; for Invoice: {2};", _item.LineItemType, _item.Value, document.InvoiceId)); } } ConfirmCommand confirmCommand; if (TryGetConfirmCommand(commandsToExecute, out confirmCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommand)); // _commandRouter.RouteDocumentCommand(confirmCommand); _auditLogWFManager.AuditLogEntry("Receipt", string.Format("Confirmed Receipt: {0}; for Invoice: {1}", document.Id, document.InvoiceId)); // _notifyService.SubmitRecieptNotification(document); } _commandEnvelopeRouter.RouteCommandEnvelope(envelope); document.CallClearCommands(); }
public void SubmitChanges(Domain.Transactional.DocumentEntities.Invoice document, BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand; //= commandsToExecute.OfType<CreateCommand>().First(); if (TryGetCreateCommand(commandsToExecute, out createCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); //_commandRouter.RouteDocumentCommand(createCommand); _auditLogWFManager.AuditLogEntry("Invoice", string.Format("Created Invoice: {0}; for Order: {1}", document.Id, document.OrderId)); } List<AfterCreateCommand> lineItemCommands; if (TryGetAfterCreateCommands(commandsToExecute, out lineItemCommands)) { foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); // _commandRouter.RouteDocumentCommand(item); var _item = item as AddInvoiceLineItemCommand; _auditLogWFManager.AuditLogEntry("Invoice", string.Format( "Added Product: {0}; Quantity: {1}; for Invoice: {2};", _item.ProductId, _item.Qty, document.Id)); } } ConfirmCommand confirmCommand; if (TryGetConfirmCommand(commandsToExecute, out confirmCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommand)); // _commandRouter.RouteDocumentCommand(confirmCommand); //send notification // _notifyService.SubmitInvoiceNotification(document); _auditLogWFManager.AuditLogEntry("Invoice", string.Format("Confirmed Invoice: {0}; for Order: {1}", document.Id, document.OrderId)); } _commandEnvelopeRouter.RouteCommandEnvelope(envelope); document.CallClearCommands(); }
public void SubmitChanges(DispatchNote document, BasicConfig config) { //document.Confirm(); int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(document); List<DocumentCommand> commandsToExecute = document.GetDocumentCommandsToExecute(); CreateCommand createCommand; if (TryGetCreateCommand(commandsToExecute, out createCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); // _commandRouter.RouteDocumentCommand(createCommand); _auditLogWFManager.AuditLogEntry("Dispatch Note", string.Format("Dispatch Note Document No: {0}; to: {1}; Created", document.Id, document.DocumentRecipientCostCentre.Name)); } List<AfterCreateCommand> lineItemCommands; if (TryGetAfterCreateCommands(commandsToExecute, out lineItemCommands)) { foreach (var item in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, item)); //_commandRouter.RouteDocumentCommand(item); var _item = item as AddDispatchNoteLineItemCommand; _auditLogWFManager.AuditLogEntry("Dispatch Note", string.Format("Added Product: {1}; Quantity: {2}; Value: {3}; to Dispatch Note document: {0}", document.Id, item.Description, _item.Qty, _item.Value)); } } ConfirmCommand confirmCommand; if (TryGetConfirmCommand(commandsToExecute, out confirmCommand)) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, confirmCommand)); //_commandRouter.RouteDocumentCommand(confirmCommand); _auditLogWFManager.AuditLogEntry("Dispatch Note", string.Format("Confirmed Dispatch Note document: {0}", document.Id)); // _notifyService.SubmitDispatch(document); } _commandEnvelopeRouter.RouteCommandEnvelope(envelope); document.CallClearCommands(); }
public void SubmitChanges(InventoryReceivedNote irn,BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(irn); List<DocumentCommand> commandsToExecute = irn.GetDocumentCommandsToExecute(); var createCommand = commandsToExecute.OfType<CreateCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, createCommand)); _auditLogWFManager.AuditLogEntry("Receive Inventory", string.Format("Created Goods Received Note: {0}; for Purchase Orders: {1}", irn.Id, irn.OrderReferences)); var lineItemCommands = commandsToExecute.OfType<AfterCreateCommand>(); foreach (var li in lineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, li)); AddInventoryReceivedNoteLineItemCommand c = li as AddInventoryReceivedNoteLineItemCommand; _auditLogWFManager.AuditLogEntry("Receive Inventory", string.Format("Received Product: {0}; Quantity: {1}; for Goods Received Note: {2};", c.ProductId, c.Qty, irn.Id)); } var co = commandsToExecute.OfType<ConfirmCommand>().First(); envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); _auditLogWFManager.AuditLogEntry("Receive Inventory", string.Format("Confirmed Goods Received Note: {0}; for Purchase Orders: {1}", irn.Id, irn.OrderReferences)); }
public void BreakBulk(Guid productId, Guid costcentreId, decimal qty, BasicConfig config) { Product product = _productService.GetById(productId); if (!(product is ConsolidatedProduct)) return; ConsolidatedProduct consolidatedProduct = product as ConsolidatedProduct; //create inventory adjustment Guid documentId = Guid.NewGuid(); //TODO AJM resolve current user id Guid currentUserId = Guid.Empty; CreateInventoryAdjustmentNoteCommand cianc = new CreateInventoryAdjustmentNoteCommand( Guid.NewGuid(), documentId, currentUserId, config.CostCentreId, 0, config.CostCentreApplicationId, config.CostCentreId, currentUserId, (int)InventoryAdjustmentNoteType.Available, "", DateTime.Now ); _commandRouter.RouteDocumentCommand(cianc); _auditLogWFManager.AuditLogEntry("Break Bulk", string.Format("Created Break Bulk document: {0}; for consolidated product: {1}; and Quantity: {2};", documentId, consolidatedProduct.Description, qty)); //create line items //-- adjust down consolidated product AddInventoryAdjustmentNoteLineItemCommand li = new AddInventoryAdjustmentNoteLineItemCommand( Guid.NewGuid(), documentId, currentUserId, config.CostCentreId, 0, config.CostCentreApplicationId, productId, -qty, 0, 1, "break bulk"); _commandRouter.RouteDocumentCommand(li); int count = 1; //-- adjust up items foreach (var item in consolidatedProduct.ProductDetails) { count++; var li1 = new AddInventoryAdjustmentNoteLineItemCommand(Guid.NewGuid(), documentId, currentUserId, config.CostCentreId, 0, config.CostCentreApplicationId, item.Product.Id, item.QuantityPerConsolidatedProduct * qty, 0, count, "break bulk" ); _commandRouter.RouteDocumentCommand(li1); _auditLogWFManager.AuditLogEntry("Break Bulk", string.Format("Adjusted Product: {0}; to Quantity: {1}; for consolidated product: {2};", item.Product.Description, item.QuantityPerConsolidatedProduct * qty, consolidatedProduct.Description)); } //confirm var confirmIA = new ConfirmInventoryAdjustmentNoteCommand(Guid.NewGuid(), documentId, currentUserId, config.CostCentreId, 0, config.CostCentreApplicationId); _commandRouter.RouteDocumentCommand(confirmIA); _auditLogWFManager.AuditLogEntry("Break Bulk", string.Format("confirmed Break Bulk document: {0}; for consolidated product: {1}; and Quantity: {2};", documentId, consolidatedProduct.Description, qty)); }
public void Submit(MainOrder order,BasicConfig config) { int sequence = 0; var envelope = new CommandEnvelope(); envelope.Initialize(order); List<DocumentCommand> commandsToExecute = order.GetSubOrderCommandsToExecute(); 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)); // _commandRouter.RouteDocumentCommand(_item); } var editlineItemCommands = commandsToExecute.OfType<ChangeMainOrderLineItemCommand>(); foreach (var _editeditem in editlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _editeditem)); //_commandRouter.RouteDocumentCommand(_editeditem); } var removedLineitem = commandsToExecute.OfType<RemoveMainOrderLineItemCommand>(); foreach (var _removeditem in removedLineitem) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _removeditem)); } var co = commandsToExecute.OfType<ConfirmCommand>().FirstOrDefault(); if (co != null) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, co)); //_commandRouter.RouteDocumentCommand(co); _notifyService.SubmitOrderSaleNotification(order); } var rco = commandsToExecute.OfType<RejectMainOrderCommand>().FirstOrDefault(); if (rco != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, rco)); //adjust inventory from distributor Guid invoiceId; var approvedlineItemCommands = order.GetSubOrderCommandsToExecute().OfType<ApproveOrderLineItemCommand>(); foreach (var _item in approvedlineItemCommands) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, _item)); } HandleApprovedCommand(order,config,out invoiceId); var aop = commandsToExecute.OfType<ApproveCommand>().FirstOrDefault(); if (aop != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, aop)); var closecommand = commandsToExecute.OfType<CloseOrderCommand>().FirstOrDefault(); if (closecommand != null) envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, closecommand)); var orderpaymentInfoitem = order.GetSubOrderCommandsToExecute().OfType<AddOrderPaymentInfoCommand>(); foreach (var paymentInfo in orderpaymentInfoitem) { envelope.CommandsList.Add(new CommandEnvelopeItem(++sequence, paymentInfo)); } HandlePayments(order,invoiceId, config); _commandEnvelopeRouter.RouteCommandEnvelope(envelope); }
private void HandleApprovedCommand(MainOrder order ,BasicConfig config, out Guid invoiceId) { invoiceId = Guid.Empty; var approvedlineItemCommands = order.GetSubOrderCommandsToExecute().OfType<ApproveOrderLineItemCommand>(); if (!approvedlineItemCommands.Any()) return; CostCentre issuer = _costCentreRepository.GetById(config.CostCentreId); CostCentre recepient = null; if (order.DocumentIssuerCostCentre is DistributorSalesman) recepient = order.DocumentIssuerCostCentre; else recepient = order.DocumentRecipientCostCentre; InventoryAdjustmentNote inventoryAdjustmentNote = _inventoryAdjustmentNoteFactory.Create(issuer, config.CostCentreApplicationId, recepient, order.DocumentIssuerUser, order.DocumentReference, InventoryAdjustmentNoteType.Available, order.ParentId); inventoryAdjustmentNote.DocumentParentId = order.Id; string invoiceRef = _getDocumentReference.GetDocReference("Inv",recepient.Id,order.IssuedOnBehalfOf.Id); Domain.Transactional.DocumentEntities.Invoice invoice = _invoiceFactory.Create(issuer, config.CostCentreApplicationId, recepient, order.DocumentIssuerUser, invoiceRef, order.Id, order.Id); invoiceId = invoice.Id; foreach (var _item in approvedlineItemCommands) { ApproveOrderLineItemCommand ap = _item as ApproveOrderLineItemCommand; SubOrderLineItem soli = order.PendingApprovalLineItems.First(s => s.Id == ap.LineItemId); if (ap.ApprovedQuantity > 0) { inventoryAdjustmentNote.AddLineItem(_inventoryAdjustmentNoteFactory.CreateLineItem(0,soli.Product.Id, ap.ApprovedQuantity,0, "Inventory adjustment")); invoice.AddLineItem(_invoiceFactory.CreateLineItem(soli.Product.Id, ap.ApprovedQuantity, soli.Value, order.DocumentReference, 0, soli.LineItemVatValue, soli.ProductDiscount, soli.DiscountType)); } // _commandRouter.RouteDocumentCommand(_item); } inventoryAdjustmentNote.Confirm(); _inventoryAdjustmentNoteWfManager.SubmitChanges(inventoryAdjustmentNote,config); invoice.Confirm(); _invoiceWorkFlowManager.SubmitChanges(invoice,config); }
private void HandlePayments(MainOrder order, Guid invoiceId,BasicConfig config) { var orderpaymentInfoitem = order.GetSubOrderCommandsToExecute().OfType<AddOrderPaymentInfoCommand>(); foreach (var paymentInfo in orderpaymentInfoitem) { //TODO AJM resolve this section /* var notification = _notificationRepository.GetById(paymentInfo.InfoId); if (notification != null) { foreach (var paymentNotificationListItem in notification.PaymentNotificationDetails.Where(s => !s.IsUsed)) { _notificationRepository.ConfirmNotificationItem(paymentNotificationListItem.Id); } }*/ } if (orderpaymentInfoitem.Any(s => s.IsConfirmed && !s.IsProcessed)) { if (invoiceId == Guid.Empty) invoiceId = _invoiceRepository.GetInvoiceByOrderId(order.Id).Id; CostCentre recepient = null; if (order.DocumentIssuerCostCentre is DistributorSalesman) recepient = order.DocumentIssuerCostCentre; else recepient = order.DocumentRecipientCostCentre; string receiptRef = _getDocumentReference.GetDocReference("Rpt", recepient.Id,order.IssuedOnBehalfOf.Id); Receipt receipt = _receiptFactory.Create(order.DocumentIssuerCostCentre, order.DocumentIssuerCostCentreApplicationId, order.DocumentRecipientCostCentre, order.DocumentIssuerUser, receiptRef, order.Id, invoiceId, Guid.Empty); foreach (var info in orderpaymentInfoitem.Where(s => s.IsConfirmed && !s.IsProcessed)) { receipt.AddLineItem(_receiptFactory.CreateLineItem(info.ConfirmedAmount, info.PaymentRefId, info.MMoneyPaymentType, info.NotificationId, 0, (PaymentMode)info.PaymentModeId, info.Description, receipt.Id, info.IsConfirmed) ); } receipt.Confirm(); _receiptWorkFlowManager.SubmitChanges(receipt,config); } }