public frmGetSalesInvoices(DataTable salesInvoiceRecords, CustomerOrderTransaction originalTransaction) : this() { if (salesInvoiceRecords == null) { throw new ArgumentNullException("salesInvoiceRecords"); } if (originalTransaction == null) { throw new ArgumentNullException("originalTransaction"); } Invoices = salesInvoiceRecords; // Copy the original order and clear all the items/charges. CustomerOrderTransaction returnTransaction = new CustomerOrderTransaction(originalTransaction, originalTransaction.ISalesOrder); SalesOrderActions.SetCustomerOrderDefaults(returnTransaction); returnTransaction.DeliveryMode = originalTransaction.DeliveryMode; returnTransaction.RequestedDeliveryDate = originalTransaction.RequestedDeliveryDate; returnTransaction.SaleItems.Clear(); returnTransaction.MiscellaneousCharges.Clear(); returnTransaction.Mode = CustomerOrderMode.Return; returnTransaction.LockPrices = true; // Clear deposit details from the Return because we simply return the full invoiced amount (deposit + payments) for the items, // and there is no way to allocate the actual deposit paid for individual lines on the transaction in the case of a partial return. returnTransaction.PrepaymentAmountOverridden = true; returnTransaction.PrepaymentAmountRequired = 0.0m; this.Transaction = returnTransaction; }
/// <summary> /// Prompt for return reason code and add to transaction. /// </summary> /// <param name="customerOrderTransaction">Transaction to update.</param> private static void ProcessReturnReasonCodes(CustomerOrderTransaction customerOrderTransaction) { if (customerOrderTransaction == null) { NetTracer.Warning("customerOrderTransaction parameter is null"); throw new ArgumentNullException("customerOrderTransaction"); } // Process codes only if it is a return order and has items selected. if (customerOrderTransaction.Mode == CustomerOrderMode.Return && customerOrderTransaction.SaleItems != null && customerOrderTransaction.SaleItems.Count > 0) { string selectedValue; DialogResult dialogResult = SalesOrder.InternalApplication.Services.Dialog.GenericLookup( SalesOrder.GetReturnReasonCodes() as IList, "Description", ApplicationLocalizer.Language.Translate(99524), // Return Reason "ReasonCodeId", out selectedValue, null); if (dialogResult == DialogResult.OK) { customerOrderTransaction.ReturnReasonCodeId = selectedValue; } } }
public OrderDetailsViewModel( CustomerOrderTransaction customerOrderTransaction, OrderDetailsSelection selectedMode) { this.SetTransaction(customerOrderTransaction); this.mode = selectedMode; DM.StoreDataManager storeDataManager = new DM.StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); DM.EmployeeDataManager employeeDataManager = new DM.EmployeeDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); // Collection of all employees employees = new ReadOnlyCollection <DataEntity.Employee>(employeeDataManager.GetEmployees(ApplicationSettings.Terminal.StoreId)); // Set the default minimum expiration date to tomorrow (but do not overwrite the current expiration date already set on the transaction) this.MinimumOrderExpirationDate = DateTime.Today.AddDays(1); // Use the actual, recalled, expiration date if it is older. // This is needed to prevent the UI from forcing the older date to snap to the minimum. if (this.MinimumOrderExpirationDate > this.OrderExpirationDate) { this.MinimumOrderExpirationDate = this.OrderExpirationDate; } // Set the default sales person to the currently logged in operator if (string.IsNullOrWhiteSpace(this.SalesPersonId)) { this.SalesPersonId = LSRetailPosis.Settings.ApplicationSettings.Terminal.TerminalOperator.OperatorId; } }
public frmGetSalesInvoices(DataTable salesInvoiceRecords, CustomerOrderTransaction originalTransaction) : this() { if (salesInvoiceRecords == null) { throw new ArgumentNullException("salesInvoiceRecords"); } if (originalTransaction == null) { throw new ArgumentNullException("originalTransaction"); } Invoices = salesInvoiceRecords; // Copy the original order and clear all the items/charges. CustomerOrderTransaction returnTransaction = new CustomerOrderTransaction(originalTransaction, originalTransaction.ISalesOrder); SalesOrderActions.SetCustomerOrderDefaults(returnTransaction); returnTransaction.DeliveryMode = originalTransaction.DeliveryMode; returnTransaction.RequestedDeliveryDate = originalTransaction.RequestedDeliveryDate; returnTransaction.SaleItems.Clear(); returnTransaction.MiscellaneousCharges.Clear(); returnTransaction.Mode = CustomerOrderMode.Return; returnTransaction.LockPrices = true; this.Transaction = returnTransaction; }
/// <summary> /// Creates a <see cref="LineLevelInformationViewModel" object/> /// </summary> /// <param name="saleLineItem">Reference to the line item. It will be modified on Commit.</param> public LineLevelInformationViewModel(SaleLineItem saleLineItem, CustomerOrderTransaction custTransaction) { this.transaction = custTransaction; StoreDataManager storeDataManager = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); this.deliveryStore = storeDataManager.GetStore(saleLineItem.DeliveryStoreNumber); this.saleLineItem = saleLineItem; this.LineItemId = saleLineItem.ItemId; this.Description = saleLineItem.Description; this.Quantity = saleLineItem.Quantity; this.DeliveryDate = saleLineItem.DeliveryDate; this.ShippingAddress = saleLineItem.ShippingAddress; this.ShippingMethodCode = saleLineItem.DeliveryMode != null ? saleLineItem.DeliveryMode.Code : string.Empty; // Since there is a difference between no shipping charge and a shipping charge of zero, we need to see if we have any shipping charges before summing them IEnumerable <Tax.MiscellaneousCharge> shippingCharges = saleLineItem.MiscellaneousCharges.Where(c => c.ChargeCode == ApplicationSettings.Terminal.ShippingChargeCode); if (shippingCharges.Any()) { this.ShippingCharge = shippingCharges.Sum(c => c.Price); } // Check for delivery mode on line first, then header IDeliveryMode deliveryMode = saleLineItem.DeliveryMode ?? custTransaction.DeliveryMode; bool hasPickupCode = deliveryMode != null && string.Equals(deliveryMode.Code, ApplicationSettings.Terminal.PickupDeliveryModeCode, StringComparison.OrdinalIgnoreCase); bool hasDeliveryDate = saleLineItem.DeliveryDate.HasValue; // we have to do this because if hasPickupCode == false, that does not mean that IsShipping will be set to true this.IsPickup = hasPickupCode && hasDeliveryDate; this.IsShipping = !hasPickupCode && hasDeliveryDate; }
public PickupInformationViewModel(CustomerOrderTransaction custTransaction) { this.transaction = custTransaction; // Get list of addresses storeDataManager = new DM.StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); customerDataManager = new DM.CustomerDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); // Create a read-only collection stores = new ReadOnlyCollection <DataEntity.Store>(storeDataManager.GetStoresForPickup(SalesOrder.InternalApplication.Settings.Database.DataAreaID)); // Load date if (custTransaction.RequestedDeliveryDate > DateTime.MinValue) { this.pickUpDate = custTransaction.RequestedDeliveryDate; } // Load store if (!string.IsNullOrWhiteSpace(custTransaction.WarehouseId)) { this.selectedStore = storeDataManager.GetWarehouseStore(custTransaction.WarehouseId); } else { this.selectedStore = storeDataManager.GetStore(LSRetailPosis.Settings.ApplicationSettings.Terminal.StoreId); } }
private void btnEdit_Click(object sender, EventArgs e) { //Get order CustomerOrderTransaction cot = SalesOrderActions.GetCustomerOrder(this.SelectedSalesOrderId, this.SelectedOrderType, LSRetailPosis.Transaction.CustomerOrderMode.Edit); SalesOrderActions.ShowOrderDetails(cot, OrderDetailsSelection.ViewDetails); SetSelectedOrderAndClose(cot); }
private void btnReturn_Click(object sender, EventArgs e) { //Get the order from the grid CustomerOrderTransaction cot = SalesOrderActions.GetCustomerOrder(this.SelectedSalesOrderId, this.SelectedOrderType, LSRetailPosis.Transaction.CustomerOrderMode.Edit); //Now get an invoice from the order cot = SalesOrderActions.ReturnOrderInvoices(cot); SetSelectedOrderAndClose(cot); }
private void btnPickUp_Click(object sender, EventArgs e) { //Get order //set Mode = Pickup CustomerOrderTransaction cot = SalesOrderActions.GetCustomerOrder(this.SelectedSalesOrderId, this.SelectedOrderType, LSRetailPosis.Transaction.CustomerOrderMode.Pickup); SalesOrderActions.ShowOrderDetails(cot, OrderDetailsSelection.PickupOrder); SetSelectedOrderAndClose(cot); }
private void SetSelectedOrderAndClose(CustomerOrderTransaction transaction) { if (transaction != null) { this.SelectedOrder = transaction; this.DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } }
public ItemDetailsViewModel(CustomerOrderTransaction customerOrderTransaction) { this.SetTransaction(customerOrderTransaction); // Create a collection of LineItemViewModels from each SaleLineItem viewModels = (from lineItem in this.Transaction.SaleItems.Where(i => !i.Voided) select new LineItemViewModel(lineItem)).ToList <LineItemViewModel>(); this.lineItems = new ReadOnlyCollection <LineItemViewModel>(viewModels); }
public PaymentHistoryViewModel(CustomerOrderTransaction customerOrderTransaction) { this.SetTransaction(customerOrderTransaction); // Create a collection of PaymentHistoryLineViewModels from each CustomerOrderPaymentHistory List <PaymentHistoryLineViewModel> viewModels = (from lineItem in this.Transaction.PaymentHistory select new PaymentHistoryLineViewModel(lineItem, this.Transaction.OrderId)).ToList <PaymentHistoryLineViewModel>(); payments = new ReadOnlyCollection <PaymentHistoryLineViewModel>(viewModels); }
private static void AddSalesItemToTransaction(string invoiceId, CustomerOrderTransaction transaction, StoreDataManager storeDataManager, InvoiceItem item) { // add item SaleLineItem lineItem = (SaleLineItem) SalesOrder.InternalApplication.BusinessLogic.Utility.CreateSaleLineItem( ApplicationSettings.Terminal.StoreCurrency, SalesOrder.InternalApplication.Services.Rounding, transaction); lineItem.Found = true; lineItem.ItemId = item.ItemId; lineItem.Description = item.ProductName; lineItem.Quantity = item.Quantity; lineItem.ReturnQtyAllowed = item.Quantity; lineItem.SalesOrderUnitOfMeasure = item.Unit; lineItem.Price = item.Price; lineItem.NetAmount = item.NetAmount; lineItem.SalesTaxGroupId = item.SalesTaxGroup; lineItem.TaxGroupId = item.ItemTaxGroup; lineItem.SalesMarkup = item.SalesMarkup; lineItem.QuantityOrdered = item.Quantity; lineItem.DeliveryMode = storeDataManager.GetDeliveryMode(item.DeliveryMode); lineItem.DeliveryDate = DateTime.Today; lineItem.DeliveryStoreNumber = transaction.StoreId; lineItem.DeliveryWarehouse = item.Warehouse; lineItem.SerialId = item.SerialId; lineItem.BatchId = item.BatchId; lineItem.ReturnInvoiceInventTransId = item.InventTransId; lineItem.ReturnInvoiceId = invoiceId; // When we get price from a sales invoice in AX; this is THE price that we will use lineItem.ReceiptReturnItem = true; lineItem.Dimension.ColorId = item.ColorId; lineItem.Dimension.SizeId = item.SizeId; lineItem.Dimension.StyleId = item.StyleId; lineItem.Dimension.ConfigId = item.ConfigId; lineItem.Dimension.ColorName = item.ColorName; lineItem.Dimension.SizeName = item.SizeName; lineItem.Dimension.StyleName = item.StyleName; lineItem.Dimension.ConfigName = item.ConfigName; // set discount, everything is converted into a LineDiscount if ((item.DiscountAmount != decimal.Zero) && (item.Quantity != decimal.Zero)) { ILineDiscountItem lineDiscountItem = SalesOrder.InternalApplication .BusinessLogic.Utility.CreateLineDiscountItem(); lineDiscountItem.Amount = item.DiscountAmount; // this method takes the per item discount amount SalesOrder.InternalApplication.Services.Discount.AddLineDiscountAmount(lineItem, lineDiscountItem); } SalesOrder.InternalApplication.Services.Item.ProcessItem(lineItem); transaction.Add(lineItem); }
/// <summary> /// Get a sales order or quote by id /// </summary> /// <param name="orderId"></param> /// <param name="orderType"></param> /// <returns></returns> internal static CustomerOrderTransaction GetCustomerOrder(string orderId, CustomerOrderType orderType, CustomerOrderMode forMode) { CustomerOrderTransaction result = null; IRetailTransaction order; bool retValue = false; string comment; //Verify that the user has rights to EDIT an order, and prompt for access. if (!SalesOrder.InternalApplication.Services.LogOn.VerifyOperationAccess(SalesOrder.InternalApplication.Shift.StaffId, PosisOperations.CustomerOrderDetails)) { return(null); } switch (orderType) { case CustomerOrderType.SalesOrder: SalesOrder.InternalApplication.Services.SalesOrder.GetCustomerOrder( ref retValue, orderId, out comment, out order); break; case CustomerOrderType.Quote: SalesOrder.InternalApplication.Services.SalesOrder.GetCustomerQuote( ref retValue, orderId, out comment, out order); break; default: throw new InvalidOperationException("Unsupported CustomerOrderType"); } if (retValue) { // Cache the order CustomerOrderTransaction customerOrder = (CustomerOrderTransaction)order; customerOrder.Mode = forMode; if (forMode == CustomerOrderMode.Cancel) { AddDefaultCancellationCharge(customerOrder); } customerOrder.CalcTotals(); result = customerOrder; } else { // The sales order was not found in AX ApplicationLog.Log(SalesOrderActions.LogSource, string.Format("{0}\n{1}", ApplicationLocalizer.Language.Translate(56124), comment), LogTraceLevel.Error); SalesOrder.InternalApplication.Services.Dialog.ShowMessage(56124, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
internal static void WarnAndFlagForRecalculation(CustomerOrderTransaction trans) { if (trans.ExpirationDate.Date < DateTime.Now.Date) { // show warning SalesOrder.InternalApplication.Services.Dialog.ShowMessage(56300, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // unlock prices so that they will recalculate RecalculatePrices(trans); } }
private void SetSelectedOrderAndClose(CustomerOrderTransaction transaction) { if (transaction == null) { return; } this.UpdateSerialNumbers(transaction); this.SelectedOrder = transaction; this.DialogResult = DialogResult.OK; this.Close(); }
internal static CustomerOrderTransaction GetTransactionFromInvoice(InvoiceJournal invoice) { CustomerOrderTransaction transaction = (CustomerOrderTransaction) SalesOrder.InternalApplication.BusinessLogic.Utility.CreateCustomerOrderTransaction( ApplicationSettings.Terminal.StoreId, ApplicationSettings.Terminal.StoreCurrency, ApplicationSettings.Terminal.TaxIncludedInPrice, SalesOrder.InternalApplication.Services.Rounding, SalesOrder.InternalApplication.Services.SalesOrder); // Get all the defaults SalesOrder.InternalApplication.BusinessLogic.TransactionSystem.LoadTransactionStatus(transaction); //General header properties transaction.OrderId = invoice.SalesId; transaction.OrderType = CustomerOrderType.SalesOrder; transaction.QuotationId = invoice.SalesId; transaction.OriginalOrderType = CustomerOrderType.SalesOrder; transaction.OrderStatus = SalesStatus.Created; transaction.LockPrices = true; transaction.ExpirationDate = DateTime.Today; transaction.RequestedDeliveryDate = DateTime.Today; transaction.BeginDateTime = DateTime.Now; transaction.Comment = string.Empty; StoreDataManager storeDataManager = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); // Customer info ICustomer customer = SalesOrder.InternalApplication.BusinessLogic.CustomerSystem .GetCustomerInfo(invoice.InvoiceAccount); SalesOrder.InternalApplication.BusinessLogic.CustomerSystem .SetCustomer(transaction, customer, customer); // Items foreach (InvoiceItem item in invoice.Items) { AddSalesItemToTransaction( invoice.InvoiceId, transaction, storeDataManager, item); } SalesOrder.InternalApplication.BusinessLogic.ItemSystem.CalculatePriceTaxDiscount(transaction); transaction.CalculateAmountDue(); return(transaction); }
private static void CloseOrder(ICustomerOrderTransaction transaction) { CustomerOrderTransaction cot = transaction as CustomerOrderTransaction; if (cot == null) { NetTracer.Warning("CustomerOrderTransaction is null"); throw new ArgumentNullException("CustomerOrderTransaction"); } cot.EntryStatus = PosTransaction.TransactionStatus.Cancelled; }
/// <summary> /// Add the default cancellation charge configured for this store /// </summary> /// <param name="transaction"></param> private static void AddDefaultCancellationCharge(CustomerOrderTransaction transaction) { Contracts.IApplication app = SalesOrder.InternalApplication; Tax.MiscellaneousCharge charge = transaction.MiscellaneousCharges.SingleOrDefault( m => string.Equals(m.ChargeCode, ApplicationSettings.Terminal.CancellationChargeCode, StringComparison.OrdinalIgnoreCase)); // if there is not already a charge on this order, then attempt to add the default charge if (charge == null && transaction.OrderType == CustomerOrderType.SalesOrder) { // Get Cancellation charge properties from DB StoreDataManager store = new StoreDataManager( app.Settings.Database.Connection, app.Settings.Database.DataAreaID); DataEntity.MiscellaneousCharge chargeProperties = store.GetMiscellaneousCharge( ApplicationSettings.Terminal.CancellationChargeCode); if (chargeProperties != null) { // Compute the default charge rate decimal chargePercent = ApplicationSettings.Terminal.CancellationCharge; decimal chargeAmount = decimal.Zero; if (chargePercent >= decimal.Zero) { chargeAmount = (transaction.NetAmountWithTaxAndCharges * chargePercent) / 100m; chargeAmount = app.Services.Rounding.Round(chargeAmount, transaction.StoreCurrencyCode); } // construct and add the new charge charge = (Tax.MiscellaneousCharge)app.BusinessLogic.Utility.CreateMiscellaneousCharge( chargeAmount, transaction.Customer.SalesTaxGroup, chargeProperties.TaxItemGroup, chargeProperties.MarkupCode, string.Empty, transaction); // Set the proper SalesTaxGroup based on the store/customer settings SalesOrder.InternalApplication.BusinessLogic.CustomerSystem.ResetCustomerTaxGroup(charge); transaction.MiscellaneousCharges.Add(charge); } else { NetTracer.Information("chargeProperties is null"); } } }
private void btnCancelOrder_Click(object sender, EventArgs e) { //Get order //set Mode = Cancel CustomerOrderTransaction cot = SalesOrderActions.GetCustomerOrder(this.SelectedSalesOrderId, this.SelectedOrderType, LSRetailPosis.Transaction.CustomerOrderMode.Cancel); if (cot.OrderStatus == SalesStatus.Processing) { //Order cannot be cancelled at this time from POS SalesOrder.InternalApplication.Services.Dialog.ShowMessage(56237, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } SalesOrderActions.ShowOrderDetails(cot, OrderDetailsSelection.CancelOrder); SetSelectedOrderAndClose(cot); }
/// <summary> /// Constructor /// </summary> /// <param name="custTransaction">Transaction for this view model</param> /// <param name="saleLineItem">Sale line item for this view model if applicable</param> /// <remarks>If saleLineItem is not null then view model wraps line not transaction</remarks> public ShippingInformationViewModel(CustomerOrderTransaction custTransaction, SaleLineItem saleLineItem) { this.transaction = custTransaction; this.lineItem = saleLineItem; this.ShippingAddress = (saleLineItem == null) ? custTransaction.ShippingAddress : saleLineItem.ShippingAddress; // Load delivery date and set DeliveryDate property so validation is checked if (saleLineItem == null) { if (custTransaction.RequestedDeliveryDate > DateTime.MinValue) { this.DeliveryDate = custTransaction.RequestedDeliveryDate; } } else { if (saleLineItem.DeliveryDate.HasValue && saleLineItem.DeliveryDate.Value > DateTime.MinValue) { this.DeliveryDate = saleLineItem.DeliveryDate.Value; } } // Load delivery charge string shippingChargeCode = LSRetailPosis.Settings.ApplicationSettings.Terminal.ShippingChargeCode; Tax.MiscellaneousCharge mc = (saleLineItem == null) ? custTransaction.MiscellaneousCharges.SingleOrDefault(m => m.ChargeCode == shippingChargeCode) : lineItem.MiscellaneousCharges.SingleOrDefault(m => m.ChargeCode == shippingChargeCode); if (mc != null) { this.shippingCharge = mc.Price; } // Get list of addresses storeDataManager = new DM.StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); // Create a read-only collection GetValidDeliveryModes(); //deliveryModes = new ReadOnlyCollection<DeliveryModeExploded>(storeDataManager.GetDeliveryModes()); // Load delivery method and set ShippingMethod property so validation is checked //this.ShippingMethod = (DeliveryMode)((saleLineItem == null) ? custTransaction.DeliveryMode : saleLineItem.DeliveryMode); this.ShippingMethod = new DeliveryModeExploded((DeliveryMode)((saleLineItem == null) ? custTransaction.DeliveryMode : saleLineItem.DeliveryMode)); }
/// <summary> /// Updates serial numbers for items in transaction. /// </summary> /// <remarks>This function will ask user to confirm serial numbers for every sales line to be picked up in transaction.</remarks> /// <param name="transaction">The customer order transaction.</param> private void UpdateSerialNumbers(CustomerOrderTransaction transaction) { if (transaction == null) { return; } if (transaction.Mode == CustomerOrderMode.Pickup) { IEnumerable <SaleLineItem> pickupSaleItems = transaction.SaleItems.Where( item => item.Quantity != 0 && ApplicationSettings.Terminal.PickupDeliveryModeCode.Equals(item.DeliveryMode.Code)); foreach (var saleLineItem in pickupSaleItems) { SalesOrder.InternalApplication.Services.Item.UpdateSerialNumberInfo(saleLineItem); } } }
private static void RecalculatePrices(ICustomerOrderTransaction transaction) { CustomerOrderTransaction cot = transaction as CustomerOrderTransaction; if (cot != null) { if (cot.OrderStatus == SalesStatus.Created || cot.OrderStatus == SalesStatus.Unknown) { cot.LockPrices = false; // discounts which already exist on the transaction could have been recalled from AX, // but we don't know which ones, so to avoid over-discounting, we remove all before recalculating the order cot.ClearAllDiscounts(); SalesOrder.InternalApplication.BusinessLogic.ItemSystem.CalculatePriceTaxDiscount(transaction); } else { //Operation is not allowed for the current order status. SalesOrder.InternalApplication.Services.Dialog.ShowMessage(56246); } } }
internal static ICustomerOrderTransaction ShowOrderDetailsOptions(ICustomerOrderTransaction transaction) { using (formOrderDetailsSelection frm = new formOrderDetailsSelection()) { ICustomerOrderTransaction result = transaction; POSFormsManager.ShowPOSForm(frm); if (frm.DialogResult == DialogResult.OK) { // when in cancel mode, we only allow to enter view details, cancel or close order modes. bool allowedOnCancelMode = IsSelectionAllowedOnCancelOrderMode(frm.Selection); CustomerOrderTransaction cot = transaction as CustomerOrderTransaction; if (cot != null && cot.Mode == CustomerOrderMode.Cancel && !allowedOnCancelMode) { SalesOrder.InternalApplication.Services.Dialog.ShowMessage(4543); return(result); } switch (frm.Selection) { case OrderDetailsSelection.ViewDetails: SalesOrderActions.ShowOrderDetails(transaction, frm.Selection); break; case OrderDetailsSelection.CloseOrder: CloseOrder(transaction); break; case OrderDetailsSelection.Recalculate: RecalculatePrices(transaction); break; default: break; } } return(result); } }
internal static void ShowOrderDetails(ICustomerOrderTransaction transaction, OrderDetailsSelection selectionMode) { CustomerOrderTransaction cot = (CustomerOrderTransaction)transaction; using (formOrderDetails frm = new formOrderDetails(cot, selectionMode)) { POSFormsManager.ShowPOSForm(frm); DialogResult result = frm.DialogResult; // Get updated transaction since nested operations might have been run transaction = frm.Transaction; if (result == DialogResult.OK) { // Update the editing mode of the order. UpdateCustomerOrderMode(cot, selectionMode); // Refresh prices/totals SalesOrder.InternalApplication.BusinessLogic.ItemSystem.CalculatePriceTaxDiscount(transaction); // call CalcTotal to roll up misc charge taxes transaction.CalcTotals(); // Reminder prompt for Deposit Override w/ Zero deposit applied if (selectionMode == OrderDetailsSelection.PickupOrder && cot.PrepaymentAmountOverridden && cot.PrepaymentAmountApplied == decimal.Zero) { SalesOrder.InternalApplication.Services.Dialog.ShowMessage(56139, MessageBoxButtons.OK, MessageBoxIcon.Information); //"No deposit has been applied to this pickup. To apply a deposit, use the ""Deposit override"" operation." } } else { // Set cancel on the transaction so the original is not updated transaction.OperationCancelled = true; } } }
private static void UpdateCustomerOrderMode(CustomerOrderTransaction cot, OrderDetailsSelection selectionMode) { switch (selectionMode) { case OrderDetailsSelection.CancelOrder: { cot.Mode = CustomerOrderMode.Cancel; } break; case OrderDetailsSelection.ViewDetails: { // if the order was cancelled before, we shouldn't change this mode when just viewing the order. if (cot.Mode != CustomerOrderMode.Cancel) { if (cot.OriginalOrderType == CustomerOrderType.Quote && cot.OrderType == CustomerOrderType.SalesOrder && !string.IsNullOrWhiteSpace(cot.QuotationId)) { // Change mode to 'Convert', if user is converting a Quote to a SalesOrder cot.Mode = CustomerOrderMode.Convert; } else if (cot.Mode == CustomerOrderMode.Convert) { // Change mode to 'Edit', if user converted from Quote to SalesOrder and then back to Quote. cot.Mode = CustomerOrderMode.Edit; } } } break; case OrderDetailsSelection.PickupOrder: //Pickup mode has already been handled by the ItemDetailsPage on frmOrderDetails default: break; } }
public CustomerInformationViewModel(CustomerOrderTransaction customerTransaction) { this.SetTransaction(customerTransaction); }
public OrderSummaryViewModel(CustomerOrderTransaction customerOrderTransaction) { this.SetTransaction(customerOrderTransaction); }
internal static CustomerOrderInfo GetInfoFromTransaction(CustomerOrderTransaction customerOrder) { CustomerOrderInfo parameters = new CustomerOrderInfo(); //GRW DAC odac = new DAC(SalesOrder.InternalApplication.Settings.Database.Connection); DataTable dt = odac.GetContactData(customerOrder.TransactionId, customerOrder.TerminalId, customerOrder.StoreId); if (dt.Rows.Count > 0) { parameters.CustName = dt.Rows[0]["NAME"].ToString(); parameters.CustPhone = dt.Rows[0]["PHONE"].ToString(); parameters.Email = dt.Rows[0]["EMAIL"].ToString(); } //GRW parameters.OrderType = customerOrder.OrderType; parameters.Id = customerOrder.OrderId; parameters.TransactionId = customerOrder.TransactionId; parameters.QuotationId = customerOrder.OrderId; parameters.AutoPickOrder = false; parameters.WarehouseId = customerOrder.WarehouseId; parameters.CurrencyCode = customerOrder.StoreCurrencyCode; parameters.StoreId = customerOrder.StoreId; parameters.TerminalId = customerOrder.TerminalId; parameters.LocalHourOfDay = customerOrder.LocalHourOfDay; parameters.AddressRecordId = (customerOrder.ShippingAddress != null) ? customerOrder.ShippingAddress.AddressRecId : string.Empty; parameters.CustomerAccount = (customerOrder.Customer != null) ? customerOrder.Customer.CustomerId : string.Empty; parameters.SalespersonStaffId = (customerOrder.SalesPersonId) ?? string.Empty; // The format must match the expected format in AX RetailTransactionService.CreateCustomerOrder: "dd/MM/yyyy" parameters.ExpiryDateString = customerOrder.ExpirationDate.ToString(FixedDateFormat); parameters.RequestedDeliveryDateString = customerOrder.RequestedDeliveryDate.ToString(FixedDateFormat); parameters.DeliveryMode = customerOrder.DeliveryMode != null ? customerOrder.DeliveryMode.Code : string.Empty; parameters.PrepaymentAmountOverridden = customerOrder.PrepaymentAmountOverridden; parameters.PrepaymentAmountApplied = customerOrder.NetAmountWithTaxAndCharges - customerOrder.AmountDue; parameters.TotalManualDiscountAmount = customerOrder.TotalManualDiscountAmount; parameters.TotalManualDiscountPercentage = customerOrder.TotalManualPctDiscount; //parameters.Email = customerOrder.ReceiptEmailAddress; parameters.Comment = ((IPosTransactionV1)customerOrder).Comment; parameters.ReturnReasonCodeId = customerOrder.ReturnReasonCodeId; parameters.LoyaltyCardId = (customerOrder.LoyaltyItem != null) ? customerOrder.LoyaltyItem.LoyaltyCardNumber : string.Empty; // If we do not have the channel reference identifier, we create a new receipt identifier instead. parameters.ChannelReferenceId = customerOrder.ChannelReferenceId; parameters.CreditCardToken = customerOrder.CreditCardToken; // Discount codes parameters.DiscountCodes = new Collection <string>(); foreach (string code in customerOrder.DiscountCodes) { parameters.DiscountCodes.Add(code); } // Line Items parameters.Items = new Collection <ItemInfo>(); foreach (SaleLineItem item in customerOrder.SaleItems) { if (!item.Voided) { string deliveryMode = parameters.DeliveryMode; if (item.DeliveryMode != null) { deliveryMode = item.DeliveryMode.Code; } string deliveryDateString = parameters.RequestedDeliveryDateString; if (item.DeliveryDate.HasValue) { deliveryDateString = item.DeliveryDate.Value.ToString(FixedDateFormat); } Collection <ChargeInfo> lineChargeInfo = new Collection <ChargeInfo>(); foreach (Tax.MiscellaneousCharge charge in item.MiscellaneousCharges) { lineChargeInfo.Add(new ChargeInfo() { Amount = charge.Amount, Code = charge.ChargeCode, SalesTaxGroup = charge.SalesTaxGroupId, TaxGroup = charge.TaxGroupId }); } // If no line-level warehouse is specified, fall back to the header warehouse string inventLocationId = string.IsNullOrWhiteSpace(item.DeliveryWarehouse) ? customerOrder.WarehouseId : item.DeliveryWarehouse; // AX SO line stores discount amount per item, POS stores for whole line, calculate per item discount amount decimal lineDiscount = (item.Quantity == 0M ? 0M : (item.TotalDiscount + item.LineDiscount + item.PeriodicDiscount) / (item.Quantity)); // Save all discount lines per sales line Collection <DiscountInfo> lineDiscountInfo = new Collection <DiscountInfo>(); foreach (DiscountItem discountLine in item.DiscountLines) { DiscountInfo discountInfo = new DiscountInfo(); discountInfo.DiscountCode = string.Empty; discountInfo.PeriodicDiscountOfferId = string.Empty; discountInfo.EffectiveAmount = discountLine.EffectiveAmount; discountInfo.DealPrice = discountLine.DealPrice; discountInfo.Percentage = discountLine.Percentage; discountInfo.DiscountAmount = discountLine.Amount; LineDiscountItem lineDiscountItem; PeriodicDiscountItem periodicDiscountItem; CustomerDiscountItem customerDiscountItem; if ((lineDiscountItem = discountLine as LineDiscountItem) != null) { discountInfo.DiscountOriginType = (int)lineDiscountItem.LineDiscountType; if ((periodicDiscountItem = discountLine as PeriodicDiscountItem) != null) { discountInfo.PeriodicDiscountOfferId = periodicDiscountItem.OfferId; discountInfo.DiscountCode = periodicDiscountItem.DiscountCode; } else if ((customerDiscountItem = discountLine as CustomerDiscountItem) != null) { discountInfo.CustomerDiscountType = (int)customerDiscountItem.CustomerDiscountType; } else { discountInfo.DiscountOriginType = (int)LineDiscountItem.DiscountTypes.Manual; discountInfo.ManualDiscountType = (int)discountLine.GetManualDiscountType(); } } if (discountLine is TotalDiscountItem) { discountInfo.DiscountOriginType = (int)LineDiscountItem.DiscountTypes.Manual; discountInfo.ManualDiscountType = (int)discountLine.GetManualDiscountType(); } lineDiscountInfo.Add(discountInfo); } parameters.Items.Add(new ItemInfo() { RecId = item.OrderLineRecordId, //quantity ItemId = item.ItemId, Quantity = item.Quantity, Unit = item.SalesOrderUnitOfMeasure, //pricing Price = item.Price, Discount = lineDiscount, NetAmount = item.NetAmount, ItemTaxGroup = item.TaxGroupId, SalesTaxGroup = item.SalesTaxGroupId, SalesMarkup = item.SalesMarkup, PeriodicDiscount = item.PeriodicDiscount, LineDscAmount = item.LineDiscount, LineManualDiscountAmount = item.LineManualDiscountAmount, LineManualDiscountPercentage = item.LineManualDiscountPercentage, TotalDiscount = item.TotalDiscount, TotalPctDiscount = item.TotalPctDiscount, PeriodicPercentageDiscount = item.PeriodicPctDiscount, //Comment Comment = item.Comment, //delivery WarehouseId = inventLocationId, AddressRecordId = item.ShippingAddress != null ? item.ShippingAddress.AddressRecId : null, DeliveryMode = deliveryMode, RequestedDeliveryDateString = deliveryDateString, //inventDim BatchId = item.BatchId, SerialId = item.SerialId, VariantId = item.Dimension.VariantId, ColorId = item.Dimension.ColorId, SizeId = item.Dimension.SizeId, StyleId = item.Dimension.StyleId, ConfigId = item.Dimension.ConfigId, //Return InvoiceId = item.ReturnInvoiceId, InventTransId = item.ReturnInvoiceInventTransId, //line-level misc. charges Charges = lineChargeInfo, //line-level discounts Discounts = lineDiscountInfo, }); } } // Header level Misc Charges parameters.Charges = new Collection <ChargeInfo>(); foreach (Tax.MiscellaneousCharge charge in customerOrder.MiscellaneousCharges) { parameters.Charges.Add(new ChargeInfo() { Code = charge.ChargeCode, Amount = charge.Amount, SalesTaxGroup = charge.SalesTaxGroupId, TaxGroup = charge.TaxGroupId }); } string CardType = ""; // Payments parameters.Payments = new Collection <PaymentInfo>(); foreach (ITenderLineItem tender in customerOrder.TenderLines) { CardType = ""; if (!tender.Voided) { ICardTenderLineItem cardTender = tender as ICardTenderLineItem; if (cardTender != null && cardTender.EFTInfo.IsAuthOnly) { // This is a Pre-Authorization record. IEFTInfo eft = cardTender.EFTInfo; parameters.Preauthorization = new Preauthorization() { PaymentPropertiesBlob = eft.PaymentProviderPropertiesXML }; } else if (tender.Amount != decimal.Zero) { // This is an actual payment record. DAC odac2 = new DAC(ApplicationSettings.Database.LocalConnection); CardType = odac2.getCardType(customerOrder.TransactionId, customerOrder.TerminalId, customerOrder.StoreId, tender.LineId, tender.TenderTypeId); parameters.Payments.Add(new PaymentInfo() { PaymentType = tender.TenderTypeId, Amount = string.IsNullOrEmpty(tender.CurrencyCode) ? tender.Amount : tender.ForeignCurrencyAmount, Currency = (tender.CurrencyCode) ?? string.Empty, CardType = string.IsNullOrEmpty(CardType) ? "":CardType }); } } } // Affiliations parameters.Affiliations = new Collection <AffiliationInfo>(); foreach (IAffiliation affiliation in customerOrder.AffiliationLines) { parameters.Affiliations.Add(new AffiliationInfo() { AffiliationId = affiliation.RecId, LoyaltyTierId = affiliation.LoyaltyTier }); } return(parameters); }
internal static CustomerOrderTransaction GetTransactionFromInfo(CustomerOrderInfo orderInfo, SalesOrder salesOrderService) { CustomerOrderTransaction transaction = (CustomerOrderTransaction)SalesOrder.InternalApplication.BusinessLogic.Utility.CreateCustomerOrderTransaction( ApplicationSettings.Terminal.StoreId, ApplicationSettings.Terminal.StoreCurrency, ApplicationSettings.Terminal.TaxIncludedInPrice, SalesOrder.InternalApplication.Services.Rounding, salesOrderService); // Get all the defaults SalesOrder.InternalApplication.BusinessLogic.TransactionSystem.LoadTransactionStatus(transaction); // General header properties transaction.OrderId = orderInfo.Id; transaction.OrderType = orderInfo.OrderType; if (orderInfo.OrderType == CustomerOrderType.Quote) { transaction.QuotationId = orderInfo.Id; } transaction.OriginalOrderType = orderInfo.OrderType; switch (orderInfo.OrderType) { case CustomerOrderType.Quote: transaction.OrderStatus = GetSalesStatus((SalesQuotationStatus)orderInfo.Status); break; case CustomerOrderType.SalesOrder: transaction.OrderStatus = GetSalesStatus((SalesOrderStatus)orderInfo.Status, (DocumentStatus)orderInfo.DocumentStatus); break; default: transaction.OrderStatus = SalesStatus.Unknown; NetTracer.Information("SalesOrder::CustomerOrderTransaction: CustomerOrderInfo OrderType is unknown: {0}", orderInfo.OrderType); break; } transaction.LockPrices = true; transaction.ExpirationDate = ParseDateString(orderInfo.ExpiryDateString, DateTime.Today); // RequestedDeliveryDate is directly input from user. It is stored in the local timezone transaction.RequestedDeliveryDate = ParseDateString(orderInfo.RequestedDeliveryDateString, DateTime.Today); // CreationDate is stored in UTC. It needs to be converted to local time zone where order is accessed. ((IPosTransactionV2)transaction).BeginDateTime = ParseDateString(orderInfo.CreationDateString, DateTime.UtcNow, DateTimeStyles.AdjustToUniversal).ToLocalTime(); transaction.LocalHourOfDay = orderInfo.LocalHourOfDay; ((IPosTransactionV2)transaction).Comment = orderInfo.Comment; // Header delivery DM.StoreDataManager storeDataManager = new DM.StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); transaction.WarehouseId = orderInfo.WarehouseId; transaction.DeliveryMode = storeDataManager.GetDeliveryMode(orderInfo.DeliveryMode); transaction.CurrencyCode = orderInfo.CurrencyCode; foreach (var code in orderInfo.DiscountCodes) { transaction.DiscountCodes.AddLast(code); } // Header affiliation DM.AffiliationDataManager affiliationDataManager = new DM.AffiliationDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); if (orderInfo.Affiliations != null && orderInfo.Affiliations.Any()) { foreach (AffiliationInfo affiliationInfo in orderInfo.Affiliations) { transaction.AffiliationLines.AddLast( new AffiliationItem() { RecId = affiliationInfo.AffiliationId, LoyaltyTier = affiliationInfo.LoyaltyTierId, AffiliationType = affiliationInfo.AffiliationType }); } } // Customer info ICustomerSystem customerSystem = SalesOrder.InternalApplication.BusinessLogic.CustomerSystem; DM.CustomerDataManager customerDataManager = new DM.CustomerDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); DE.ICustomer customer = customerSystem.GetCustomerInfo(orderInfo.CustomerAccount); // try to get the customer from transaction service if (customer == null || customer.IsEmptyCustomer()) { DE.ICustomer tempCustomer = SalesOrder.GetCustomerFromAX(orderInfo.CustomerAccount, customerSystem, customerDataManager); if (tempCustomer != null) { customer = tempCustomer; } } DE.ICustomer invoicedCustomer = customerSystem.GetCustomerInfo(customer.InvoiceAccount); // try to get the invoicedCustomer from transaction service if (invoicedCustomer == null || invoicedCustomer.IsEmptyCustomer()) { DE.ICustomer tempinvoicedCustomer = SalesOrder.GetCustomerFromAX(customer.InvoiceAccount, customerSystem, customerDataManager); if (tempinvoicedCustomer != null) { invoicedCustomer = tempinvoicedCustomer; } } // If InvoiceCustomer is *still* blank/empty then fallback to Customer so that the UI fields are populated. if (invoicedCustomer == null || invoicedCustomer.IsEmptyCustomer()) { invoicedCustomer = customer; } customerSystem.SetCustomer(transaction, customer, invoicedCustomer); if (transaction.DeliveryMode != null && !string.IsNullOrWhiteSpace(orderInfo.AddressRecordId)) { DE.IAddress shippingAddress = customerDataManager.GetAddress(Int64.Parse(orderInfo.AddressRecordId)); customerSystem.SetShippingAddress(transaction, shippingAddress); } if (!string.IsNullOrEmpty(orderInfo.SalespersonStaffId)) { // Sets the sales person id and name according to AX values // This is done because we do not know whether the sales person information is available on this store transaction.SalesPersonId = orderInfo.SalespersonStaffId; transaction.SalesPersonName = orderInfo.SalespersonName; DM.EmployeeDataManager employees = new DM.EmployeeDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); Employee employee = employees.GetEmployee(ApplicationSettings.Terminal.StoreId, orderInfo.SalespersonStaffId); if (employee != null) { transaction.SalesPersonId = employee.StaffId; transaction.SalesPersonName = employee.Name; transaction.SalesPersonNameOnReceipt = employee.NameOnReceipt; } } transaction.ChannelReferenceId = orderInfo.ChannelReferenceId; if (transaction.LoyaltyItem != null && !string.IsNullOrEmpty(orderInfo.LoyaltyCardId)) { transaction.LoyaltyItem.LoyaltyCardNumber = orderInfo.LoyaltyCardId; } transaction.ReceiptEmailAddress = orderInfo.Email; transaction.TotalManualDiscountAmount = orderInfo.TotalManualDiscountAmount; transaction.TotalManualPctDiscount = orderInfo.TotalManualDiscountPercentage; DateTime earliestDeliveryDate = DateTime.MaxValue; // Items foreach (ItemInfo item in orderInfo.Items) { Collection <Tax.MiscellaneousCharge> lineCharges = new Collection <Tax.MiscellaneousCharge>(); foreach (ChargeInfo charge in item.Charges) { Tax.MiscellaneousCharge lineCharge = (Tax.MiscellaneousCharge)SalesOrder.InternalApplication.BusinessLogic.Utility.CreateMiscellaneousCharge( charge.Amount, charge.SalesTaxGroup, charge.TaxGroup, charge.Code, string.Empty, transaction); lineCharges.Add(lineCharge); } // add item SaleLineItem lineItem = (SaleLineItem)SalesOrder.InternalApplication.BusinessLogic.Utility.CreateSaleLineItem( ApplicationSettings.Terminal.StoreCurrency, SalesOrder.InternalApplication.Services.Rounding, transaction); lineItem.Found = true; lineItem.OrderLineRecordId = item.RecId; lineItem.ItemId = item.ItemId; lineItem.Quantity = item.Quantity; lineItem.ReturnQtyAllowed = item.Quantity; lineItem.SalesOrderUnitOfMeasure = item.Unit; lineItem.Price = item.Price; lineItem.NetAmount = item.NetAmount; lineItem.QuantityOrdered = item.Quantity; lineItem.QuantityPickedUp = item.QuantityPicked; lineItem.DeliveryMode = storeDataManager.GetDeliveryMode(item.DeliveryMode); lineItem.DeliveryDate = ParseDateString(item.RequestedDeliveryDateString, DateTime.Today); lineItem.DeliveryStoreNumber = item.StoreId; lineItem.DeliveryWarehouse = item.WarehouseId; lineItem.SerialId = item.SerialId; lineItem.BatchId = item.BatchId; lineItem.HasBeenRecalled = true; lineItem.SalesMarkup = item.SalesMarkup; lineItem.Comment = string.IsNullOrEmpty(item.Comment) ? string.Empty : item.Comment; lineItem.LineStatus = GetSalesStatus((SalesOrderStatus)item.Status); lineItem.LineDiscount = item.LineDscAmount; lineItem.PeriodicDiscount = item.PeriodicDiscount; lineItem.PeriodicPctDiscount = item.PeriodicPercentageDiscount; lineItem.LineManualDiscountAmount = item.LineManualDiscountAmount; lineItem.LineManualDiscountPercentage = item.LineManualDiscountPercentage; lineItem.TotalDiscount = item.TotalDiscount; lineItem.TotalPctDiscount = item.TotalPctDiscount; foreach (Tax.MiscellaneousCharge charge in lineCharges) { lineItem.MiscellaneousCharges.Add(charge); } if (lineItem.DeliveryMode != null && !string.IsNullOrWhiteSpace(item.AddressRecordId)) { lineItem.ShippingAddress = customerDataManager.GetAddress(Int64.Parse(item.AddressRecordId)); } lineItem.Dimension.VariantId = item.VariantId; lineItem.Dimension.ColorId = item.ColorId; lineItem.Dimension.StyleId = item.StyleId; lineItem.Dimension.SizeId = item.SizeId; lineItem.Dimension.ConfigId = item.ConfigId; lineItem.Dimension.ColorName = item.ColorName; lineItem.Dimension.StyleName = item.StyleName; lineItem.Dimension.SizeName = item.SizeName; lineItem.Dimension.ConfigName = item.ConfigName; if (!string.IsNullOrEmpty(lineItem.Dimension.VariantId)) { Dimensions dimension = (Dimensions)SalesOrder.InternalApplication.BusinessLogic.Utility.CreateDimension(); dimension.VariantId = lineItem.Dimension.VariantId; SalesOrder.InternalApplication.Services.Dimension.GetDimensionForVariant(dimension); lineItem.Dimension = dimension; } if (item.Discounts.Count > 0) { lineItem.QuantityDiscounted = item.Quantity; lineItem.LinePctDiscount = lineItem.CalculateLinePercentDiscount(); } // create discount line from discount info object foreach (DiscountInfo discountInfo in item.Discounts) { DiscountItem discountItem = ConvertToDiscountItem( discountInfo.DiscountOriginType, discountInfo.ManualDiscountType, discountInfo.CustomerDiscountType, discountInfo.EffectiveAmount, discountInfo.DealPrice, discountInfo.DiscountAmount, discountInfo.Percentage, discountInfo.PeriodicDiscountOfferId, discountInfo.OfferName, discountInfo.DiscountCode); SalesOrder.InternalApplication.Services.Discount.AddDiscountLine(lineItem, discountItem); } // Set other default properties for this item SalesOrder.InternalApplication.Services.Item.ProcessItem(lineItem, bypassSerialNumberEntry: true); // Set tax info after defaults, as it may have been overridden. lineItem.SalesTaxGroupId = item.SalesTaxGroup; lineItem.SalesTaxGroupIdOriginal = item.SalesTaxGroup; lineItem.TaxGroupId = item.ItemTaxGroup; lineItem.TaxGroupIdOriginal = item.ItemTaxGroup; // Add it to the transaction transaction.Add(lineItem); if (lineItem.DeliveryDate < earliestDeliveryDate) { earliestDeliveryDate = lineItem.DeliveryDate.HasValue ? lineItem.DeliveryDate.Value : earliestDeliveryDate; } } // Once Items are populated - Reset Customer Tax Group //GRW Linea comentada para poder recoger la orden de venta en una tienda distinta a la configurada en AX //customerSystem.ResetCustomerTaxGroup(transaction); // The order can be created through some other channel other than POS which has set header delivery date as NoDate. // This must not be interpreted as a valid date. Instead the earliestDeliveryDate is used. if (transaction.RequestedDeliveryDate == NoDate) { transaction.RequestedDeliveryDate = earliestDeliveryDate; } // Charges foreach (ChargeInfo charge in orderInfo.Charges) { // add charges Tax.MiscellaneousCharge newCharge = (Tax.MiscellaneousCharge)SalesOrder.InternalApplication.BusinessLogic.Utility.CreateMiscellaneousCharge( charge.Amount, charge.SalesTaxGroup, charge.TaxGroup, charge.Code, string.Empty, transaction); transaction.Add(newCharge); } SalesOrder.InternalApplication.BusinessLogic.ItemSystem.CalculatePriceTaxDiscount(transaction); transaction.CalculateAmountDue(); // Payments // - total up amounts // - add history entries transaction.PrepaymentAmountPaid = decimal.Zero; transaction.PrepaymentAmountInvoiced = decimal.Zero; decimal nonPrepayments = decimal.Zero; PaymentInfo pinfo = new PaymentInfo(); pinfo.Amount = -111; pinfo.Currency = "MXN"; orderInfo.Payments.Add(pinfo); foreach (PaymentInfo payment in orderInfo.Payments) { // sum up payments decimal amount = (string.IsNullOrWhiteSpace(payment.Currency)) ? payment.Amount : (SalesOrder.InternalApplication.Services.Currency.CurrencyToCurrency( payment.Currency, ApplicationSettings.Terminal.StoreCurrency, payment.Amount)); if (payment.Prepayment) { // Sum prepayments to track total deposits paid transaction.PrepaymentAmountPaid += amount; } else { // Sum non-prepayments as base for calculating deposits applied to pickups nonPrepayments += amount; } CustomerOrderPaymentHistory paymentHistory = (CustomerOrderPaymentHistory)SalesOrder.InternalApplication.BusinessLogic.Utility.CreateCustomerOrderPaymentHistory(); paymentHistory.Amount = payment.Amount; paymentHistory.Currency = payment.Currency; paymentHistory.Date = ParseDateString(payment.DateString, DateTime.MinValue); paymentHistory.Balance = transaction.NetAmountWithTaxAndCharges - transaction.PrepaymentAmountPaid; transaction.PaymentHistory.Add(paymentHistory); } // Prepayment/Deposit override info transaction.PrepaymentAmountOverridden = orderInfo.PrepaymentAmountOverridden; if (transaction.PrepaymentAmountOverridden) { transaction.PrepaymentAmountRequired = transaction.PrepaymentAmountPaid; } // Amount that has been previously invoiced (picked-up) transaction.PreviouslyInvoicedAmount = orderInfo.PreviouslyInvoicedAmount; // Portion of the prepayment that has been applied to invoices. // If .PrepaymentAmountApplied is non-NULL then use the explicit amount, otherwise fall back to computing the amount based on payment history. transaction.PrepaymentAmountInvoiced = orderInfo.PrepaymentAmountApplied ?? (transaction.PreviouslyInvoicedAmount - nonPrepayments); transaction.HasLoyaltyPayment = orderInfo.HasLoyaltyPayment; return(transaction); }