public static StoreTransfer UpdateStoreTransfer(Dictionary <string, string> values) { string stNumber = values["STNumber"]; string stId = values["STID"]; StoreTransfer ST = GetStoreTransfer(stNumber); ST.Id = string.IsNullOrEmpty(stId) ? 0 : int.Parse(stId); ST.STDate = values.ContainsKey("Date") ? DateTime.Parse(values["Date"]) : DateTime.Now; ST.Customer = values.ContainsKey("Customer") ? CustomerManager.GetCustomerRef(values["Customer"]) : CustomerManager.GetDefaultRef(); ST.Origin = values.ContainsKey("Origin") ? CommonDataManager.GetOrigin(values["Origin"]) : CommonDataManager.GetDefaultRef(); ST.Size = values.ContainsKey("Size") ? CommonDataManager.GetOrigin(values["Size"]) : CommonDataManager.GetDefaultRef(); ST.Vessel = values.ContainsKey("Vessel") ? CommonDataManager.GetOrigin(values["Vessel"]) : CommonDataManager.GetDefaultRef(); ST.Quantity = values.ContainsKey("Quantity") ? decimal.Parse(values["Quantity"]) : 0; ST.FromStoreId = values.ContainsKey("FromStore") ? GetStoreRef(values["FromStore"]) : GetDefaultRef(); ST.ToStoreId = values.ContainsKey("ToStore") ? GetStoreRef(values["ToStore"]) : GetDefaultRef(); ST.VehicleNo = values.ContainsKey("VehicleNo") ? values["VehicleNo"] : ""; ST.BiltyNo = values.ContainsKey("BiltyNo") ? values["BiltyNo"] : ""; ST.BiltyDate = values.ContainsKey("BiltyDate") ? DateTime.Parse(values["BiltyDate"]) : DateTime.MinValue; ST.RRInvoice = values.ContainsKey("Invoice") ? values["Invoice"] : ""; ST.CCMNumber = values.ContainsKey("CCMNo") ? values["CCMNo"] : ""; ST.Transporter = values.ContainsKey("Transporter") ? CommonDataManager.GetTrader(values["Transporter"]) : CommonDataManager.GetDefaultRef(); ST.StoreInDate = DateTime.MinValue; ST.StoreInQuantity = 0; ST.Remarks = values.ContainsKey("Remarks") ? values["Remarks"] : ""; StoreDataManager.UpdateStoreTransfer(StoreMap.reMapStoreTransferData(ST)); ResetCache(); return(ST); }
/// <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 static StoreTransfer CreateStoreTransfer(Dictionary <string, string> values) { StoreTransfer ST = NewStoreTransfer(); ST.STDate = values.ContainsKey("Date") ? DateTime.Parse(values["Date"]) : DateTime.Now; ST.Customer = values.ContainsKey("Customer") ? CustomerManager.GetCustomerRef(values["Customer"]) : CustomerManager.GetDefaultRef(); ST.Origin = values.ContainsKey("Origin") ? CommonDataManager.GetOrigin(values["Origin"]) : CommonDataManager.GetDefaultRef(); ST.Size = values.ContainsKey("Size") ? CommonDataManager.GetOrigin(values["Size"]) : CommonDataManager.GetDefaultRef(); ST.Vessel = values.ContainsKey("Vessel") ? CommonDataManager.GetOrigin(values["Vessel"]) : CommonDataManager.GetDefaultRef(); ST.Quantity = values.ContainsKey("Quantity") ? decimal.Parse(values["Quantity"]) : 0; ST.FromStoreId = values.ContainsKey("FromStore") ? StoreManager.GetStoreRef(values["FromStore"]) : StoreManager.GetDefaultRef(); ST.ToStoreId = values.ContainsKey("ToStore") ? StoreManager.GetStoreRef(values["ToStore"]) : StoreManager.GetDefaultRef(); ST.VehicleNo = values.ContainsKey("VehicleNo") ? values["VehicleNo"] : ""; ST.BiltyNo = values.ContainsKey("BiltyNo") ? values["BiltyNo"] : ""; ST.BiltyDate = values.ContainsKey("BiltyDate") ? DateTime.Parse(values["BiltyDate"]) : DateTime.MinValue; ST.RRInvoice = values.ContainsKey("Invoice") ? values["Invoice"] : ""; ST.CCMNumber = values.ContainsKey("CCMNo") ? values["CCMNo"] : ""; ST.Transporter = values.ContainsKey("Transporter") ? CommonDataManager.GetTrader(values["Transporter"]) : CommonDataManager.GetDefaultRef(); ST.StoreInDate = DateTime.MinValue; ST.StoreInQuantity = 0; ST.Remarks = values.ContainsKey("Remarks") ? values["Remarks"] : ""; StoreDataManager.CreateStoreTransfer(StoreMap.reMapStoreTransferData(ST)); // ztodo: create store movement record ResetCache(); return(ST); }
/// <summary> /// Commits all changes to the line item. /// </summary> public void Commit() { string storeTaxGroup = string.Empty; StoreDataManager storeDataManager = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); //In case of mixed delivery mode, set transaction RequestedDeliveryDate to the earliest date of all line items in customer order instead of an arbitrary value if (this.DeliveryDate.HasValue && DateTime.Compare(this.transaction.RequestedDeliveryDate, this.DeliveryDate.Value) > 0) { this.transaction.RequestedDeliveryDate = this.DeliveryDate.Value; } else { if (this.transaction.RequestedDeliveryDate == DateTime.MinValue) { this.transaction.RequestedDeliveryDate = DateTime.Now.Date; } } this.saleLineItem.DeliveryDate = this.DeliveryDate; this.saleLineItem.Quantity = this.Quantity; this.saleLineItem.DeliveryStoreNumber = this.StoreNumber; if (this.IsShipping) { // if this line is shipping, then use the stores shipping warehouse setting this.saleLineItem.DeliveryWarehouse = ApplicationSettings.Terminal.InventLocationIdForCustomerOrder; this.saleLineItem.DeliveryStoreNumber = ApplicationSettings.Terminal.StoreId; this.saleLineItem.ShippingAddress = this.ShippingAddress; this.saleLineItem.DeliveryMode = storeDataManager.GetDeliveryMode(this.ShippingMethodCode); } else if (this.IsPickup) { if (string.IsNullOrWhiteSpace(ApplicationSettings.Terminal.PickupDeliveryModeCode)) { // "Pickup cannot be used for delivery because a pickup delivery code was not found." string errorMessage = LSRetailPosis.ApplicationLocalizer.Language.Translate(56382); SalesOrder.LogMessage(errorMessage, LSRetailPosis.LogTraceLevel.Error); throw new InvalidOperationException(errorMessage); } // if the delivery warehouse is not set, default to the store's warehouse this.saleLineItem.DeliveryWarehouse = (this.deliveryStore != null) ? this.deliveryStore.Warehouse : ApplicationSettings.Terminal.InventLocationId; this.saleLineItem.DeliveryMode = storeDataManager.GetDeliveryMode(ApplicationSettings.Terminal.PickupDeliveryModeCode); this.saleLineItem.ShippingAddress = this.shippingAddress; } // Set the proper SalesTaxGroup based on the store/customer settings SalesOrder.InternalApplication.BusinessLogic.CustomerSystem.ResetCustomerTaxGroup(this.saleLineItem); // Adds or removes shipping charge CommitShippingCharge(this.saleLineItem, this.transaction, this.ShippingCharge); }
public static Seiving CreateSeving(Seiving seiving) { StoreDataManager.CreateSeving(StoreMap.reMapSeivingData(seiving)); StoreDataManager.CreateSevingQuantity(StoreMap.reMapSeivingQuantityData(seiving.seivingSizeQty)); // ztodo: create store movement record ResetCache(); return(seiving); }
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); }
public static List <StoreTransfer> ReadAllStoreIO() { DataTable DTstoreIO = StoreDataManager.GetAllStoreInOut(); List <StoreTransfer> allStoreIOs = StoreMap.MapStoreTransferData(DTstoreIO); //foreach (StoreInOut storeIO in allStoreIOs) //{ // StoreInOut CalculatedStore = CalculateStoreQuantity(storeIO); // AllStores.Add(CalculatedStore); //} HttpContext.Current.Session.Add(SessionManager.StoreIOSession, allStoreIOs); return(allStoreIOs); }
/// <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"); } } }
public static List <Store> ReadAllStore() { DataTable DTstore = StoreDataManager.GetAllStore(); DataTable DTcustStock = StoreDataManager.GetAllCustomerStock(); DataTable DTstockMovement = StoreDataManager.GetAllStockMovements(); List <Store> allStores = StoreMap.MapStoreData(DTstore, DTcustStock, DTstockMovement); List <Store> calculatedStores = new List <Store>(); foreach (Store store in allStores) { Store CalculatedStore = CalculateStoreQuantity(store); calculatedStores.Add(CalculatedStore); } HttpContext.Current.Session.Add(SessionManager.StoreSession, calculatedStores); _allStores = calculatedStores; return(calculatedStores); }
private void LoadStores() { this.storeDataManager = new StoreDataManager( PosApplication.Instance.Settings.Database.Connection, PosApplication.Instance.Settings.Database.DataAreaID); this.stores = this.storeDataManager.GetStores(); this.storeIndexByNumber = new Dictionary <string, int>(); for (int i = 0; i < this.stores.Count; i++) { Store store = stores[i]; this.storeIndexByNumber[store.Number] = i; } this.selectedStore = this.storeDataManager.GetStore( ApplicationSettings.Terminal.StoreId); CreateStoreTable(); }
public formShippingInformation(ShippingInformationViewModel viewModel) : this() { this.dateTimePicker.MinDate = DateTime.Today; this.labelShipMethodValue.Text = string.Empty; // Handle the formatting and parsing for binding to the DateTimePicker so it knows how to handle nulls from a DateTime? value. this.dateTimePicker.DataBindings[DATABINDING_VALUEPROPERTY].Format += new ConvertEventHandler(OnDateTimePicker_Format); this.dateTimePicker.DataBindings[DATABINDING_VALUEPROPERTY].Parse += new ConvertEventHandler(OnDateTimePicker_Parse); // Toggle the charge button's text based on whether or not there is a charge this.btnChargeChange.DataBindings[DATABINDING_TEXTPROPERTY].Format += new ConvertEventHandler(OnShippingChargeButtonText_Format); // Bind to view model this.bindingSource.Add(viewModel); if (viewModel != null && viewModel.Transaction != null) { this.viewAddressUserControl1.SetProperties(viewModel.Transaction.Customer, viewModel.ShippingAddress); StoreDataManager storeDataManager = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); DAC odac = new DAC(SalesOrder.InternalApplication.Settings.Database.Connection); DataTable dt = odac.GetLineDataOV(viewModel.Transaction.TransactionId, viewModel.Transaction.TerminalId, viewModel.Transaction.StoreId, "1"); if (dt.Rows.Count > 0) { string DelMode = dt.Rows[0]["SHIPMODE"].ToString(); if (DelMode != "") { this.ViewModel.ShippingMethod = this.ViewModel.ShippingMethods.First(s => s.Code == DelMode); } } } viewModel.PropertyChanged += new PropertyChangedEventHandler(OnViewModel_PropertyChanged); }
void Awake() { _instance = this; _isReady = true; }
/// <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; bool IsPickupaux = false; string DelMode = ""; StoreDataManager storeDataManager = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); DAC odac = new DAC(SalesOrder.InternalApplication.Settings.Database.Connection); DataTable dt = odac.GetLineDataOV(custTransaction.TransactionId, custTransaction.TerminalId, custTransaction.StoreId, saleLineItem.LineId.ToString()); if (dt.Rows.Count > 0) { saleLineItem.DeliveryStoreNumber = dt.Rows[0]["STORENUMBER"].ToString(); IsPickupaux = dt.Rows[0]["ISPICKUP"].ToString() == "1"?true:false; DelMode = dt.Rows[0]["SHIPMODE"].ToString(); if (IsPickupaux) { IList <Microsoft.Dynamics.Retail.Pos.DataEntity.DeliveryMode> delmod = storeDataManager.GetDeliveryModes(); foreach (DeliveryMode mod in delmod) { if (mod.Code == DelMode) { saleLineItem.DeliveryMode = mod; } } } } 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 if (IsPickupaux) { this.IsPickup = IsPickupaux; this.IsShipping = !IsPickupaux; } else { this.IsPickup = hasPickupCode && hasDeliveryDate; this.IsShipping = !hasPickupCode && hasDeliveryDate; } }
public static bool CreateDutyClear(DutyClear dcl) { try { if (dcl.PO != null && dcl.PO.Id != Guid.Empty && dcl.PODetail != null && dcl.PODetail.Id != Guid.Empty) { Guid dclId = PurchaseDataManager.CreateDCL(POMap.reMapDCLData(dcl)); dcl.Id = dclId; PurchaseOrder po = GetPO(dcl.PO.Name); StoreDataManager.CreateStockMovement(StoreMap.reMapStockMovementData(po, dcl)); //TODO ResetCache(); } return(true); } catch (Exception ex) { ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex); } return(false); /*string poNumber = keyvalues.ContainsKey("PO") ? keyvalues["PO"] : ""; * string cusId = keyvalues.ContainsKey("Customer") ? keyvalues["Customer"] : ""; * * if (poNumber != "" && cusId != "") * { * PurchaseOrder PO = GetPO(poNumber); * PODetail POD = null; * foreach (PODetail pod in PO.PODetailsList) * { * if (pod.Customer.Id == new Guid(cusId)) * POD = pod; * } * if (POD != null) * { * if (POD.DutyClearsList == null) * POD.DutyClearsList = new List<DutyClear>(); * DutyClear Dcl = NewDCL(); * Dcl.PO = new Reference() { Id = PO.Id, Name = PO.PONumber }; * Dcl.PODetail = new Reference() { Id = POD.Id, Name = PO.PONumber }; * if (keyvalues.ContainsKey("Store")) * Dcl.Store = StoreManager.GetStoreRef(keyvalues["Store"].ToString()); * Dcl.Quantity = keyvalues.ContainsKey("Quantity") ? decimal.Parse(keyvalues["Quantity"]) : 0; * Dcl.Remarks = keyvalues.ContainsKey("Remarks") ? keyvalues["Remarks"] : ""; * POD.DutyClearsList.Add(Dcl); * * PurchaseDataManager.CalculatePO(PO); * if (PO.isValid) * { * PurchaseDataManager.CreateDCL(POMap.reMapDCLData(Dcl)); * //todo stock movement * } * else * { * ExceptionHandler.Error("Something went wrong! PO Quantity is not valid."); * PurchaseDataManager.ResetCache(); * return null; * } * PurchaseDataManager.ResetCache(); * return Dcl; * } * } * return null;*/ }
private static void CommitShippingCharge(SaleLineItem lineItem, CustomerOrderTransaction trans, decimal?charge) { // First check if a shipping charge code was configured on the back end and exists in the DB string shippingChargeCode = LSRetailPosis.Settings.ApplicationSettings.Terminal.ShippingChargeCode; if (charge.HasValue && string.IsNullOrWhiteSpace(shippingChargeCode)) { // "A shipping charge cannot be added for item: {0} because a shipping charge code was not found." string errorMessage = string.Format(LSRetailPosis.ApplicationLocalizer.Language.Translate(56301), lineItem.ItemId); SalesOrder.LogMessage(errorMessage, LSRetailPosis.LogTraceLevel.Error); throw new InvalidOperationException(errorMessage); } // Shipping charge Tax.MiscellaneousCharge mc = lineItem.MiscellaneousCharges.FirstOrDefault(m => m.ChargeCode == shippingChargeCode); // See if there's an existing charge if (mc == null) { if (charge.HasValue) { // No charge exists, so we add it // Get Cancellation charge properties from DB StoreDataManager store = new StoreDataManager( SalesOrder.InternalApplication.Settings.Database.Connection, SalesOrder.InternalApplication.Settings.Database.DataAreaID); DataEntity.MiscellaneousCharge chargeProperties = store.GetMiscellaneousCharge(shippingChargeCode); if (chargeProperties != null) { mc = new Tax.MiscellaneousCharge( charge.Value, trans.Customer.SalesTaxGroup, chargeProperties.TaxItemGroup, chargeProperties.MarkupCode, string.Empty, trans); // Set the proper SalesTaxGroup based on the store/customer settings SalesOrder.InternalApplication.BusinessLogic.CustomerSystem.ResetCustomerTaxGroup(mc); lineItem.MiscellaneousCharges.Add(mc); } else { // "A shipping charge cannot be added for item: {0} because no information was found for shipping charge code: {1}." string errorMessage = string.Format(LSRetailPosis.ApplicationLocalizer.Language.Translate(56303), lineItem.ItemId, shippingChargeCode); SalesOrder.LogMessage(errorMessage, LSRetailPosis.LogTraceLevel.Error); throw new InvalidOperationException(errorMessage); } } } else // Charge exists { if (charge.HasValue) { if (mc.Amount != charge.Value) { // Update amount mc.Amount = charge.Value; } } else { // No charge, so remove lineItem.MiscellaneousCharges.Remove(mc); } } // Remove any header level charge var headerCharge = trans.MiscellaneousCharges.FirstOrDefault(m => m.ChargeCode == shippingChargeCode); if (headerCharge != null) { trans.MiscellaneousCharges.Remove(headerCharge); } // Trigger new price,tax and discount for the customer (do NOT reset item prices because we should preserve any existing Price Overrides) SalesOrder.InternalApplication.BusinessLogic.ItemSystem.RecalcPriceTaxDiscount(trans, false); trans.CalcTotals(); }
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); }
void OnDestroy() { _instance = null; }