/// <summary> /// Raises the <see cref="E:PreRender"/> event. /// </summary> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); LoadTreeConfig(); ClientBindingMgr.RegisterDialogCancelButton(cmdCancel); if (Visible) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; // required to register the .js file used in this page if (DesignMode == false) { if (ScriptManager.GetCurrent(Page) != null) { ScriptManager.GetCurrent(Page).RegisterScriptControl(this); } } if (salesOrder != null) { dtsProducts.SelectParameters.Clear(); string salesorderId = (salesOrder.Id == null) ? string.Empty : salesOrder.Id.ToString(); dtsProducts.SelectParameters.Add("salesorderId", salesorderId); grdProducts.DataBind(); } } if (chkPackage.Checked != _State.Packages) { chkPackage_CheckedChanged(null, null); } }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="salesOrder">The sales order.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(ISalesOrder salesOrder, double exchangeRate) { var systemInfo = ApplicationContext.Current.Services.Get <ISystemOptionsService>(true); string baseCode = ""; if (!string.IsNullOrEmpty(systemInfo.BaseCurrency)) { baseCode = systemInfo.BaseCurrency; } var currencyCode = EntityFactory.GetById <IExchangeRate>(lueCurrencyCode.LookupResultValue); string exhangeCode = currencyCode != null ? currencyCode.CurrencyCode : salesOrder.CurrencyCode; curBaseSubTotal.CurrentCode = baseCode; curBaseDiscount.CurrentCode = baseCode; curBaseTotal.CurrentCode = baseCode; curBaseTax.CurrentCode = baseCode; curBaseShipping.CurrentCode = baseCode; curSubTotal.CurrentCode = exhangeCode; curDiscount.CurrentCode = exhangeCode; curShipping.CurrentCode = exhangeCode; curShipping.ExchangeRate = exchangeRate; curTax.CurrentCode = exhangeCode; curTax.ExchangeRate = exchangeRate; curTotal.CurrentCode = exhangeCode; }
/// <summary> /// Initializes and invokes the Add Custom Product view. /// </summary> /// <param name="form">The Sales Order Products form.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> public static void btnAddCustomProduct_OnClickStep(ISalesOrderProducts form, EventArgs args) { ISalesOrder salesOrder = form.CurrentEntity as ISalesOrder; if (salesOrder != null) { IWebDialogService dialogService = form.Services.Get <IWebDialogService>(); if (dialogService != null) { string dialogCaption = String.Format(form.GetResource("btnAddCustomProduct.Caption").ToString(), salesOrder.SalesOrderNumber); if (salesOrder.IsContractIntegrationEnabled()) { dialogService.SetSpecs(20, 20, 390, 700, "ICEditSalesOrderItem", dialogCaption, true); } else { dialogService.SetSpecs(20, 20, 325, 700, "EditSalesOrderItem", dialogCaption, true); } dialogService.DialogParameters.Add("CustomProductSalesOrder", salesOrder); dialogService.EntityType = typeof(ISalesOrderItem); dialogService.ShowDialog(); } } }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="salesOrder">The sales order.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(ISalesOrder salesOrder, Double exchangeRate) { string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById <IExchangeRate>(String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode); double myRate = 0; if (myExchangeRate != null) { myRate = myExchangeRate.Rate.GetValueOrDefault(1); } curDiscount.CurrentCode = salesOrder.CurrencyCode; curDiscount.ExchangeRate = exchangeRate; curMyDiscount.CurrentCode = myCurrencyCode; curMyDiscount.ExchangeRate = myRate; curSubTotal.CurrentCode = String.IsNullOrEmpty(lueCurrencyCode.LookupResultValue.ToString()) ? salesOrder.CurrencyCode : lueCurrencyCode.LookupResultValue.ToString(); curTotal.CurrentCode = curSubTotal.CurrentCode; curTotal.ExchangeRate = exchangeRate; curMyTotal.CurrentCode = myCurrencyCode; curMyTotal.ExchangeRate = myRate; curSubTotal.CurrentCode = salesOrder.CurrencyCode; curSubTotal.ExchangeRate = exchangeRate; curMySubTotal.CurrentCode = myCurrencyCode; curMySubTotal.ExchangeRate = myRate; curTax.CurrentCode = salesOrder.CurrencyCode; curTax.ExchangeRate = exchangeRate; curMyTax.CurrentCode = myCurrencyCode; curMyTax.ExchangeRate = myRate; curShipping.CurrentCode = salesOrder.CurrencyCode; curShipping.ExchangeRate = exchangeRate; curMyShipping.CurrentCode = myCurrencyCode; curMyShipping.ExchangeRate = myRate; }
public static decimal CalcProfitOnSalesOrder(ISalesOrder salesOrder) { var revenue = salesOrder.SubTotal + salesOrder.ShippingCost; var expenses = salesOrder.FinalValueFee + salesOrder.PayPalFee + salesOrder.I_Paid; var profit = revenue - expenses; return(profit); }
private void AssignSalesOrderDetails(SalesOrderVm viewModel, ISalesOrder salesOrder) { viewModel.SalesOrderId = salesOrder.SalesOrderId; viewModel.OrderNumber = salesOrder.OrderNumber; viewModel.OrderDate = salesOrder.OrderDate; viewModel.RequiredDate = salesOrder.RequiredDate; viewModel.DiscountRate = salesOrder.DiscountRate; }
protected void btnOK_ClickAction(object sender, EventArgs e) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; bool submitSalesOrder = Convert.ToBoolean(DialogService.DialogParameters["SubmitSalesOrder"].ToString()); salesOrder.CompleteUpdatedErpPricingLines(submitSalesOrder); Response.Redirect(Request.Url.ToString()); }
/// <summary> /// Updates the sales order shipping address with the newly selected address. /// </summary> /// <param name="form">The bill to ship to form.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> public static void lstbxShippingAddress_OnChange(IBillToShipTo form, EventArgs args) { ISalesOrder salesOrder = form.CurrentEntity as ISalesOrder; if (salesOrder != null) { IAddress address = Sage.Platform.EntityFactory.GetById <IAddress>(form.lstbxShippingAddress.Text); salesOrder.SetSalesOrderShippingAddress(address); } }
private void AssignTotals(SalesOrderVm viewModel, ISalesOrder salesOrder) { viewModel.SubTotal = salesOrder.SubTotal; viewModel.TaxTotal = salesOrder.TaxTotal; viewModel.Total = salesOrder.Total; viewModel.Margin = salesOrder.Margin; viewModel.Profit = salesOrder.Profit; viewModel.TotalVolume = salesOrder.TotalVolume; viewModel.TotalWeight = salesOrder.TotalWeight; }
/// <summary> /// Assigns the Sales Order type. /// </summary> /// <param name="form">The Sales Order details form.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> public static void btnSaveSalesOrder_OnClickStep(ISalesOrderDetails form, EventArgs args) { ISalesOrder salesOrder = form.CurrentEntity as ISalesOrder; if (salesOrder != null && !form.rdgSOType.IsReadOnly) { salesOrder.IsQuote = !String.IsNullOrEmpty(form.rdgSOType.SelectedValue) && Convert.ToBoolean(form.rdgSOType.SelectedValue); salesOrder.Save(); } }
public static void OnLoadHandlerStep(ISalesOrderProducts form, EventArgs args) { ISalesOrder salesOrder = form.CurrentEntity as ISalesOrder; if (salesOrder != null) { bool bInsertMode = ((salesOrder.PersistentState | PersistentState.New) == salesOrder.PersistentState); form.btnAddCustomProduct.Visible = !bInsertMode; } }
/// <summary> /// Updates the sales order shipping address and shipping contact with the new address. /// </summary> /// <param name="form">The bill to ship to form.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> public static void lueNameShipping_OnChange(IBillToShipTo form, EventArgs args) { ISalesOrder salesOrder = form.CurrentEntity as ISalesOrder; if (salesOrder != null && salesOrder.ShippingContact != null) { salesOrder.ShippingAddress = salesOrder.SetSalesOrderShippingAddress(salesOrder.ShippingContact.ShippingAddress); salesOrder.ShipToName = salesOrder.ShippingContact.NameLF; } }
public SalesOrderVm Build(ISalesOrder salesOrder) { var salesOrderVm = InstantiateSalesOrderVmModelBuilder().Build(salesOrder); salesOrderVm.DeliveryAddress = InstantiateAddressVmModelBuilder().Build(salesOrder.DeliveryAddress); salesOrderVm.Currency = InstantiateCurrencyVmModelBuilder().Build(salesOrder.Currency); salesOrderVm.CompanyFeatures = InstantiateCompanyFeatureVmModelBuilder().Build(salesOrder.Customer.Company); salesOrderVm.SalesTax = InstantiateSalesTaxVmModelBuilder().Build(salesOrder.SalesTax); return(salesOrderVm); }
/// <summary> /// Handles the OnChange event of the ExchangeRate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void ExchangeRate_OnChange(object sender, EventArgs e) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { salesOrder.ExchangeRate = Convert.ToDouble(String.IsNullOrEmpty(numExchangeRateValue.Text) ? "1" : numExchangeRateValue.Text); salesOrder.ExchangeRateDate = DateTime.UtcNow; UpdateMultiCurrencyExchangeRate(salesOrder, salesOrder.ExchangeRate.Value); } }
/// <summary> /// Handles the OnClick event of the ShowDetailsView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void ShowDetailsView_OnClick(object sender, EventArgs e) { if (DialogService != null) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; string caption = String.Format(GetLocalResourceObject("lblDetailsView.Caption").ToString(), salesOrder.SalesOrderNumber); DialogService.SetSpecs(300, 450, 300, 410, "EditSalesOrderDetail", caption, true); DialogService.EntityID = salesOrder.Id.ToString(); DialogService.ShowDialog(); } }
private void LoadSOTasks(EntityPage page) { if (page.IsDetailMode) { divEntitySalesOrder.Style.Add("display", "block"); _currentSOEntity = EntityFactory.GetRepository <ISalesOrder>().Get(page.EntityContext.EntityID); rowCheckPrices.Style.Add("display", "none"); rowSOSubmit.Style.Add("display", "none"); rowSOStatus.Style.Add("display", "block"); divSOLastUpdate.Style.Add("display", "block"); lblStatus.ForeColor = lblSOStatus.ForeColor; Sage.Platform.SData.IAppIdMappingService mappingService = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.SData.IAppIdMappingService>(true); if (!mappingService.IsIntegrationEnabled()) { rowSOStatus.Style.Add("display", "none"); divSOLastUpdate.Style.Add("display", "none"); } else { bool isOpen = true; if (!String.IsNullOrEmpty(_currentSOEntity.ERPSalesOrder.ERPStatus)) { isOpen = (_currentSOEntity.ERPSalesOrder.ERPStatus.Equals( GetLocalResourceObject("ERPStatus_Open").ToString()) || _currentSOEntity.ERPSalesOrder.ERPStatus.Equals(GetLocalResourceObject("ERPStatus_Rejected").ToString())); } lblStatus.Text = _currentSOEntity.ERPSalesOrder.ERPStatus; //sales order has never been submitted if (!_currentSOEntity.GlobalSyncId.HasValue && isOpen) { rowCheckPrices.Style.Add("display", "block"); rowSOSubmit.Style.Add("display", "block"); } else if (_currentSOEntity.GlobalSyncId.HasValue && !isOpen) { lblStatus.ForeColor = Color.Red; rowCheckPrices.Style.Add("display", "none"); rowSOSubmit.Style.Add("display", "none"); } } if (mappingService.IsIntegrationEnabled()) { lblSOSubmittedOn.Text = String.Format(GetLocalResourceObject("lblSoSubmittedOn.Caption").ToString(), TimeZone.UTCDateTimeToLocalTime( (DateTime)_currentSOEntity.ModifyDate), _currentSOEntity.ModifyUser); } if (page.IsNewEntity) { updateSOPanel.Update(); } } }
protected void Page_Load(object sender, EventArgs e) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { if (BusinessRuleHelper.IsMultiCurrencyEnabled()) { UpdateMultiCurrencyExchangeRate(salesOrder, salesOrder.ExchangeRate.GetValueOrDefault(1)); } } }
public static void PublishEvent(SalesOrderVersions version, ILogger log) { log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); ISalesOrder order = SalesOrder.CreateOrder(version); EventData eventData = new EventData(SalesOrder.AsJsonUTF8(order)); eventData.Properties.Add("SchemaVersion", order.SchemaVersion); log.LogInformation($"Sending message attempt: {SalesOrder.AsJson(order)}"); eventHubClient.SendAsync(eventData); }
/// <summary> /// Initializes the view. /// </summary> /// <param name="form">The Edit Sales Order Item form.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> public static void OnFormLoadStep(IEditSalesOrderItem form, EventArgs args) { ISalesOrderItem salesOrderItem = form.CurrentEntity as ISalesOrderItem; IWebDialogService dialogService = form.Services.Get <IWebDialogService>(); if (dialogService != null && dialogService.DialogParameters.ContainsKey("CustomProductSalesOrder")) { ISalesOrder salesOrder = dialogService.DialogParameters["CustomProductSalesOrder"] as ISalesOrder; salesOrderItem.SalesOrder = salesOrder; salesOrderItem.Quantity = 1; salesOrderItem.CalculatedPrice = 0; salesOrderItem.Discount = 0; salesOrderItem.ExtendedPrice = 0; salesOrderItem.Price = 0; dialogService.DialogParameters.Remove("CustomProductSalesOrder"); } if (salesOrderItem.SalesOrder.IsMultiCurrencyEnabled()) { form.curMCCalcPrice.ExchangeRate = salesOrderItem.SalesOrder.ExchangeRate.GetValueOrDefault(1); form.curMCCalcPrice.CurrentCode = salesOrderItem.SalesOrder.CurrencyCode; form.curMCCalcPrice.ExchangeRateType = Sage.Platform.Controls.ExchangeRateTypeEnum.EntityRate; form.curMCCalcPrice.Text = salesOrderItem.CalculatedPrice.ToString(); } else { form.ctrlstMCPrice.Visible = false; } if (salesOrderItem.Product == null) // AdHocProduct { salesOrderItem.LineType = "FreeText"; // Use as literal; represents adhoc product. form.ctrlstLineNumber.Visible = false; form.ctrlstPriceLevel.Visible = false; form.curPrice.IsReadOnly = false; form.txtSKU.IsReadOnly = false; form.pklFamily.IsReadOnly = false; form.txtDescription.IsReadOnly = false; form.txtProductName.IsReadOnly = false; } bool closed = (salesOrderItem.SalesOrder.Status.ToUpper().Equals(form.GetResource("SalesOrderStatus_Closed").ToString().ToUpper())); form.txtDescription.Enabled = !closed; form.txtSKU.Enabled = !closed; form.pklFamily.Enabled = !closed; form.txtDiscount.Enabled = !closed; form.curCalculatedPrice.Enabled = !closed; form.curMCCalcPrice.Enabled = !closed; form.numQuantity.Enabled = !closed; form.btnOK.Visible = !closed; form.btnCancel.Caption = form.GetResource("Closed_Caption").ToString(); }
private string GetAppId() { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { if (salesOrder.OperatingCompany != null) { return(salesOrder.OperatingCompany.Id.ToString()); } } return(string.Empty); }
/// <summary> /// Sends the email. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SendEmail(object sender, EventArgs e) { try { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { string emailTo = String.Empty; string emailCC = String.Empty; if (salesOrder.RequestedBy != null) { if (!salesOrder.RequestedBy.Equals(salesOrder.ShippingContact) || !salesOrder.RequestedBy.Equals(salesOrder.BillingContact)) { emailCC = salesOrder.RequestedBy.Email; } } if (salesOrder.ShippingContact != null) { emailTo = String.Format("{0};", salesOrder.ShippingContact.Email); } if (salesOrder.BillingContact != null && !salesOrder.BillingContact.Equals(salesOrder.ShippingContact)) { emailTo += salesOrder.BillingContact.Email; } string subject = PortalUtil.JavaScriptEncode( String.Format(GetLocalResourceObject("lblEmailSubject.Caption").ToString(), salesOrder.SalesOrderNumber, salesOrder.Account.AccountName)).Replace( Environment.NewLine, "%0A"); string emailBody = FormatEmailBody(salesOrder).Replace(Environment.NewLine, "%0A"); if (!String.IsNullOrEmpty(emailCC)) { ScriptManager.RegisterStartupScript(this, GetType(), "emailscript", string.Format( "<script type='text/javascript'>window.location.href='mailto:{0}?cc={1}&subject={2}&body={3}';</script>", emailTo, emailCC, subject, emailBody), false); } else { ScriptManager.RegisterStartupScript(this, GetType(), "emailscript", string.Format( "<script type='text/javascript'>window.location.href='mailto:{0}?subject={1}&body={2}';</script>", emailTo, subject, emailBody), false); } } } catch (Exception ex) { log.Error(ex.Message); } }
public static DataSet UpdateDOAndManifest(ISalesOrder SalesOrder) { SqlParameter[] _parameters = { new SqlParameter("@Id", SalesOrder.Id) , new SqlParameter("@OrderNumber", SalesOrder.OrderNumber) , new SqlParameter("@DNOrder", SalesOrder.DNOrder) , new SqlParameter("@Manifest", SalesOrder.Manifest) , new SqlParameter("@RIT", SalesOrder.RIT) , new SqlParameter("@SysCreator", SalesOrder.SysCreator) }; return(SqlHelper.ExecuteDataset(ConnectionString, "sp_SalesOrders_UpdateDOAndManifest", _parameters)); }
public static DataSet Retrieve(ISalesOrder SalesOrder) { SqlParameter[] _Parameters = { new SqlParameter("@FromDeliveryDate", SalesOrder.OrderDate) , new SqlParameter("@ToDeliveryDate", SalesOrder.OrderDate2) , new SqlParameter("@DeliveryTo", SalesOrder.CustNo) , new SqlParameter("@DealingType", SalesOrder.DealingType) , new SqlParameter("@Shift", SalesOrder.Shift) //,new SqlParameter("@FromTime",SalesOrder.FromTime) //,new SqlParameter("@ToTime",SalesOrder.ToTime) , new SqlParameter("@ItemCode", SalesOrder.IchItemCode) }; return(SqlHelper.ExecuteDataset(ConnectionString, "sp_SalesOrders_SearchDeliveryOrdersWithShift", _Parameters)); }
public SalesOrderVm Build(ISalesOrder salesOrder) { if (salesOrder == null) { throw new SalesOrderCannotBeNullException(); } var viewModel = new SalesOrderVm(); AssignTotals(viewModel, salesOrder); AssignCustomerDetails(viewModel, salesOrder); AssignSalesInvoiceDetails(viewModel, salesOrder); AssignSalesOrderDetails(viewModel, salesOrder); return(viewModel); }
public static void OnLoad1Step(IInsertSalesOrder form, EventArgs args) { ISalesOrder so = form.CurrentEntity as ISalesOrder; if (so == null) { return; } IAppIdMappingService mappingService = ApplicationContext.Current.Services.Get <IAppIdMappingService>(false); ISelectionService srv = ApplicationContext.Current.Services.Get <ISelectionService>(true); if (srv != null) { ISelectionContext sc = srv.GetSelectionContext("QuickInsertAccountContact"); if (sc != null) { List <string> sels = sc.GetSelectedIds(); if (sels.Count > 0) { string newContactId = sels[0]; IContact newContact = EntityFactory.GetById <IContact>(newContactId); IAccount newAccount = newContact.Account; so.Account = newAccount; so.AccountManager = newAccount.AccountManager; so.BillingContact = newContact; so.ShippingContact = newContact; so.BillToName = newContact.NameLF; so.ShipToName = newContact.NameLF; if (so.BillingAddress == null) { ISalesOrderAddress billAddr = EntityFactory.Create <ISalesOrderAddress>(); so.BillingAddress = billAddr; } so.SetSalesOrderBillingAddress(newContact.Address); if (so.ShippingAddress == null) { ISalesOrderAddress shipAddr = EntityFactory.Create <ISalesOrderAddress>(); so.ShippingAddress = shipAddr; } so.SetSalesOrderShippingAddress(newContact.Address); srv.SetSelectionContext("QuickInsertAccountContact", null); } } } }
/// <summary> /// Handles the OnChange event of the CurrencyCode control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void CurrencyCode_OnChange(object sender, EventArgs e) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { IExchangeRate exchangeRate = EntityFactory.GetById <IExchangeRate>(lueCurrencyCode.LookupResultValue); if (exchangeRate != null) { Double rate = exchangeRate.Rate.GetValueOrDefault(1); salesOrder.ExchangeRate = rate; salesOrder.ExchangeRateDate = DateTime.UtcNow; salesOrder.CurrencyCode = lueCurrencyCode.LookupResultValue.ToString(); UpdateMultiCurrencyExchangeRate(salesOrder, rate); } } }
protected void cmdOK_Click(object sender, EventArgs e) { if (BindingSource != null) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; if (salesOrder != null) { if ((salesOrder.PersistentState & Sage.Platform.Orm.Interfaces.PersistentState.New) <= 0) { salesOrder.Save(); } } } DialogService.CloseEventHappened(sender, e); Refresh(); }
public static DataSet Retrieve(ISalesOrder SalesOrder, Int32 SearchOption) { SqlParameter[] _parameters = { new SqlParameter("@FromOrderDate", SalesOrder.OrderDate) , new SqlParameter("@ToOrderDate", SalesOrder.OrderDate2) , new SqlParameter("@OrderNumber", SalesOrder.OrderNumber) , new SqlParameter("@OrderBy", SalesOrder.OrderBy) , new SqlParameter("@InvoiceTo", SalesOrder.InvoiceTo) , new SqlParameter("@DeliveryTo", SalesOrder.DeliveryTo) , new SqlParameter("@YourRef", SalesOrder.YourRef) , new SqlParameter("@SelectionCode", SalesOrder.SelectionCode) , new SqlParameter("@Description", SalesOrder.Description) , new SqlParameter("@SearchOption", SearchOption) }; return(SqlHelper.ExecuteDataset(ConnectionString, "sp_SalesOrders_Search", _parameters)); }
protected override void OnFormBound() { if (_loadPricingChanges) { if (DialogService.DialogParameters.ContainsKey("PriceList")) { ISalesOrder salesOrder = BindingSource.Current as ISalesOrder; lblHeader.Text = String.Format(GetLocalResourceObject("lblHeader.Text").ToString(), salesOrder.SalesOrderNumber, salesOrder.Account.AccountName); grdProducts.DataSource = (IList <ComponentView>)DialogService.DialogParameters["PriceList"]; grdProducts.DataBind(); if (grdProducts.DataKeys[0].Values[0] != null) { curNewTotalPrice.Text = grdProducts.DataKeys[0].Values[0].ToString(); } ClientBindingMgr.RegisterDialogCancelButton(btnCancel); } } }
public static void OnAfterUpdateStep( ISalesOrder salesorder) { // TODO: Complete business rule implementation if ((salesorder.Actual==false || salesorder.Actual==null) && salesorder.Account.Status!="Active Client" && salesorder.Status=="Accepted Order"){ using (NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper()){ string sql = "update Account set Status='Active Client' where AccountId='"+salesorder.Account.Id.ToString()+"'"; session.CreateQuery(sql) .ExecuteUpdate(); } } if ((salesorder.Actual==false || salesorder.Actual==null) && salesorder.Account.Status!="Active Client" && salesorder.Status=="Accepted Order" && salesorder.Account.AccountConferon.Clientsince==null){ using (NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper()){ string sql = "update AccountConferon set Clientsince='"+DateTime.Now+"' where AccountId='"+salesorder.Account.Id.ToString()+"'"; session.CreateQuery(sql) .ExecuteUpdate(); } } }
/// <summary> /// Assigns the Sales Order type. /// </summary> /// <param name="form">The Insert Sales Order form.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> public static void btnSaveNew_OnClickStep(IInsertSalesOrder form, EventArgs args) { ISalesOrder salesOrder = form.CurrentEntity as ISalesOrder; if (salesOrder != null) { string selectedValue = form.rdgSOType.SelectedValue; if (selectedValue.Equals("SalesOrder")) { salesOrder.IsQuote = false; } else if (selectedValue.Equals("Quote")) { salesOrder.IsQuote = true; } salesOrder.Save(); HttpContext.Current.Response.Redirect(string.Format("SalesOrder.aspx?entityId={0}", salesOrder.Id.ToString()), false); } }
public static void GetSalesOrdReceiptsStep( ISalesOrder salesorder, out System.Decimal result) { // TODO: Complete business rule implementation try{ using (ISession session = new SessionScopeWrapper()) { decimal fswon=0; if (salesorder!=null){ if (!string.IsNullOrEmpty(salesorder.Id.ToString())){ string sql = "select sum(amount) from receipts where salesorderid= (select top 1 salesorderid from salesorder where actual = 'T' and anticipatedid='" + salesorder.Id.ToString() + "')"; fswon = session.CreateSQLQuery(sql).UniqueResult<decimal>(); } } if (!string.IsNullOrEmpty(fswon.ToString())){ result = fswon; } else { result = 0; } } } catch(Exception){result=0;} }
public static void GetCSAnticNoStep( ISalesOrder salesorder, out System.String result) { try{ using (ISession session = new SessionScopeWrapper()){ string fswon = string.Empty; if (salesorder!=null){ if (!string.IsNullOrEmpty(salesorder.Id.ToString())){ string sql = "select documentid from salesorder where actual = 'F' and salesorderid='"+salesorder.Id.ToString()+"'"; fswon = session.CreateSQLQuery(sql).UniqueResult<string>(); } } if (!string.IsNullOrEmpty(fswon)){ result=fswon; } else { result="-"; } } } catch(Exception){ result="-";} }
public static void GetSalesOrdActRevStep(ISalesOrder salesorder, out System.Double result) { // TODO: Complete business rule implementation try{ using (ISession session = new SessionScopeWrapper()) { double fswon=0; if (salesorder!=null){ if (!string.IsNullOrEmpty(salesorder.Id.ToString())){ string sql = "select top 1 ordertotal from salesorder where Actual='T' and anticipatedid='" + salesorder.Id.ToString() + "'"; fswon = session.CreateSQLQuery(sql).UniqueResult<double>(); } } if (!string.IsNullOrEmpty(fswon.ToString())){ result = fswon; } else { result = 0; } } } catch(Exception) { result=0;} }
public static void GetSalesOrdAnticDateStep( ISalesOrder salesorder, out System.DateTime result) { // TODO: Complete business rule implementation] try{ using (ISession session = new SessionScopeWrapper()) { DateTime fswon = System.DateTime.MinValue; if (salesorder!=null){ if (!string.IsNullOrEmpty(salesorder.Id.ToString())){ string sql = "select orderdate from salesorder where actual = 'F' and salesorderid='" + salesorder.Id.ToString() + "'"; fswon = session.CreateSQLQuery(sql).UniqueResult<DateTime>(); } } if (!string.IsNullOrEmpty(fswon.ToString())){ result = fswon; } else { result=System.DateTime.MinValue; } } } catch(Exception){ result=System.DateTime.MinValue;} }
public static void SetOrderTotals(ISalesOrder salesOrder) { double adjPrice = GetAdjustedPrice(salesOrder); double total = GetSalesOrderGrandTotal(salesOrder); salesOrder.OrderTotal = adjPrice; salesOrder.GrandTotal = total; }
public static void SubmitOrder(ISalesOrder salesOrder) { //don't allow already submitted order to resubmit if (salesOrder.Status == "Transmitted to Accounting") { throw new Exception("The order (" + salesOrder.SalesOrderNumber + ") has already been submitted. Change the status to resubmit."); } //Determine which order to submit and pass through switch (salesOrder.OrderType) { case "Sales Order": SubmitSalesOrder(salesOrder); break; case "Transfer Order": SubmitTransferOrder(salesOrder); break; case "Purchase Order": SubmitPurchaseOrder(salesOrder); break; case "Return Order": switch (salesOrder.AccountManager.Eabrelationship.Trim()) { case "Distributor": //Distributor SubmitInventoryAdjustment(salesOrder); break; case "Sales Rep": //Sales Rep SubmitPurchaseOrder(salesOrder); break; default: throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): Error Reading Account Manager Relationship"); } break; case "Inventory Order": switch (salesOrder.AccountManager.Eabrelationship.Trim()) { case "Distributor": //Distributor SubmitSalesOrder(salesOrder); break; case "Sales Rep": //Sales Rep SubmitTransferOrder(salesOrder); break; default: throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): Error Reading Account Manager Relationship"); } break; default: throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): Error Determining Order Type"); } }
/// <summary> /// Loads the sales order data. /// </summary> private void LoadSalesOrderData() { if (SalesOrderId.HasValue) { _salesOrderEntity = this.BrokerFactory.SalesOrderBroker.GetSalesOrderById(SalesOrderId.Value); if (_salesOrderEntity != null) { LoadSalesDetailPanel(); LoadSalesOrderPaymentPanel(); // bind/load the sales order item data to the gridview BindSalesOrderItemList(); if (MembershipHelper.IsCurrentLoggedOnUserInRole(Membership.Constants.BMRESTO_ROLE_ADMINISTRATOR)) _isReadOnly = false; else _isReadOnly = _salesOrderEntity.OrderStatus == BMResto.BO.SalesOrder.Constant.ORDER_STATUS_PAID; UpdateUI(); Mode = SalesConstants.SALESORDER_EDIT_MODE; } } else { string dummy = string.Empty; NewCommand(ref dummy); } }
//public static void SubmitSOPicklist(IStgSalesOrder_TAC salesOrder) { // Sage.Entity.Interfaces.IStgSOPicklist_TAC plHeader = // Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgSOPicklist_TAC), // Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgSOPicklist_TAC; // plHeader.RowKey = 0; //set this to unique int number (global) during integration // plHeader.TranType = 801; // plHeader.TranNo = salesOrder.TranNo; // plHeader.TranDate = salesOrder.TranDate; // plHeader.CompanyID = salesOrder.CustID; //get this from mas // plHeader.ProcessStatus = 0; // plHeader.SessionKey = 0; // plHeader.SubmitDate = null; // plHeader.ProcessDate = null; // plHeader.Save(); // foreach (Sage.Entity.Interfaces.IStgSOLine_TAC item in salesOrder.StgSOLine_TACs) { // //Transfer order line items // Sage.Entity.Interfaces.IStgSOPicklistLine_TAC plLine = // Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgSOPicklistLine_TAC), // Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgSOPicklistLine_TAC; // plLine.Stgsopicklist_tacId = plHeader.Id.ToString(); // plLine.RowKey = 0; //set this to unique int number (global) during integration - same as header value // plLine.SOLineNo = 0; //Set this to unique number (for this order) during integration. // //plLine.TrnsfrLineNo = (short)item.LineNumber; //sequence number // //plLine.TranNo = // plLine.ItemID = item.ItemID; //set to itemid from mas // plLine.QtyOnBO = item.QtyOnBO; // plLine.QtyOrd = item.QtyOrd; // plLine.QtyShip = item.QtyShip; // plLine.ShipDate = item.ShipDate; // plLine.CompanyID = salesOrder.CustID; // plLine.UnitMeasID = item.UnitMeasID; // plLine.ProcessStatus = 0; // plLine.SessionKey = 0; // plLine.SubmitDate = null; // plLine.ProcessDate = null; // plLine.SOLineKey = null; // plLine.OrderKey = null; // plLine.Save(); // } //} public static void CreatePickinglist(ISalesOrder salesOrder, out String result) { try { Sage.Entity.Interfaces.IPickingList plHeader = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IPickingList), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IPickingList; plHeader.RowKey = 0; //set this to unique int number (global) during integration switch (salesOrder.OrderType) { case "Sales Order": plHeader.TranType = 801; break; case "Transfer Order": plHeader.TranType = 812; break; } plHeader.TranNo = "0"; plHeader.TranDate = DateTime.Now; plHeader.SalesOrderId = salesOrder.Id.ToString(); //get the accountfinancial data if (salesOrder.Account != null) { if (salesOrder.Account.AccountFinancial != null) { if (salesOrder.Account.AccountFinancial.CustomerId.Length > 12) { plHeader.CompanyID = salesOrder.Account.AccountFinancial.CustomerId.Substring(0, 12); //get from mas } else { plHeader.CompanyID = salesOrder.Account.AccountFinancial.CustomerId; } } } //plHeader.ProcessStatus = 0; //plHeader.SessionKey = 0; //plHeader.SubmitDate = null; //plHeader.ProcessDate = null; plHeader.Save(); foreach (Sage.Entity.Interfaces.ISalesOrderItem item in salesOrder.SalesOrderItems) { //don't add items with 0 quantity if (item.Quantity <= 0) { //Picking list line items Sage.Entity.Interfaces.IPickingListItem plLine = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IPickingListItem), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IPickingListItem; plLine.PickingListId = plHeader.Id.ToString(); plLine.RowKey = 0; //set this to unique int number (global) during integration - same as header value plLine.SOLineNo = item.LineNumber; //sequence number if (item.Product != null) { //plLine.ItemID = item.Product.MASITEMKEY.ToString(); //set to itemid from mas plLine.ProductId = item.Product.Id.ToString(); plLine.UnitMeasID = item.Product.Unit; } plLine.QtyOnBO = 0; plLine.QtyOrd = Decimal.Parse(item.Quantity.ToString()); plLine.QtyShip = Decimal.Parse(item.Quantity.ToString()); plLine.ShipDate = salesOrder.OrderDate; plLine.CompanyID = plHeader.CompanyID; //plLine.ProcessStatus = 0; //plLine.SessionKey = 0; //plLine.SubmitDate = null; //plLine.ProcessDate = null; //plLine.SOLineKey = null; //plLine.OrderKey = null; plLine.Save(); } } //redirect to new picking list result = plHeader.Id.ToString(); } catch (Exception e) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): " + e.Message, e); } }
public static double GetAdjustedPrice(ISalesOrder salesOrder) { double adjprice = 0d; foreach (ISalesOrderItem item in salesOrder.SalesOrderItems) { //sum the prices from all items adjprice += item.ExtendedPrice ?? 0d; } return adjprice; }
public static double GetSalesOrderGrandTotal(ISalesOrder salesOrder) { double total = salesOrder.OrderTotal.HasValue ? salesOrder.OrderTotal.Value : 0.0; total = salesOrder.Discount.HasValue ? (total - (total * salesOrder.Discount.Value)) : total; total += salesOrder.Freight.HasValue ? salesOrder.Freight.Value : 0.0; return (total + (salesOrder.Tax.HasValue ? (total * salesOrder.Tax.Value) : 0.0)); }
private static void SubmitTransferOrder(ISalesOrder salesOrder) { try { //submit order to mas //header Sage.Entity.Interfaces.IStgTrnsfrOrder_TAC toHeader = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgTrnsfrOrder_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgTrnsfrOrder_TAC; toHeader.SalesOrderID = salesOrder.Id.ToString(); toHeader.TrnsfrOrderID = 0; //set this to unique int number (global) during integration toHeader.CloseDate = DateTime.Now; //get the accountfinancial data if (salesOrder.Account != null) { if (salesOrder.Account.AccountFinancial != null) { if (salesOrder.Account.AccountFinancial.Companycode.Length > 3) { toHeader.CompanyID = salesOrder.Account.AccountFinancial.Companycode.Substring(0, 3); //get from mas } else { toHeader.CompanyID = salesOrder.Account.AccountFinancial.Companycode; } } } if (salesOrder.SourceSLXSite == null) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): Error: Destination Warehouse not specified."); } else { if (salesOrder.SourceSLXSite.Sitereference != null) { toHeader.RcvgWhseID = salesOrder.SourceSLXSite.Sitereference.Siterefdisplayname; //get this from mas } } if (salesOrder.UserWareHouse == null) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): Error: Source Warehouse not specified."); } else { if (salesOrder.UserWareHouse.Sitereference != null) { toHeader.ShipWhseID = salesOrder.UserWareHouse.Sitereference.Siterefdisplayname; //get this from mas } } toHeader.ReqDelvDate = DateTime.Now.AddDays(10); toHeader.SchdShipDate = DateTime.Now.AddDays(2); toHeader.ShipMethID = null; toHeader.TranCmnt = salesOrder.SalesOrderNumber; toHeader.TranDate = DateTime.Now; toHeader.TranNo = "0"; toHeader.TransitWhseID = null; toHeader.ProcessStatus = 0; toHeader.ProcessStatusMessage = null; toHeader.SessionKey = 0; toHeader.Save(); foreach (Sage.Entity.Interfaces.ISalesOrderItem item in salesOrder.SalesOrderItems) { //only create item if quantity > 0 if (item.Quantity > 0) { //Transfer order line items Sage.Entity.Interfaces.IStgTrnsfrOrderLine_TAC toLine = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgTrnsfrOrderLine_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgTrnsfrOrderLine_TAC; toLine.Stgtrnsfrorder_tacId = toHeader.Id.ToString(); toLine.SalesOrderID = salesOrder.Id.ToString(); toLine.SalesOrderItemID = item.Id.ToString(); //toLine.TranCmnt = salesOrder.SalesOrderNumber; toLine.TrnsfrOrderID = 0; //set this to unique int number (global) during integration - same as header value toLine.TrnsfrOrderLineID = 0; //Set this to unique number (for this order) during integration. toLine.TrnsfrLineNo = (short)item.LineNumber; //sequence number if (item.Product != null) { toLine.ItemID = item.Product.MasItemID; //set to itemid from mas toLine.UoM = item.Product.Unit; //set to unit of measure from mas } toLine.QtyOrd = item.Quantity; toLine.SurchargeFixedAmt = 0; toLine.SurchargePct = 0; toLine.TranCmnt = null; toLine.ProcessStatus = 0; toLine.ProcessStatusMessage = null; toLine.SessionKey = 0; toLine.Save(); } } //Update the salesorder salesOrder.Status = "Transmitted to Accounting"; salesOrder.Save(); } catch (Exception e) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): " + e.Message, e); } }
private static void SubmitSalesOrder(ISalesOrder salesOrder) { try { //submit order to mas //Salesorder header Sage.Entity.Interfaces.IStgSalesOrder_TAC soHeader = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgSalesOrder_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgSalesOrder_TAC; soHeader.SalesOrderID = salesOrder.Id.ToString(); soHeader.UserFld1 = salesOrder.SalesOrderNumber; soHeader.TranNo = "0"; soHeader.TranDate = DateTime.Now; soHeader.STaxAmt = null; soHeader.Status = "Open"; soHeader.SessionKey = 0; soHeader.RowKey = null; soHeader.RequireSOAck = "No"; soHeader.RecurSOTranNo = null; soHeader.ProcessStatus = 0; //soHeader.OpenAmt = Math.Round((Double)salesOrder.OrderTotal, 2, MidpointRounding.AwayFromZero); //invoice total soHeader.OpenAmt = (Double)TruncateDecimal((Decimal)salesOrder.OrderTotal, 2); soHeader.Hold = "0"; //soHeader.FreightAmt = salesOrder.Freight; soHeader.FreightAmt = 0; soHeader.CustPONO = salesOrder.CustomerPurchaseOrderNumber; soHeader.PrimarySperID = Sage.SalesLogix.API.MySlx.Security.CurrentSalesLogixUser.UserInfo.AccountingUserId; //Set the discount amount from discount percentage //if (salesOrder.Discount == null || salesOrder.Discount == 0) { soHeader.TradeDiscAmt = null; //} else { // soHeader.TradeDiscAmt = (Double)TruncateDecimal((Decimal)salesOrder.Discount * (Decimal)soHeader.OpenAmt, 2); //} //get the accountfinancial data if (salesOrder.Account != null) { if (salesOrder.Account.AccountFinancial != null) { soHeader.CustID = salesOrder.Account.AccountFinancial.CustomerId; //get from mas if (salesOrder.Account.AccountFinancial.Customer_Type == null) { throw new ArgumentNullException("Customer_Type"); } else { soHeader.CustClassID = salesOrder.Account.AccountFinancial.Customer_Type.Substring(0, 4).ToUpper(); //get from mas } //soHeader.DfltShipToCustAddrID = salesOrder.ShippingAddress.Address.MASAddrKey.ToString(); //change this to mas id soHeader.DfltShipToCustAddrID = salesOrder.Account.AccountFinancial.CustomerId; //soHeader.BillToCustAddrID = salesOrder.BillingAddress.Address.MASAddrKey.ToString(); //change to mas id soHeader.BillToCustAddrID = salesOrder.Account.AccountFinancial.CustomerId; soHeader.CompanyID = salesOrder.Account.AccountFinancial.Companycode; } } soHeader.CurrID = salesOrder.CurrencyCode; soHeader.CurrExchRate = salesOrder.ExchangeRate; //soHeader.ContactName = salesOrder.BillingContact.FullName; soHeader.ContactName = ""; soHeader.DfltShipPriority = 3; soHeader.PmtTermsID = "120"; soHeader.Save(); foreach (Sage.Entity.Interfaces.ISalesOrderItem item in salesOrder.SalesOrderItems) { //only create item if quantity != 0 if (item.Quantity != 0) { //Sales order line items Sage.Entity.Interfaces.IStgSOLine_TAC soLine = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgSOLine_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgSOLine_TAC; soLine.Stgsalesorder_tacId = soHeader.Id.ToString(); soLine.SalesOrderID = salesOrder.Id.ToString(); soLine.SalesOrderItemID = item.Id.ToString(); ////Get the so line number - slx does this already //Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.IStgSOLine_TAC> rep = // Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.IStgSOLine_TAC>(); //Sage.Platform.Repository.ICriteria criteria = rep.CreateCriteria(); //criteria.Add(rep.EF.Eq("Stgsalesorder_tacId", soHeader.Id.ToString())); //criteria.SetProjection(rep.PF.Max("SOLineNo")); //criteria.SetMaxResults(1); //int lastLineNo = (int)criteria.UniqueResult(); //soLine.SOLineNo = lastLineNo + 1; soLine.SOLineNo = item.LineNumber; soLine.AcctRefCode = null; soLine.RowAction = 0; //find out values for this soLine.AmtInvcd = 0; soLine.CloseDate = null; soLine.CmntOnly = "No"; soLine.CommClassID = null; soLine.CommPlanID = null; soLine.DeliveryMeth = "1"; if (item.Description.Length > 40) { soLine.Description = item.Description.Substring(0, 40); } else { soLine.Description = item.Description; } //don't rely on slx calculation //soLine.ExtAmt = Math.Round((Double)item.ExtendedPrice, 2); double extendedAmount = (Double)item.CalculatedPrice * (Double)item.Quantity; soLine.ExtAmt = Math.Round(extendedAmount, 2, MidpointRounding.AwayFromZero); soLine.TradeDiscAmt = (Double)Math.Round((Decimal)salesOrder.Discount * (Decimal)soLine.ExtAmt, 2, MidpointRounding.ToEven); soLine.TradeDiscPct = null; soLine.ExtCmnt = null; soLine.FOBID = salesOrder.Fob; //soLine.FreightAmt = salesOrder.Freight; //do not use soLine.FreightAmt = 0; soLine.Hold = "0"; soLine.HoldReason = null; soLine.ItemAliasID = null; soLine.KitComponent = null; soLine.MAS90LineIndex = null; soLine.OrigOrdered = item.Quantity; //soLine.OrigPromiseDate = salesOrder.DatePromised; soLine.OrigPromiseDate = salesOrder.OrderDate.Value.AddDays(10); soLine.PONumber = salesOrder.CustomerPurchaseOrderNumber; soLine.ProcessStatus = 0; //soLine.PromiseDate = salesOrder.DatePromised; soLine.PromiseDate = salesOrder.OrderDate.Value.AddDays(10); soLine.QtyInvcd = item.Quantity; soLine.QtyOnBO = 0; soLine.QtyOrd = item.Quantity; soLine.QtyRtrnCredit = 0; soLine.QtyRtrnReplacement = 0; soLine.QtyShip = 0; soLine.ReqCert = "No"; soLine.RequestDate = salesOrder.OrderDate; soLine.RowKey = null; soLine.SessionKey = 0; soLine.ShipDate = salesOrder.OrderDate.Value.AddDays(2); soLine.ShipMethID = null; soLine.ShipPriority = 3; if (salesOrder.ShippingAddress != null) { if (salesOrder.ShippingAddress.Address != null) { soLine.ShipToAddrName = salesOrder.ShippingAddress.Address.MASAddrKey.ToString();//get from MAS } soLine.ShipToAddrLine1 = salesOrder.ShippingAddress.Address1; soLine.ShipToAddrLine2 = salesOrder.ShippingAddress.Address2; soLine.ShipToAddrLine3 = salesOrder.ShippingAddress.Address3; soLine.ShipToAddrLine4 = salesOrder.ShippingAddress.Address4; soLine.ShipToAddrLine5 = ""; soLine.ShipToCity = salesOrder.ShippingAddress.City; if (salesOrder.ShippingAddress.Country.Length > 3) { if (salesOrder.ShippingAddress.Country.ToUpper().Substring(0, 1) == "U") { soLine.ShipToCountryID = "USA"; } else { soLine.ShipToCountryID = "CAN"; } } else { soLine.ShipToCountryID = salesOrder.ShippingAddress.Country; } soLine.ShipToPostalCode = salesOrder.ShippingAddress.PostalCode; soLine.ShipToStateID = salesOrder.ShippingAddress.State; } soLine.Status = "Open"; soLine.STaxClassID = null; soLine.TranNo = "0"; if (item.Product != null) { soLine.GLAcctNo = item.Product.GlAccountNumber; //get this from mas soLine.ItemID = item.Product.MasItemID; //item key from mas soLine.UnitMeasID = item.Product.Unit; //get this from mas } //soLine.UnitPrice = Math.Round((Double)item.Price, 2); //wrong price, use price * margin soLine.UnitPrice = Math.Round((Double)item.CalculatedPrice, 2, MidpointRounding.AwayFromZero); soLine.UserFld1 = null; soLine.UserFld2 = null; soLine.VendorID = soHeader.CustID; soLine.WillCall = null; if (salesOrder.UserWareHouse != null) { if (salesOrder.UserWareHouse.Sitereference != null) { soLine.WarehouseID = salesOrder.UserWareHouse.Sitereference.Siterefdisplayname; //get this from mas } } soLine.Save(); } } //Update the salesorder salesOrder.Status = "Transmitted to Accounting"; salesOrder.Save(); } catch (Exception e) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): " + e.Message, e); } }
private void btnAdd_Click(object sender, EventArgs e) { // IMPORTANT!! // in Sales order item list, there has to be only 1 records per menu. So, you can't have sales order // item list containing 2 records with same menu. // for now, if user enter a sales item recors in which menu already exist in the list, // add the quantity to existing record bool isValid = true; errorProvider1.Clear(); string menuCode = txtMenuCode.Text; string menuName = txtMenuName.Text; int quantity = 0; if (!int.TryParse(txtQty.Text, out quantity)) { isValid = false; errorProvider1.SetError(txtQty, SalesConstants.SALESORDER_QUANTITY_INVALID_FORMAT); } string notes = txtNotes.Text; if (isValid) { if (_salesOrderEntity == null) { _salesOrderEntity = this.BrokerFactory.SalesOrderBroker.CreateSalesOrderInstance(); } ISalesOrderItem salesOrderItem = this.BrokerFactory.SalesOrderBroker.CreateSalesOrderItemInstance(); IMenu menu = this.BrokerFactory.SalesOrderBroker.GetMenyByMenuCode(menuCode); if (menu != null) { salesOrderItem.MenuCode = menu.MenuCode; salesOrderItem.MenuID = menu.MenuID; salesOrderItem.MenuName = menu.MenuName; salesOrderItem.Price = menu.Price; salesOrderItem.Notes = notes; salesOrderItem.QtyOrdered = quantity; // order status automatically set to new in here. this._salesOrderEntity.AddSalesOrderItem(salesOrderItem); _helper.CalculateSalesOrderHead(_salesOrderEntity, chkApplyTax.Checked); UpdateSalesOrderAndSalesOrderItemStatus(); BindSalesOrderItemList(); ResetSalesOrderItemInputPanel(); LoadSalesOrderPaymentPanel(); } } }
/// <summary> /// Saves the command. /// </summary> /// <param name="message">The message.</param> /// <returns></returns> public override bool SaveCommand(ref string message) { if (_isReadOnly) { message = SalesConstants.SALESORDER_SAVE_CANNOT_MODIFIED; return false; } // IMPORTANT!! // in Sales order item list, there has to be only 1 records per menu. So, you can't have sales order // item list containing 2 records with same menu. // for now, if user enter a sales item recors in which menu already exist in the list, // add the quantity to existing record bool isValid = true; errorProvider1.Clear(); try { // TODO : Validation string orderNo = txtOrderNo.Text; DateTime transactionDate = dpTransDate.Value; string customer = txtCustomer.Text; int tableNo = 0; if (!string.IsNullOrEmpty(txtTableNo.Text) && !int.TryParse(txtTableNo.Text, out tableNo)) { isValid = false; errorProvider1.SetError(txtTableNo, SalesConstants.SALESORDER_TABLE_NO_INVALID_FORMAT); } string orderStatus = cmbOrderStatus.SelectedValue.ToString(); string paymentType = cmbPaymentType.SelectedValue.ToString(); if (isValid) { if (_salesOrderEntity == null) { _salesOrderEntity = this.BrokerFactory.SalesOrderBroker.CreateSalesOrderInstance(); } _salesOrderEntity.OrderNo = orderNo; _salesOrderEntity.OrderDate = transactionDate; _salesOrderEntity.CustomerName = customer; _salesOrderEntity.TableNo = tableNo; _salesOrderEntity.PaymentType = paymentType; _salesOrderEntity = _helper.CalculateAndSaveSalesOrder(_salesOrderEntity, chkApplyTax.Checked, MembershipHelper.CurrentUserName); SalesOrderId = _salesOrderEntity.SalesOrderID; message = SalesConstants.SALESORDER_SAVE_SUCCESS; } } catch (Exception ex) { message = ex.Message; isValid = false; } return isValid; }
/// <summary> /// News the command. /// </summary> /// <param name="message">The message.</param> /// <returns></returns> public override bool NewCommand(ref string message) { _isReadOnly = false; errorProvider1.Clear(); this._salesOrderEntity = this.BrokerFactory.SalesOrderBroker.CreateSalesOrderInstance(); this.SalesOrderId = null; ResetSalesOrderItemInputPanel(); ResetOrderPaymentPanel(); ResetOrderDetailsPanel(); dgOrderDetail.DataSource = null; dgOrderDetail.Refresh(); UpdateUI(); return true; }
public static bool OnBeforeUpdateStep2(ISalesOrder salesOrder, ISession session) { SetOrderTotals(salesOrder); return true; }
private void LoadSOTasks(EntityPage page) { if (page.IsDetailMode) { divEntitySalesOrder.Style.Add("display", "block"); _currentSOEntity = EntityFactory.GetRepository<ISalesOrder>().Get(page.EntityContext.EntityID); rowCheckPrices.Style.Add("display", "none"); rowSOSubmit.Style.Add("display", "none"); rowSOStatus.Style.Add("display", "block"); divSOLastUpdate.Style.Add("display", "block"); lblStatus.ForeColor = lblSOStatus.ForeColor; Sage.Platform.SData.IAppIdMappingService mappingService = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.SData.IAppIdMappingService>(true); if (!mappingService.IsIntegrationEnabled()) { rowSOStatus.Style.Add("display", "none"); divSOLastUpdate.Style.Add("display", "none"); } else { bool isOpen = true; if (!String.IsNullOrEmpty(_currentSOEntity.ERPSalesOrder.ERPStatus)) { isOpen = (_currentSOEntity.ERPSalesOrder.ERPStatus.Equals( GetLocalResourceObject("ERPStatus_Open").ToString()) || _currentSOEntity.ERPSalesOrder.ERPStatus.Equals(GetLocalResourceObject("ERPStatus_Rejected").ToString())); } lblStatus.Text = _currentSOEntity.ERPSalesOrder.ERPStatus; //sales order has never been submitted if (!_currentSOEntity.GlobalSyncId.HasValue && isOpen) { rowCheckPrices.Style.Add("display", "block"); rowSOSubmit.Style.Add("display", "block"); } else if (_currentSOEntity.GlobalSyncId.HasValue && !isOpen) { lblStatus.ForeColor = Color.Red; rowCheckPrices.Style.Add("display", "none"); rowSOSubmit.Style.Add("display", "none"); } } if (mappingService.IsIntegrationEnabled()) { lblSOSubmittedOn.Text = String.Format(GetLocalResourceObject("lblSoSubmittedOn.Caption").ToString(), TimeZone.UTCDateTimeToLocalTime( (DateTime) _currentSOEntity.ModifyDate), _currentSOEntity.ModifyUser); } if (page.IsNewEntity) { updateSOPanel.Update(); } } }
/// <summary> /// Use this value to get the calculated order total /// </summary> /// <param name="salesorder"></param> /// <param name="result"></param> public static void GetSalesOrderTotal(ISalesOrder salesorder, out System.Double result) { salesorder.OrderTotal = new double?(GetAdjustedPrice(salesorder)); salesorder.GrandTotal = new double?(GetSalesOrderGrandTotal(salesorder)); result = salesorder.GrandTotal ?? 0d; }
private static void SubmitPurchaseOrder(ISalesOrder salesOrder) { try { //submit order to mas Sage.Entity.Interfaces.IStgPurchaseOrder_TAC soHeader = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgPurchaseOrder_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgPurchaseOrder_TAC; soHeader.SalesOrderID = salesOrder.Id.ToString(); soHeader.ClosedForInvc = "No"; soHeader.ClosedForRcvg = "No"; soHeader.CurrExchRate = 1.0; soHeader.CurrID = "CAD"; soHeader.FreightAmt = 0; soHeader.Hold = "No"; soHeader.IssueDate = DateTime.Now; soHeader.OriginationDate = DateTime.Now; soHeader.RequirePOIssue = "No"; soHeader.Status = "Open"; soHeader.STaxAmt = null; soHeader.TranCmnt = null; soHeader.TranNo = "0"; soHeader.TranDate = DateTime.Now; soHeader.UserFld1 = salesOrder.SalesOrderNumber; soHeader.VendClassID = null; //get the accountfinancial data if (salesOrder.Account != null) { if (salesOrder.Account.AccountFinancial != null) { soHeader.CompanyID = salesOrder.Account.AccountFinancial.Companycode; soHeader.VendorID = salesOrder.Account.AccountFinancial.CustomerId; //get from mas } } //exit if wareouse not specified if (salesOrder.UserWareHouse == null) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): Error: Source Warehouse not specified."); } soHeader.Save(); foreach (Sage.Entity.Interfaces.ISalesOrderItem item in salesOrder.SalesOrderItems) { //only create item if quantity > 0 if (item.Quantity > 0) { //Sales order line items Sage.Entity.Interfaces.IStgPOLine_TAC soLine = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgPOLine_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgPOLine_TAC; soLine.Stgpurchaseorder_tacId = soHeader.Id.ToString(); soLine.SalesOrderID = salesOrder.Id.ToString(); soLine.SalesOrderItemID = item.Id.ToString(); soLine.POLineNo = item.LineNumber; soLine.AmtInvcd = 0; soLine.ClosedForInvc = "No"; soLine.ClosedForRcvg = "No"; soLine.CmntOnly = "No"; if (item.Description.Length > 40) { soLine.Description = item.Description.Substring(0, 40); } else { soLine.Description = item.Description; } soLine.DropShip = "No"; soLine.ExclLastCost = "No"; soLine.Expedite = "No"; soLine.ExtCmnt = null; //soLine.FreightAmt = salesOrder.Freight; //do not use soLine.FreightAmt = 0; if (item.Product != null) { if (String.IsNullOrEmpty(item.Product.GlAccountNumber)) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): GL Account Number is required"); } soLine.GLAcctNo = item.Product.GlAccountNumber; //get this from mas soLine.ItemID = item.Product.MasItemID; //item key from mas soLine.UnitMeasID = item.Product.Unit; //get this from mas } soLine.OrigOrdered = item.Quantity; //soLine.OrigPromiseDate = salesOrder.DatePromised; soLine.OrigPromiseDate = salesOrder.OrderDate.Value.AddDays(10); //soLine.PromiseDate = salesOrder.DatePromised; soLine.PromiseDate = salesOrder.OrderDate.Value.AddDays(10); soLine.QtyInvcd = 0; soLine.QtyOnBO = 0; soLine.QtyOpenToRcv = item.Quantity; soLine.QtyOrd = item.Quantity; soLine.QtyRcvd = 0; soLine.QtyRtrnCredit = 0; soLine.QtyRtrnReplacement = 0; soLine.RequestDate = salesOrder.OrderDate; soLine.Status = "Open"; soLine.TranNo = "0"; //get the accountfinancial data if (salesOrder.Account != null) { if (salesOrder.Account.AccountFinancial != null) { if (salesOrder.Account.AccountFinancial.Companycode.Length > 3) { soLine.TargetCompanyID = salesOrder.Account.AccountFinancial.Companycode.Substring(0, 3); //get from mas } else { soLine.TargetCompanyID = salesOrder.Account.AccountFinancial.Companycode; } } } if (item.CalculatedPrice == null) { soLine.UnitCost = 0; soLine.ExtAmt = 0; } else { soLine.UnitCost = Math.Round((Double)item.CalculatedPrice, 2, MidpointRounding.AwayFromZero); soLine.ExtAmt = Math.Round((Double)item.CalculatedPrice * (Double)item.Quantity, 2, MidpointRounding.AwayFromZero); } soLine.UserFld1 = null; soLine.STaxClassID = "Taxable"; if (salesOrder.UserWareHouse == null) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): Error: Source Warehouse not specified."); } else { if (salesOrder.UserWareHouse.Sitereference != null) { soLine.ShipToWhseID = salesOrder.UserWareHouse.Sitereference.Siterefdisplayname; //get this from mas } } soLine.Save(); } } //Update the salesorder salesOrder.Status = "Transmitted to Accounting"; salesOrder.Save(); } catch (Exception e) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): " + e.Message, e); } }
public static void GetPickingListsbySalesOrder(ISalesOrder salesorder, out IList<IPickingList> result) { try { //query the picking list object for all PICKING LIST records that are linked to this sales order Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.IPickingList> f = Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.IPickingList>(); Sage.Platform.Repository.ICriteria crit = f.CreateCriteria(); crit.Add(f.EF.Eq("SalesOrder", salesorder)); crit.Add(f.EF.Eq("Status", "Picking List")); result = crit.List<Sage.Entity.Interfaces.IPickingList>(); } catch (Exception e) { throw new Exception("Order (" + salesorder.SalesOrderNumber + "): " + e.Message, e); } }
private static void SubmitInventoryAdjustment(ISalesOrder salesOrder) { //submit order to mas //Adjusts Inventory on hand try { Sage.Entity.Interfaces.IStgInvtTranBatch_TAC tranHeader = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgInvtTranBatch_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgInvtTranBatch_TAC; tranHeader.SalesOrderID = salesOrder.Id.ToString(); tranHeader.BatchID = 0; tranHeader.BComment = salesOrder.SalesOrderNumber; tranHeader.BDate = DateTime.Now; if (salesOrder.UserWareHouse != null) { if (salesOrder.UserWareHouse.Sitereference != null) { tranHeader.WhseID = salesOrder.UserWareHouse.Sitereference.Siterefdisplayname; } } //get the accountfinancial data if (salesOrder.Account != null) { if (salesOrder.Account.AccountFinancial != null) { tranHeader.CompanyID = salesOrder.Account.AccountFinancial.Companycode; } } tranHeader.Save(); foreach (Sage.Entity.Interfaces.ISalesOrderItem item in salesOrder.SalesOrderItems) { //only create item if quantity > 0 if (item.Quantity > 0) { Sage.Entity.Interfaces.IStgInvtTran_TAC transaction = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IStgInvtTran_TAC), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IStgInvtTran_TAC; transaction.Stginvttranbatch_tacId = tranHeader.Id.ToString(); transaction.SalesOrderID = salesOrder.Id.ToString(); transaction.SalesOrderItemID = item.Id.ToString(); transaction.TranCmnt = salesOrder.SalesOrderNumber; //Determine Transaction Type int transactionType = 0; double quantity = 0; if (item.Quantity > 0) { transactionType = 703; quantity = (Double)item.Quantity; } else { //if (Double.Parse(txtAdjustment.Text) < 0) transactionType = 701; quantity = Math.Abs((Double)item.Quantity); } transaction.Qty = quantity; transaction.TranID = tranHeader.BatchID; transaction.BatchID = tranHeader.BatchID; transaction.TranType = transactionType; transaction.TranDate = DateTime.Now; //product info if (item.Product != null) { transaction.ItemID = item.Product.MasItemID; transaction.UoM = item.Product.Unit; //msrp price if (item.Product.Vlueproductmsrp != null) { transaction.UnitCost = Math.Round((Double)item.Product.Vlueproductmsrp.Listprice, 2, MidpointRounding.AwayFromZero); } else { transaction.UnitCost = 0; } transaction.TranAmt = transaction.UnitCost * transaction.Qty; transaction.GLAcctNo = item.Product.GlAccountNumber; if (transaction.GLAcctNo == null) { transaction.GLAcctNo = ""; } } transaction.CompanyID = tranHeader.CompanyID; transaction.ProcessStatus = 0; transaction.Save(); } } //Update the salesorder salesOrder.Status = "Transmitted to Accounting"; salesOrder.Save(); } catch (Exception e) { //DialogService.ShowMessage("Error Creating Transaction: " + transactionID + " " + ex.Message); //Sage.Platform.Application.Exceptions.EventLogExceptionHandler eh = new Sage.Platform.Application.Exceptions.EventLogExceptionHandler(); //eh.HandleException(ex, false); throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): " + e.Message, e); } }
public static void CreateReceiptOfGoods(ISalesOrder salesOrder, out String result) { try { Sage.Entity.Interfaces.IReceiptOfGoods plHeader = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IReceiptOfGoods), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IReceiptOfGoods; plHeader.PostDate = DateTime.Now; plHeader.SalesOrderId = salesOrder.Id.ToString(); plHeader.Status = "Open"; //plHeader.PONum = "How to get?"; //get the accountfinancial data if (salesOrder.Account != null) { if (salesOrder.Account.AccountFinancial != null) { if (salesOrder.Account.AccountFinancial.Companycode.Length > 3) { plHeader.CompanyID = salesOrder.Account.AccountFinancial.Companycode.Substring(0, 3); //get from mas } else { plHeader.CompanyID = salesOrder.Account.AccountFinancial.Companycode; } } } if (salesOrder.UserWareHouse != null) { if (salesOrder.UserWareHouse.Sitereference != null) { plHeader.WhseID = salesOrder.UserWareHouse.Sitereference.Siterefdisplayname; } } plHeader.Save(); foreach (Sage.Entity.Interfaces.ISalesOrderItem item in salesOrder.SalesOrderItems) { //don't add items with 0 quantity if (item.Quantity > 0) { //Transfer order line items Sage.Entity.Interfaces.IReceiptOfGoodsItem plLine = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.IReceiptOfGoodsItem), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.IReceiptOfGoodsItem; plLine.ReceiptOfGoodsId = plHeader.Id.ToString(); //plLine.RowKey = 0; //set this to unique int number (global) during integration - same as header value plLine.POLineNo = item.LineNumber; //sequence number if (item.Product != null) { //plLine.ItemID = item.Product.MASITEMKEY.ToString(); //set to itemid from mas plLine.ProductId = item.Product.Id.ToString(); plLine.UnitMeasID = item.Product.Unit; plLine.QtyRcvd = Decimal.Parse(item.Quantity.ToString()); } plLine.Save(); } } //redirect to new picking list result = plHeader.Id.ToString(); } catch (Exception e) { throw new Exception("Order (" + salesOrder.SalesOrderNumber + "): " + e.Message, e); } }
/// <summary> /// Formats the email body. /// </summary> /// <param name="salesOrder">The sales order.</param> /// <returns></returns> private string FormatEmailBody(ISalesOrder salesOrder) { IContextService context = ApplicationContext.Current.Services.Get<IContextService>(true); TimeZone timeZone = (TimeZone)context.GetContext("TimeZone"); bool isMultiCurr = BusinessRuleHelper.IsMultiCurrencyEnabled(); string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; string products = String.Empty; string emailBody = String.Format("{0} %0A", GetLocalResourceObject("lblEmailInfo.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailAccount.Caption"), CheckForNullValue(salesOrder.Account.AccountName)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailOpportunity.Caption"), CheckForNullValue(salesOrder.Opportunity != null ? salesOrder.Opportunity.Description : String.Empty)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailDateCreated.Caption"), timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.CreateDate).ToString(datePattern)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailDateRequested.Caption"), salesOrder.OrderDate.HasValue ? timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.OrderDate).ToString( datePattern) : String.Empty); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailDatePromised.Caption"), salesOrder.DatePromised.HasValue ? timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.DatePromised).ToString( datePattern) : String.Empty); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailSalesOrderId.Caption"), salesOrder.SalesOrderNumber); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailType.Caption"), CheckForNullValue(salesOrder.OrderType)); emailBody += String.Format("{0} {1} %0A%0A", GetLocalResourceObject("lblEmailStatus.Caption"), CheckForNullValue(salesOrder.Status)); emailBody += String.Format("{0} {1} %0A%0A", GetLocalResourceObject("lblEmailComments.Caption"), CheckForNullValue(salesOrder.Comments)); emailBody += String.Format("{0} %0A", GetLocalResourceObject("lblEmailValue.Caption")); curBaseTotal.Text = salesOrder.GrandTotal.ToString(); emailBody += String.Format("{0} %0A", String.Format(GetLocalResourceObject("lblEmailBaseGrandTotal.Caption").ToString(), curBaseTotal.FormattedText)); if (isMultiCurr) { curTotal.CurrentCode = salesOrder.CurrencyCode; curTotal.Text = salesOrder.GrandTotal.ToString(); emailBody += String.Format("{0} %0A", String.Format(GetLocalResourceObject("lblEmailSalesOrderGrandTotal.Caption").ToString(), curTotal.FormattedText)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailCurrencyCode.Caption"), CheckForNullValue(salesOrder.CurrencyCode)); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailExchangeRate.Caption"), CheckForNullValue(salesOrder.ExchangeRate)); if (salesOrder.ExchangeRateDate.HasValue) emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailExchangeRateDate.Caption"), timeZone.UTCDateTimeToLocalTime((DateTime)salesOrder.ExchangeRateDate). ToString(datePattern)); else emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailExchangeRateDate.Caption"), GetLocalResourceObject("lblNone.Caption")); } emailBody += String.Format("%0A{0} %0A", GetLocalResourceObject("lblEmailProducts.Caption")); foreach (ISalesOrderItem item in salesOrder.SalesOrderItems) products += String.Format("{0} ({1}); ", item.Product, item.Quantity); emailBody += String.Format("{0} %0A", CheckForNullValue(products)); emailBody += String.Format("%0A{0} %0A", GetLocalResourceObject("lblEmailBillShipAddress.Caption")); emailBody += String.Format("{0} %0A", GetLocalResourceObject("lblEmailBillingAddress.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailBillingAddressName.Caption"), salesOrder.BillingContact == null ? String.Empty : salesOrder.BillingContact.NameLF); emailBody += salesOrder.BillingAddress.FormatFullSalesOrderAddress().Replace("\r\n", "%0A"); emailBody += String.Format("%0A %0A{0} %0A", GetLocalResourceObject("lblEmailShippingAddress.Caption")); emailBody += String.Format("{0} {1} %0A", GetLocalResourceObject("lblEmailShippingAddressName.Caption"), salesOrder.ShippingContact == null ? String.Empty : salesOrder.ShippingContact.NameLF); emailBody += salesOrder.ShippingAddress.FormatFullSalesOrderAddress().Replace("\r\n", "%0A"); return PortalUtil.JavaScriptEncode(emailBody.Replace("+", "%20")); }
public static void AddStockcardProducts(ISalesOrder salesorder) { try { //Only add products if the account is specified if (salesorder.Account != null) { //save the salesorder salesorder.Save(); //get the user's warehouseid, the id may not match the object reference, use the id as correct String userWarehouseID = ""; if (String.IsNullOrEmpty(salesorder.UserWHSEID) && salesorder.UserWareHouse != null) { userWarehouseID = salesorder.UserWareHouse.SiteCodeId; } else if (salesorder.UserWHSEID == salesorder.UserWareHouse.Id.ToString()) { userWarehouseID = salesorder.UserWareHouse.SiteCodeId; } else { //lookup id from site Sage.Entity.Interfaces.ISLXSite _UserWareHouse = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.ISLXSite>(salesorder.UserWHSEID); if (_UserWareHouse != null) { userWarehouseID = _UserWareHouse.SiteCodeId; } } //List the stock card items Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.IStockCardItems> f = Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.IStockCardItems>(); Sage.Platform.Repository.ICriteria crit = f.CreateCriteria(); crit.Add(f.EF.Eq("Accountid", salesorder.Account.Id.ToString())); crit.CreateAlias("Product", "p"); crit.Add(f.EF.Eq("p.WarehouseID", userWarehouseID)); crit.Add(f.EF.Ne("p.Status", "Deleted")); //result = crit.List<Sage.Entity.Interfaces.IPickingList>(); foreach (IStockCardItems scitem in crit.List<IStockCardItems>()) { if (scitem.Product != null) { ////Only add products in the selected warehouse //if (!String.IsNullOrEmpty(userWarehouseID) && userWarehouseID == scitem.Product.WarehouseID) { try { //add the products to the salesorder Sage.Entity.Interfaces.ISalesOrderItem item = Sage.Platform.EntityFactory.Create(typeof(Sage.Entity.Interfaces.ISalesOrderItem), Sage.Platform.EntityCreationOption.DoNotExecuteBusinessRules) as Sage.Entity.Interfaces.ISalesOrderItem; //use common function to add salesorderitem item.SalesOrder = salesorder; item.Product = scitem.Product; item.MaxStockLevel = scitem.MaxStockLevel; //ssommerfeldt Nov 2 2012 item.SaveProductToSalesOrderItem(); item.Save(); salesorder.SalesOrderItems.Add(item); } catch (Exception ex) { //handle errors to allow other items to process Sage.Platform.Application.Exceptions.EventLogExceptionHandler eh = new Sage.Platform.Application.Exceptions.EventLogExceptionHandler(); eh.HandleException(new Exception("Order (" + salesorder.SalesOrderNumber + "): " + ex.Message, ex), false); } ////get msrp price //double listPrice = 0; //try { // if (scitem.Product.Vproductpricesheet != null) { // listPrice = (double)scitem.Product.Vproductpricesheet.Listprice; // } else { // //price not found // } //} catch (Exception ex) { // //vproductpricesheet record not found // Sage.Platform.Application.Exceptions.EventLogExceptionHandler eh = new Sage.Platform.Application.Exceptions.EventLogExceptionHandler(); // eh.HandleException(new Exception("Order (" + item.SalesOrder.SalesOrderNumber + "): " + ex.Message, ex), false); //} ////item.Price = Math.Round((Double)scitem.Product.Price, 2, MidpointRounding.AwayFromZero); //item.Price = listPrice; ////get the margin //item.Discount = scitem.Margin; //item.ExtendedPrice = 0; //due to quantity 0 //item.Quantity = 0; //set to 0 initially //item.ActualID = scitem.Product.ActualId; //item.UPC = scitem.Product.UPC; //item.Description = scitem.ProductDescription; //item.Family = scitem.Product.Family; //item.ProductName = scitem.Product.Name; //item.Program = scitem.Product.Program; //item.Case = scitem.Product.Unit; //item.Product = scitem.Product; //item.UnitOfMeasureId = scitem.Product.UnitOfMeasureId.Trim(); //item.MaxStockLevel = scitem.MaxStockLevel; //ssommerfeldt Nov 2 2012 //salesorder.SalesOrderItems.Add(item); //item.Save(); } } } } catch (Exception e) { throw new Exception("Order (" + salesorder.SalesOrderNumber + "): " + e.Message, e); } }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="salesOrder">The sales order.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(ISalesOrder salesOrder, Double exchangeRate) { string myCurrencyCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById<IExchangeRate>(String.IsNullOrEmpty(myCurrencyCode) ? "USD" : myCurrencyCode); double myRate = 0; if (myExchangeRate != null) myRate = myExchangeRate.Rate.GetValueOrDefault(1); curDiscount.CurrentCode = salesOrder.CurrencyCode; curDiscount.ExchangeRate = exchangeRate; curMyDiscount.CurrentCode = myCurrencyCode; curMyDiscount.ExchangeRate = myRate; curSubTotal.CurrentCode = String.IsNullOrEmpty(lueCurrencyCode.LookupResultValue.ToString()) ? salesOrder.CurrencyCode : lueCurrencyCode.LookupResultValue.ToString(); curTotal.CurrentCode = curSubTotal.CurrentCode; curTotal.ExchangeRate = exchangeRate; curMyTotal.CurrentCode = myCurrencyCode; curMyTotal.ExchangeRate = myRate; curSubTotal.CurrentCode = salesOrder.CurrencyCode; curSubTotal.ExchangeRate = exchangeRate; curMySubTotal.CurrentCode = myCurrencyCode; curMySubTotal.ExchangeRate = myRate; curTax.CurrentCode = salesOrder.CurrencyCode; curTax.ExchangeRate = exchangeRate; curMyTax.CurrentCode = myCurrencyCode; curMyTax.ExchangeRate = myRate; curShipping.CurrentCode = salesOrder.CurrencyCode; curShipping.ExchangeRate = exchangeRate; curMyShipping.CurrentCode = myCurrencyCode; curMyShipping.ExchangeRate = myRate; }
///<summary> ///Saves the sales order. ///</summary> ///<param name="salesOrder">The sales order.</param> ///<param name="createdOrModifiedBy">The created or modified by.</param> ///<returns></returns> public abstract ISalesOrder SaveSalesOrder(ISalesOrder salesOrder, string createdOrModifiedBy);
/// <summary> /// Deletes the sales order. /// </summary> /// <param name="salesOrder">The sales order.</param> /// <returns></returns> public abstract void DeleteSalesOrder(ISalesOrder salesOrder, string deletedBy);