protected virtual void _(Events.FieldUpdated <FSRouteEmployee, FSRouteEmployee.priorityPreference> e) { if (e.Row == null) { return; } FSRouteEmployee fsRouteEmployeeRow = (FSRouteEmployee)e.Row; if (fsRouteEmployeeRow.PriorityPreference < 1) { e.Cache.RaiseExceptionHandling <FSRouteEmployee.priorityPreference>( fsRouteEmployeeRow, fsRouteEmployeeRow.PriorityPreference, new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix(TX.Error.MINIMUN_VALUE, 1), PXErrorLevel.Error)); } }
/// <summary> /// Gets the current version of the system. /// </summary> private string GetVersion(bool raw) { string ver = PXVersionInfo.Version; if (!raw) { ver = PXMessages.LocalizeFormatNoPrefix(PX.AscxControlsMessages.PageTitle.Version, ver); } string cstProjects = Customization.CstWebsiteStorage.PublishedProjectList; if (!string.IsNullOrEmpty(cstProjects)) { ver += " " + PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.PageTitle.Customization) + cstProjects; } return(ver); }
private void ValidateVendorAndJointPayees(PXCache cache, IEnumerable <JointPayee> jointPayees, APAdjust adjustment, IEnumerable <int?> projectIds, IEnumerable <ComplianceDocument> outstandingCompliancesForPrimaryVendor) { var vendorMessage = lienWaiverWarningMessageService .CreateVendorWarningMessage(outstandingCompliancesForPrimaryVendor); var warningMessage = string.Concat(ComplianceMessages.LienWaiver.VendorAndJointPayeeHaveOutstandingLienWaiver, Constants.WarningMessageSymbols.NewLine, vendorMessage); warningMessage = jointPayees.Aggregate(warningMessage, (current, jointPayee) => string.Concat(current, lienWaiverWarningMessageService.CreateWarningMessage( jointPayee, Constants.WarningMessageSymbols.NewLine, projectIds.ToList()))); var formattedWarningMessage = PXMessages.LocalizeFormatNoPrefix(warningMessage); SetWarningIfNeeded <APAdjust.adjdLineNbr>(cache, adjustment, formattedWarningMessage, true, PXErrorLevel.RowWarning); }
private static String GetTitle(PXLogOutReason reason) { switch (reason) { case PXLogOutReason.UserDisabled: return(ActionsMessages.UserDisabledReason); case PXLogOutReason.CompaniesExceeded: case PXLogOutReason.UsersExceeded: return(PXMessages.LocalizeFormatNoPrefix(ActionsMessages.LogoutReason, ReasonToString(reason))); case PXLogOutReason.SnapshotRestored: return(ActionsMessages.LogoutSnapshotReason); default: return(String.Empty); } }
public static PhysicalAddressDictionaryEntryType GetValueByType(PhysicalAddressDictionaryEntryType[] types, PhysicalAddressKeyType key, bool checkEmpty = false) { if (types != null) { foreach (PhysicalAddressDictionaryEntryType item in types) { if (item.Key == key) { return(item); } } } if (checkEmpty) { throw new PXException(PXMessages.LocalizeFormatNoPrefix(Messages.EmailTypeNotFound, key.ToString())); } return(null); }
public static IEnumerable<string> GetPeriodAgingBucketDescriptions( IFinancialPeriodProvider financialPeriodProvider, DateTime currentDate, AgingDirection agingDirection, int numberOfBuckets) { if (financialPeriodProvider == null) throw new ArgumentNullException(nameof(financialPeriodProvider)); if (numberOfBuckets <= 0) throw new ArgumentOutOfRangeException(nameof(numberOfBuckets)); short periodStep = (short)(agingDirection == AgingDirection.Backwards ? -1 : 1); // Must not re-use any existing graphs due to possible query // caching of financial periods, which can impact localization // of their descriptions, see AC-84505. // - PXGraph graph = new PXGraph(); FinPeriod currentPeriod = financialPeriodProvider.GetFinPeriodByID( graph, financialPeriodProvider.GetPeriodFromDate(graph, currentDate)); yield return currentPeriod.Descr; --numberOfBuckets; while (numberOfBuckets > 1) { currentPeriod = financialPeriodProvider.GetFinPeriodByID( graph, financialPeriodProvider.PeriodPlusPeriod(graph, currentPeriod.FinPeriodID, periodStep)); yield return currentPeriod.Descr; --numberOfBuckets; } if (numberOfBuckets > 0) { yield return PXMessages.LocalizeFormatNoPrefix( agingDirection == AgingDirection.Backwards ? Messages.BeforeMonth : Messages.AfterMonth, currentPeriod.Descr); } }
protected virtual FinPeriod GetAndValidateMainFinPeriod(PXCache cache, object oldRow, object newRow, bool externalCall) { int?newMainCalendarOrgID = CalendarOrganizationIDProvider.GetCalendarOrganizationID(cache.Graph, cache, newRow); int?oldMainCalendarOrgID = CalendarOrganizationIDProvider.GetCalendarOrganizationID(cache.Graph, cache, oldRow); string newMainOrgFinPeriodID = null; FinPeriod newMainOrgFinPeriod = null; newMainOrgFinPeriodID = (string)cache.GetValue(newRow, _FieldName); if (newMainOrgFinPeriodID == null) { return(null); } newMainOrgFinPeriod = FinPeriodRepository.FindByID(newMainCalendarOrgID, newMainOrgFinPeriodID); if (newMainOrgFinPeriod == null) { string errorMessage = null; if (newMainCalendarOrgID == FinPeriod.organizationID.MasterValue) { errorMessage = PXMessages.LocalizeFormatNoPrefix(Messages.MasterFinPeriodDoesNotExist, FormatForError(newMainOrgFinPeriodID)); } else { errorMessage = PXMessages.LocalizeFormatNoPrefix( Messages.FinPeriodDoesNotExistForCompany, FormatForError(newMainOrgFinPeriodID), PXAccess.GetOrganizationCD(newMainCalendarOrgID)); } SetErrorAndResetForMainFields(cache, oldRow, newRow, oldMainCalendarOrgID, newMainCalendarOrgID, externalCall, new PXSetPropertyException(errorMessage)); return(null); } return(newMainOrgFinPeriod); }
private void SendMails() { if (MassMails.Current == null || MassMails.Current.Status == CRMassMailStatusesAttribute.Send) { return; } if (MassMails.View.Answer == WebDialogResult.No) { this.Caches <CRLead>().Clear(); this.Caches <Contact>().Clear(); this.Caches <BAccount>().Clear(); this.Caches <EPEmployee>().Clear(); this.Caches <CRMarketingListMember>().Clear(); this.Caches <CRMarketingList>().Clear(); this.Caches <CRCampaign>().Clear(); return; } // TODO: need to get rid of 2 selects. Now it happens twice because of Ask if (MassMails.View.Answer == WebDialogResult.Yes) { var massMail = PXCache <CRMassMail> .CreateCopy(MassMails.Current); PXLongOperation.StartOperation(this, () => ProcessMassMailEmails(MassMails.Current, GetRecipientsForSendingDistinctByEmail())); } else { var mails = GetRecipientsForSendingDistinctByEmail(); if (mails.Count == 0) { throw new PXException(Messages.RecipientsNotFound); } this.Caches <Note>().Clear(); var confirmMessage = PXMessages.LocalizeFormatNoPrefix(Messages.MassMailSend, mails.Count); MassMails.Ask(Messages.Confirmation, confirmMessage, MessageButtons.YesNo); } }
protected virtual IEnumerable Action(PXAdapter adapter, [PXInt] [SOShipmentEntryActions] int?actionID, [PXString()] string ActionName ) { object queueName = null; if (actionID == SOShipmentEntryActionsAttribute.PrintPickList && adapter.Arguments.TryGetValue("PrintQueue", out queueName) && !String.IsNullOrEmpty(queueName as string)) { GL.Branch company = null; using (new PXReadBranchRestrictedScope()) { company = Base.Company.Select(); } using (PXTransactionScope ts = new PXTransactionScope()) { var jobMaint = PXGraph.CreateInstance <PrintJobMaint>(); foreach (SOShipment shipment in adapter.Get <SOShipment>()) { Base.Document.Current = shipment; string actualReportID = new NotificationUtility(Base).SearchReport(ARNotificationSource.Customer, Base.customer.Current, "SO644000", company.BranchID); jobMaint.AddPrintJob(PXMessages.LocalizeFormatNoPrefix(WM.Messages.PrintPickList, shipment.ShipmentNbr), queueName as string, actualReportID, new Dictionary <string, string> { { "ShipmentNbr", shipment.ShipmentNbr } }); shipment.PickListPrinted = true; Base.Document.Update(shipment); } Base.Save.Press(); ts.Complete(); } return(adapter.Get()); } else { return(Base.action.Press(adapter)); } }
protected virtual void EPActivityApprove_RowDeleting(PXCache sender, PXRowDeletingEventArgs e) { EPActivityApprove row = (EPActivityApprove)e.Row; if (row == null) { return; } if (row.ApprovalStatus == CR.ActivityStatusListAttribute.Approved || row.Released == true) { Filter.View.Ask((PXMessages.LocalizeFormatNoPrefix(Messages.ActivityIs, sender.GetValueExt <EPActivityApprove.approvalStatus>(row))), MessageButtons.OK); e.Cancel = true; } else if (row.TimeCardCD != null) { Filter.View.Ask(Messages.ActivityAssignedToTimeCard, MessageButtons.OK); e.Cancel = true; } }
public string All() { string localizedString; object parameter = new object(); localizedString = PXLocalizer.Localize(MyMessages.CommasInUserName + MyMessages.SomeString); localizedString = PXLocalizer.Localize(string.Format(MyMessages.StringToFormat, parameter), typeof(MyMessages).FullName); localizedString = PXLocalizer.LocalizeFormat(String.Concat(MyMessages.CommasInUserName, MyMessages.SomeString), parameter); localizedString = PXMessages.Localize(MyMessages.CommasInUserName + "123"); localizedString = PXMessages.Localize(string.Format(MyMessages.StringToFormat, 123), out string strPrefix); localizedString = PXMessages.LocalizeNoPrefix(string.Concat(MyMessages.CommasInUserName, "123")); localizedString = PXMessages.LocalizeFormat(MyMessages.StringToFormat + "456", parameter); localizedString = PXMessages.LocalizeFormat(string.Format(MyMessages.StringToFormat, parameter), out string prefix, parameter); localizedString = PXMessages.LocalizeFormatNoPrefix(string.Concat(MyMessages.StringToFormat, "456"), parameter); localizedString = PXMessages.LocalizeFormatNoPrefixNLA(string.Concat(MyMessages.StringToFormat, "456", "789"), parameter); return(localizedString); }
protected override bool PerformSearch(string query, bool isQuick) { DateTime start = DateTime.Now; query = query == string.Empty ? null : query; PXArticleSearch search = new PXArticleSearch(this.Request["wikiid"], this.Request["categoryID"], this.Request["productID"], this.Request["orderID"]); search.IsQuick = isQuick; search.LinkFormat = ArticleUrl + "?PageID={0}"; search.IgnoreCache = Search.CurrentPage == 0 ? true : false; List <PXSearchResult> articles = search.Search(query, Search.CurrentPage * 20, 20); if (articles.Count == 0) { Search.DisplaySearchTips(query, SearchTips); return(false); } int i = Search.CurrentPage * 20; foreach (PXArticleSearch.Result res in articles) { if (PXSiteMap.IsPortal) { Search.DisplayStar(res, res.Rating, res.Views, res.Publisheddate, res.Orderid, null); } else { Search.DisplayResult(res); } i++; } TimeSpan span = DateTime.Now.Subtract(start); Search.DisplayResult(PXMessages.LocalizeFormatNoPrefix(Messages.SearchResults, Search.CurrentPage * 20 + 1, i, search.TotalCount, HttpUtility.HtmlEncode(query), this.Search.FormatTimeResult(span))); Search.PagesCount = search.TotalCount % 20 == 0 ? search.TotalCount / 20 : search.TotalCount / 20 + 1; return(true); }
public virtual ProcessingResult <FinPeriod> GetFinPeriodByMasterPeriodID(int?organizationID, string masterFinPeriodID) { FinPeriod period = PXSelect <FinPeriod, Where <FinPeriod.organizationID, Equal <Required <FinPeriod.organizationID> >, And <FinPeriod.masterFinPeriodID, Equal <Required <FinPeriod.masterFinPeriodID> > > > > .Select(Graph, organizationID, masterFinPeriodID); var result = ProcessingResult <FinPeriod> .CreateSuccess(period); if (period == null) { string errorMessage = PXMessages.LocalizeFormatNoPrefix( Messages.RelatedFinPeriodsForMasterDoesNotExistForCompany, PeriodIDAttribute.FormatForError(masterFinPeriodID), PXAccess.GetOrganizationCD(organizationID)); result.AddErrorMessage(errorMessage); } return(result); }
public virtual IEnumerable deleteOrganizationLedgerLink(PXAdapter adapter) { var link = LinkCache.Current as OrganizationLedgerLink; if (link?.OrganizationID == null || link.LedgerID == null) { return(adapter.Get()); } Ledger ledger = GeneralLedgerMaint.FindLedgerByID(Base, link.LedgerID); if (ledger.BalanceType == LedgerBalanceType.Actual) { LinkCache.Delete(link); } else { if (GLUtility.RelatedGLHistoryExists(Base, link.LedgerID, link.OrganizationID)) { Organization org = OrganizationMaint.FindOrganizationByID(Base, link.OrganizationID, true); WebDialogResult dialogResult = OrganizationLedgerLinkSelect.Ask(PXMessages.LocalizeFormatNoPrefix( Messages.AtLeastOneGeneralLedgerTransactionHasBeenPosted, LinkCache.GetValueExt <OrganizationLedgerLink.ledgerID>(link).ToString().Trim(), org.OrganizationCD.Trim()), MessageButtons.YesNo); if (dialogResult == WebDialogResult.Yes) { LinkCache.Delete(link); } } else { LinkCache.Delete(link); } } return(adapter.Get()); }
/// <summary> /// Enables/Disables the Item Type field depending of there is at least one service related to. /// </summary> /// <param name="cache">PXCache instance.</param> /// <param name="itemClassRow">The current INItemClass object row.</param> /// <param name="fsxServiceClassRow">The current <c>FSxServiceClass</c> object row.</param> public virtual void EnableDisable_ItemType(PXCache cache, INItemClass itemClassRow, FSxServiceClass fsxServiceClassRow) { bool enableItemType = true; PXSetPropertyException exception = null; if (itemClassRow.ItemType == INItemTypes.ServiceItem && cache.GetStatus(itemClassRow) != PXEntryStatus.Inserted) { int rowCount = PXSelectJoin <InventoryItem, InnerJoin <INItemClass, On <INItemClass.itemClassID, Equal <InventoryItem.itemClassID> > >, Where < InventoryItem.itemClassID, Equal <Required <InventoryItem.itemClassID> >, And <InventoryItem.itemType, Equal <INItemTypes.serviceItem> > > > .SelectWindowed(cache.Graph, 0, 1, itemClassRow.ItemClassID).Count; enableItemType = rowCount == 0; } if (enableItemType == false) { exception = new PXSetPropertyException( PXMessages.LocalizeFormatNoPrefix(TX.Warning.CANNOT_MODIFY_FIELD, "Services", "Item Class"), PXErrorLevel.Warning); } cache.RaiseExceptionHandling <INItemClass.itemType>( itemClassRow, itemClassRow.ItemType, exception ); cache.RaiseExceptionHandling <FSxServiceClass.requireRoute>( itemClassRow, fsxServiceClassRow.RequireRoute, exception ); PXUIFieldAttribute.SetEnabled <INItemClass.itemType>(cache, itemClassRow, enableItemType); PXUIFieldAttribute.SetEnabled <FSxServiceClass.requireRoute>(cache, itemClassRow, enableItemType); }
/// <param name="shortFormat"> /// If set to <c>true</c>, then no "Past Due" or "Outstanding" postfix will /// be appended to the bucket description, making <paramref name="agingDirection"/> /// parameter irrelevant. /// </param> public static string GetDayAgingBucketDescription( int?lowerExclusiveBucketBoundary, int?upperInclusiveBucketBoundary, AgingDirection agingDirection, bool shortFormat) { if (lowerExclusiveBucketBoundary == null) { string description = agingDirection == AgingDirection.Backwards ? Messages.Current : Messages.PastDue; return(PXMessages.LocalizeNoPrefix(description)); } else if (lowerExclusiveBucketBoundary != null && upperInclusiveBucketBoundary == null) { string descriptionFormat = shortFormat ? Messages.OverDays : agingDirection == AgingDirection.Backwards ? Messages.OverDaysPastDue : Messages.OverDaysOutstanding; return(PXMessages.LocalizeFormatNoPrefix(descriptionFormat, lowerExclusiveBucketBoundary.Value)); } else if (lowerExclusiveBucketBoundary != null && upperInclusiveBucketBoundary != null) { string descriptionFormat = shortFormat ? Messages.IntervalDays : agingDirection == AgingDirection.Backwards ? Messages.IntervalDaysPastDue : Messages.IntervalDaysOutstanding; return(PXMessages.LocalizeFormatNoPrefix( descriptionFormat, lowerExclusiveBucketBoundary.Value + 1, upperInclusiveBucketBoundary.Value)); } return(null); }
/// <summary> /// Fill the info about system, /// </summary> private void SetInfoText() { string copyR = PXVersionInfo.Copyright; txtDummyInstallationID.Value = PXLicenseHelper.InstallationID; bool hasError = false; if (!PX.Data.Update.PXUpdateHelper.ChectUpdateStatus()) { this.updateError.Style["display"] = ""; hasError = true; } if (Request.QueryString["licenseexceeded"] != null) { this.logOutReasone.Style["display"] = ""; this.logOutReasoneMsg.InnerText = PXMessages.LocalizeFormatNoPrefix( PX.Data.ActionsMessages.LogoutReason, Request.QueryString["licenseexceeded"]); hasError = true; } else if (PXDatabase.Companies.Length > PXDatabase.AvailableCompanies.Length) { this.logOutReasone.Style["display"] = ""; this.logOutReasoneMsg.InnerText = PXMessages.LocalizeNoPrefix(PX.Data.ActionsMessages.CompaniesOverlimit); hasError = true; } // sets the customization info text string status = Customization.CstWebsiteStorage.GetUpgradeStatus(); if (!String.IsNullOrEmpty(status)) { this.customizationError.Style["display"] = ""; this.custErrorContent.InnerText = status; hasError = true; } login_info.Style[HtmlTextWriterStyle.Display] = hasError ? "" : "none"; }
/// <summary> /// Validate subaccountCD length /// and insert "Consolidation Segment Value" if it is need /// </summary> public Sub.Keys GetMappedSubaccountKeys(string subaccountCD) { if (subaccountCD == null) { throw new ArgumentNullException("subaccountCD"); } var pasteFlag = GLConsolSetup.PasteFlag ?? false; var pastingSegmentLength = pasteFlag ? GLConsolSetup.SegmentValue.Length : 0; var extrapolatedSubaccountLength = subaccountCD.Length + pastingSegmentLength; if (extrapolatedSubaccountLength != _subaccountCDKeyLength) { Logger.WriteWarning(PXMessages.LocalizeFormatNoPrefix(Messages.ConsolidationFailedToAssembleDestinationSub, subaccountCD)); } if (extrapolatedSubaccountLength < _subaccountCDKeyLength) { subaccountCD = subaccountCD.PadRight(_subaccountCDKeyLength - pastingSegmentLength); } if (pasteFlag) { subaccountCD = subaccountCD.Insert(_segmentStartIndex, GLConsolSetup.SegmentValue); } if (subaccountCD.Length > _subaccountCDKeyLength) { subaccountCD = subaccountCD.Substring(0, _subaccountCDKeyLength); } return(new Sub.Keys() { SubCD = subaccountCD, SubID = _findSubIdbyCD(subaccountCD) }); }
/// <summary> /// /// </summary> protected void Page_Load(object sender, EventArgs e) { string copyR = PXVersionInfo.Copyright; String version = PXMessages.LocalizeFormatNoPrefix(PX.AscxControlsMessages.PageTitle.Version, PXVersionInfo.Version); if (!PX.Data.Update.PXUpdateHelper.VersionsEquals()) { version = "<b style=\"color:red\">" + version + "</b>"; } if (!PX.Data.Update.PXUpdateHelper.ChectUpdateStatus()) { version = "<b style=\"color:red\">" + version + "</b>"; } lblCopy.Text = copyR + " " + version; string cstProjects = Customization.CstWebsiteStorage.PublishedProjectList; if (!string.IsNullOrEmpty(cstProjects)) { this.lblCstProjects.Visible = true; this.lblCstProjects.Text = string.Format("Customized: {0}", cstProjects.Replace(",", ", ")); } this.CorrectCssUrl(); }
public virtual ProcessingResult <FABookPeriod> GetFABookPeriodByMasterPeriodID(int?bookID, int?organizationID, string masterFinPeriodID) { FABookPeriod period = SelectFrom <FABookPeriod> .Where <FABookPeriod.bookID.IsEqual <@P.AsInt> .And <FABookPeriod.organizationID.IsEqual <@P.AsInt> > .And <FABookPeriod.masterFinPeriodID.IsEqual <@P.AsString> > > .View .ReadOnly .Select(Graph, bookID, organizationID, masterFinPeriodID); ProcessingResult <FABookPeriod> result = ProcessingResult <FABookPeriod> .CreateSuccess(period); if (period == null) { string errorMessage = PXMessages.LocalizeFormatNoPrefix( GL.Messages.RelatedFinPeriodsForMasterDoesNotExistForCompany, PeriodIDAttribute.FormatForError(masterFinPeriodID), PXAccess.GetOrganizationCD(organizationID)); result.AddErrorMessage(errorMessage); } return(result); }
private void CheckFields(PXCache cache, object row, params Type[] fields) { var errors = new Dictionary <string, string>(fields.Length); foreach (Type field in fields) { var value = cache.GetValue(row, field.Name); if (value == null || (value is string && string.IsNullOrEmpty(value as string))) { var state = cache.GetValueExt(row, field.Name) as PXFieldState; var fieldDisplayName = state == null || string.IsNullOrEmpty(state.DisplayName) ? field.Name : state.DisplayName; var errorMessage = PXMessages.LocalizeFormatNoPrefix(Messages.EmptyValueErrorFormat, fieldDisplayName); var fieldName = cache.GetField(field); errors.Add(fieldName, errorMessage); PXUIFieldAttribute.SetError(cache, row, fieldName, errorMessage); } } if (errors.Count > 0) { throw new PXOuterException(errors, GetType(), row, ErrorMessages.RecordRaisedErrors, null, cache.GetItemType().Name); } }
/// <summary> /// Gets the employees contact info separated by a coma. /// </summary> /// <param name="graph">Graph to use.</param> /// <param name="concatenateNames">Boolean that if true, returns the Staff name(s).</param> /// <param name="concatenateCells">Boolean that if true, returns the Staff cell phone(s).</param> /// <param name="appointmentID">Appointment ID.</param> private static StringBuilder GetsEmployeesContactInfo(PXGraph graph, bool concatenateNames, bool concatenateCells, int?appointmentID) { StringBuilder names = new StringBuilder(); int i = 0; // TODO SD-7612 this BQL is not currently retrieving contact info for vendors BqlCommand fsAppointmentEmployeeContactInfoBql = new Select5 <FSAppointmentEmployee, InnerJoin <BAccount, On < BAccount.bAccountID, Equal <FSAppointmentEmployee.employeeID> >, InnerJoin <Contact, On < BAccount.defContactID, Equal <Contact.contactID> > > >, Where < FSAppointmentEmployee.appointmentID, Equal <Required <FSAppointmentEmployee.appointmentID> > >, Aggregate < GroupBy <FSAppointmentEmployee.employeeID> >, OrderBy < Asc <FSAppointmentEmployee.employeeID> > >(); PXView fsAppointmentEmployeeContactInfoView = new PXView(graph, true, fsAppointmentEmployeeContactInfoBql); var fsAppointmentEmployeeSet = fsAppointmentEmployeeContactInfoView.SelectMulti(appointmentID); if (fsAppointmentEmployeeSet.Count > 0) { foreach (PXResult <FSAppointmentEmployee, BAccount, Contact> bqlResult in fsAppointmentEmployeeSet) { FSAppointmentEmployee fsAppointmentEmployeeRow = (FSAppointmentEmployee)bqlResult; BAccount bAccountRow = (BAccount)bqlResult; Contact contactRow = (Contact)bqlResult; i++; if (fsAppointmentEmployeeSet.Count > 1 && i == fsAppointmentEmployeeSet.Count) { names.Append(PXMessages.LocalizeFormatNoPrefix(TX.Messages.LIST_LAST_ITEM_PREFIX)); } else { if (names.Length != 0) { names.Append(", "); } } if (fsAppointmentEmployeeRow.Type == BAccountType.EmployeeType) { if (string.IsNullOrEmpty(contactRow.FirstName) == false && concatenateNames == true) { names.Append(contactRow.FirstName.Trim()); } if (string.IsNullOrEmpty(contactRow.LastName) == false && concatenateNames == true) { names.Append(' '); names.Append(contactRow.LastName.Trim()); } } else if (fsAppointmentEmployeeRow.Type == BAccountType.VendorType) { if (string.IsNullOrEmpty(contactRow.FullName) == false && concatenateNames == true) { names.Append(contactRow.FullName.Trim()); } } if (string.IsNullOrEmpty(contactRow.Phone1) == false && concatenateCells == true) { names.Append(contactRow.Phone1.Trim()); } else if (concatenateCells == true) { names.Append(TX.Messages.NO_CONTACT_CELL_FOR_THE_STAFF); } } } else { names.Append(TX.Messages.NO_STAFF_ASSIGNED_FOR_THE_APPOINTMENT); } return(names); }
public virtual CommitTaxRequest BuildCommitTaxRequestWithFrt(ARInvoice invoice) { if (invoice == null) { throw new PXArgumentException(nameof(invoice), ErrorMessages.ArgumentNullException); } Customer cust = (Customer)Base.customer.View.SelectSingleBound(new object[] { invoice }); CR.Location loc = (CR.Location)Base.location.View.SelectSingleBound(new object[] { invoice }); CommitTaxRequest request = new CommitTaxRequest(); request.CompanyCode = Base1.CompanyCodeFromBranch(invoice.TaxZoneID, invoice.BranchID); request.CurrencyCode = invoice.CuryID; request.CustomerCode = cust.AcctCD; request.TaxRegistrationID = loc?.TaxRegistrationID; IAddressBase fromAddress = Base1.GetFromAddress(invoice); IAddressBase toAddress = Base1.GetToAddress(invoice); if (fromAddress == null) { throw new PXException(Messages.FailedGetFrom); } if (toAddress == null) { throw new PXException(Messages.FailedGetTo); } request.OriginAddress = AddressConverter.ConvertTaxAddress(fromAddress); request.DestinationAddress = AddressConverter.ConvertTaxAddress(toAddress); request.DocCode = $"AR.{invoice.DocType}.{invoice.RefNbr}"; request.DocDate = invoice.DocDate.GetValueOrDefault(); request.LocationCode = GetExternalTaxProviderLocationCode <ARTran, ARTran.FK.Invoice.SameAsCurrent, ARTran.siteID>(invoice); request.CustomerUsageType = invoice.AvalaraCustomerUsageType; if (!string.IsNullOrEmpty(invoice.ExternalTaxExemptionNumber)) { request.ExemptionNo = invoice.ExternalTaxExemptionNumber; } request.DocType = Base1.GetTaxDocumentType(invoice); Sign sign = Base1.GetDocumentSign(invoice); PXSelectBase <ARTran> select = new PXSelectJoin <ARTran, LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <ARTran.inventoryID> >, LeftJoin <Account, On <Account.accountID, Equal <ARTran.accountID> > > >, Where <ARTran.tranType, Equal <Current <ARInvoice.docType> >, And <ARTran.refNbr, Equal <Current <ARInvoice.refNbr> >, And <Where <ARTran.lineType, NotEqual <SOLineType.discount>, Or <ARTran.lineType, IsNull> > > > >, OrderBy <Asc <ARTran.tranType, Asc <ARTran.refNbr, Asc <ARTran.lineNbr> > > > >(Base); request.Discount = Base.Document.Current.CuryDiscTot.GetValueOrDefault(); DateTime?taxDate = invoice.OrigDocDate; bool applyRetainage = Base.ARSetup.Current?.RetainTaxes != true && invoice.IsOriginalRetainageDocument(); /// <summary> /// Add the following condition and logic per Jira [IP-23] /// </summary>> string taxCategory = (Base as SOInvoiceEntry).FreightDetails.Current?.TaxCategoryID; if (invoice.CuryFreightTot > 0 && GL.Branch.PK.Find(Base, Base.Accessinfo.BranchID).CountryID == Country_US && invoice.TaxZoneID == TaxCloud && !string.IsNullOrEmpty(taxCategory)) { var line = new TaxCartItem(); line.Index = short.MinValue; line.Quantity = 1; line.UOM = "EA"; line.Amount = sign * invoice.CuryFreightTot.GetValueOrDefault(); line.Description = PXMessages.LocalizeNoPrefix(SO.Messages.FreightDesc); line.DestinationAddress = request.DestinationAddress; line.OriginAddress = request.OriginAddress; line.ItemCode = "N/A"; line.Discounted = false; line.TaxCode = taxCategory; request.CartItems.Add(line); } foreach (PXResult <ARTran, InventoryItem, Account> res in select.View.SelectMultiBound(new object[] { invoice })) { ARTran tran = (ARTran)res; InventoryItem item = (InventoryItem)res; Account salesAccount = (Account)res; var line = new TaxCartItem(); line.Index = tran.LineNbr ?? 0; line.Amount = sign * (tran.CuryTranAmt.GetValueOrDefault() + (applyRetainage ? tran.CuryRetainageAmt.GetValueOrDefault() : 0m)); line.Description = tran.TranDesc; line.DestinationAddress = AddressConverter.ConvertTaxAddress(Base1.GetToAddress(invoice, tran)); line.OriginAddress = AddressConverter.ConvertTaxAddress(Base1.GetFromAddress(invoice, tran)); line.ItemCode = item.InventoryCD; line.Quantity = Math.Abs(tran.Qty.GetValueOrDefault()); line.UOM = tran.UOM; line.Discounted = tran.LineType != SOLineType.Freight && request.Discount > 0; line.RevAcct = salesAccount.AccountCD; line.TaxCode = tran.TaxCategoryID; line.CustomerUsageType = tran.AvalaraCustomerUsageType; if (tran.OrigInvoiceDate != null) { taxDate = tran.OrigInvoiceDate; } request.CartItems.Add(line); } if (applyRetainage) { var line = new TaxCartItem(); line.Index = invoice.LineCntr.GetValueOrDefault() + 1; line.Amount = Sign.Minus * sign * invoice.CuryLineRetainageTotal.GetValueOrDefault(); line.Description = PXMessages.LocalizeFormatNoPrefix(AP.Messages.RetainageForTransactionDescription, GetLabel.For <ARDocType>(invoice.DocType), invoice.RefNbr); line.DestinationAddress = request.DestinationAddress; line.OriginAddress = request.OriginAddress; line.ItemCode = "Retainage"; line.Discounted = false; line.NonTaxable = true; request.CartItems.Add(line); } if ((invoice.DocType == ARDocType.CreditMemo || invoice.DocType == ARDocType.CashReturn) && invoice.OrigDocDate != null) { request.TaxOverride.Reason = Messages.ReturnReason; request.TaxOverride.TaxDate = taxDate.Value; request.TaxOverride.TaxOverrideType = TaxOverrideType.TaxDate; sign = Sign.Minus; } return(request); }
protected override void ValidatePeriodAndSourcesImpl(PXCache cache, object oldRow, object newRow, bool externalCall) { PeriodKeyProviderBase.KeyWithSourceValuesCollection < FABookPeriodKeyProvider.FAKeyWithSourceValues, FABookPeriodKeyProvider.FASourceSpecificationItem, FABookPeriod.Key> newKeyWithSourceValues = FABookPeriodKeyProvider.GetKeys(cache.Graph, cache, newRow); PeriodKeyProviderBase.KeyWithSourceValuesCollection < FABookPeriodKeyProvider.FAKeyWithSourceValues, FABookPeriodKeyProvider.FASourceSpecificationItem, FABookPeriod.Key> oldKeyWithSourceValues = FABookPeriodKeyProvider.GetKeys(cache.Graph, cache, oldRow); FABookPeriod.Key newPeriodKey = newKeyWithSourceValues.ConsolidatedKey; newPeriodKey.PeriodID = (string)cache.GetValue(newRow, _FieldName); if (!newPeriodKey.Defined) { return; } IFABookPeriodRepository periodRepository = cache.Graph.GetService <IFABookPeriodRepository>(); FABookPeriod period = periodRepository.FindByKey(newPeriodKey.BookID, newPeriodKey.OrganizationID, newPeriodKey.PeriodID); if (period == null) { PXSetPropertyException exception = null; FABook book = BookMaint.FindByID(cache.Graph, newPeriodKey.BookID); if (book.UpdateGL == true) { exception = new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix( Messages.PeriodDoesNotExistForBookAndCompany, FormatForError(newPeriodKey.PeriodID), book.BookCode, PXAccess.GetOrganizationCD(newPeriodKey.OrganizationID))); if (FAMainSpecificationItem.OrganizationSourceType != null && newKeyWithSourceValues.MainItem.SourceOrganizationIDs.First() != null && newKeyWithSourceValues.MainItem.SourceOrganizationIDs.First() != oldKeyWithSourceValues.MainItem.SourceOrganizationIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.OrganizationSourceType.Name, exception, externalCall); } if (FAMainSpecificationItem.BranchSourceType != null && newKeyWithSourceValues.MainItem.SourceBranchIDs.First() != null && newKeyWithSourceValues.MainItem.SourceBranchIDs.First() != oldKeyWithSourceValues.MainItem.SourceBranchIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.BranchSourceType.Name, exception, externalCall); } if (FAMainSpecificationItem.AssetSourceType != null && newKeyWithSourceValues.MainItem.SourceAssetIDs.First() != null && newKeyWithSourceValues.MainItem.SourceAssetIDs.First() != oldKeyWithSourceValues.MainItem.SourceAssetIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.AssetSourceType.Name, exception, externalCall); } } else { exception = new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix( Messages.PeriodDoesNotExistForBook, FormatForError(newPeriodKey.PeriodID))); } cache.RaiseExceptionHandling( _FieldName, newRow, FormatForDisplay(newPeriodKey.PeriodID), exception); cache.SetValue( newRow, _FieldName, cache.GetValue(oldRow, _FieldName)); if (FAMainSpecificationItem.BookSourceType != null && newKeyWithSourceValues.MainItem.SourceBookIDs.First() != null && newKeyWithSourceValues.MainItem.SourceBookIDs.First() != oldKeyWithSourceValues.MainItem.SourceBookIDs.First()) { SetErrorAndResetToOldForField( cache, oldRow, newRow, FAMainSpecificationItem.BookSourceType.Name, exception, externalCall); } } }
public override void RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { if ((e.Row as APTran) == null || sender.GetValue <APTran.tranType>(e.Row) as string != APDocType.Prepayment) { base.RowUpdated(sender, e); return; } AmountLineFields lineAmountsFields = GetDiscountDocumentLine(sender, e.Row); if (lineAmountsFields.FreezeManualDisc == true) { lineAmountsFields.FreezeManualDisc = false; return; } DiscountLineFields lineDiscountFields = GetDiscountedLine(sender, e.Row); DiscountLineFields oldLineDiscountFields = GetDiscountedLine(sender, e.OldRow); if (lineDiscountFields.LineType == SOLineType.Discount) { return; } // Force auto mode. if (lineDiscountFields.ManualDisc == false && oldLineDiscountFields.ManualDisc == true) { sender.SetValueExt(e.Row, sender.GetField(typeof(DiscountLineFields.discPct)), 0m); sender.SetValueExt(e.Row, sender.GetField(typeof(DiscountLineFields.curyDiscAmt)), 0m); return; } if ((lineAmountsFields.CuryExtPrice ?? 0m) == 0) { sender.SetValueExt(e.Row, sender.GetField(typeof(DiscountLineFields.curyDiscAmt)), 0m); return; } LineEntitiesFields lineEntities = LineEntitiesFields.GetMapFor(e.Row, sender); AmountLineFields oldLineAmountsFields = GetDiscountDocumentLine(sender, e.OldRow); bool discountIsUpdated = false; if (lineDiscountFields.CuryDiscAmt != oldLineDiscountFields.CuryDiscAmt) { if (Math.Abs(lineDiscountFields.CuryDiscAmt ?? 0m) > Math.Abs(lineAmountsFields.CuryExtPrice.Value)) { sender.SetValueExt(e.Row, sender.GetField(typeof(DiscountLineFields.curyDiscAmt)), lineAmountsFields.CuryExtPrice); PXUIFieldAttribute.SetWarning <DiscountLineFields.curyDiscAmt>(sender, e.Row, PXMessages.LocalizeFormatNoPrefix(AR.Messages.LineDiscountAmtMayNotBeGreaterExtPrice, lineAmountsFields.ExtPriceDisplayName)); } decimal?discPct = CalcDiscountPercent(lineAmountsFields, lineDiscountFields); sender.SetValueExt(e.Row, sender.GetField(typeof(DiscountLineFields.discPct)), discPct); discountIsUpdated = true; } else if (lineDiscountFields.DiscPct != oldLineDiscountFields.DiscPct || oldLineAmountsFields.CuryExtPrice != lineAmountsFields.CuryExtPrice) { decimal discAmt = CalcDiscountAmount(sender, GetLineDiscountTarget(sender, lineEntities), lineAmountsFields, lineDiscountFields); sender.SetValueExt(e.Row, sender.GetField(typeof(DiscountLineFields.curyDiscAmt)), discAmt); discountIsUpdated = true; } if (discountIsUpdated || sender.Graph.IsCopyPasteContext) { sender.SetValue(e.Row, this.FieldName, true); // Switch to manual mode. } }
protected virtual void _(Events.FieldUpdated <FSSetup, FSSetup.appAutoConfirmGap> e) { if (e.Row == null) { return; } FSSetup fsSetupRow = (FSSetup)e.Row; if (fsSetupRow.AppAutoConfirmGap < 0) { e.Cache.RaiseExceptionHandling <FSSetup.appAutoConfirmGap>(fsSetupRow, fsSetupRow.AppAutoConfirmGap, new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix(TX.Error.MINIMUN_VALUE, " 00 h 00 m"), PXErrorLevel.Error)); } }
public override void AddMessage(PXErrorLevel errorLevel, string message, params object[] args) { _messages.Add(new ProcessingResultMessage(errorLevel, PXMessages.LocalizeFormatNoPrefix(message, args))); }
public void CreateBatch(JournalEntry je, string periodId, int?ledgerID, int?branchID, GLConsolSetup item) { je.Clear(); je.glsetup.Current.RequireControlTotal = false; Ledger ledger = PXSelect <Ledger, Where <Ledger.ledgerID, Equal <Required <Ledger.ledgerID> > > > .Select(this, ledgerID); FinPeriod fiscalPeriod = PXSelect <FinPeriod, Where <FinPeriod.finPeriodID, Equal <Required <FinPeriod.finPeriodID> > > > . Select(this, periodId); if (fiscalPeriod == null) { throw new FiscalPeriodInvalidException(periodId); } je.Accessinfo.BusinessDate = fiscalPeriod.EndDate.Value.AddDays(-1); CurrencyInfo info = new CurrencyInfo(); info.CuryID = ledger.BaseCuryID; info.CuryEffDate = fiscalPeriod.EndDate.Value.AddDays(-1); info.CuryRate = (decimal)1.0; info = je.currencyinfo.Insert(info); Batch batch = new Batch(); batch.TranPeriodID = periodId; batch.BranchID = branchID; batch.LedgerID = ledgerID; batch.Module = BatchModule.GL; batch.Hold = false; batch.Released = false; batch.CuryID = ledger.BaseCuryID; batch.CuryInfoID = info.CuryInfoID; batch.FinPeriodID = periodId; batch.CuryID = ledger.BaseCuryID; batch.BatchType = BatchTypeCode.Consolidation; batch.Description = PXMessages.LocalizeFormatNoPrefix(Messages.ConsolidationBatch, item.Description); batch = je.BatchModule.Insert(batch); foreach (GLConsolRead read in listConsolRead) { Action <decimal?, decimal?> insertTransaction = (debitAmt, creditAmt) => { GLTran tran = new GLTran(); tran.AccountID = read.AccountID; tran.SubID = read.SubID; tran.CuryInfoID = info.CuryInfoID; tran.CuryCreditAmt = creditAmt; tran.CuryDebitAmt = debitAmt; tran.CreditAmt = creditAmt; tran.DebitAmt = debitAmt; tran.TranType = GLTran.tranType.Consolidation; tran.TranClass = GLTran.tranClass.Consolidation; tran.TranDate = fiscalPeriod.EndDate.Value.AddDays(-1); tran.TranDesc = Messages.ConsolidationDetail; tran.TranPeriodID = periodId; tran.RefNbr = ""; tran.ProjectID = PM.ProjectDefaultAttribute.NonProject(); tran = je.GLTranModuleBatNbr.Insert(tran); if (tran != null && tran.SubID == null && read.MappedValue != null) { je.GLTranModuleBatNbr.SetValueExt <GLTran.subID>(tran, read.MappedValue); } if (tran == null || tran.AccountID == null || tran.SubID == null) { throw new PXException(Messages.AccountOrSubNotFound, read.AccountCD, read.MappedValue); } }; if (Math.Abs((decimal)read.ConsolAmtDebit) > 0) { insertTransaction(read.ConsolAmtDebit, 0m); } if (Math.Abs((decimal)read.ConsolAmtCredit) > 0) { insertTransaction(0m, read.ConsolAmtCredit); } } item.LastPostPeriod = periodId; item.LastConsDate = DateTime.Now; je.Caches[typeof(GLConsolSetup)].Update(item); if (!je.Views.Caches.Contains(typeof(GLConsolSetup))) { je.Views.Caches.Add(typeof(GLConsolSetup)); } GLConsolBatch cb = new GLConsolBatch(); cb.SetupID = item.SetupID; je.Caches[typeof(GLConsolBatch)].Insert(cb); if (!je.Views.Caches.Contains(typeof(GLConsolBatch))) { je.Views.Caches.Add(typeof(GLConsolBatch)); } try { je.Save.Press(); } catch (PXException e) { try { if (!String.IsNullOrEmpty(PXUIFieldAttribute.GetError <Batch.curyCreditTotal>(je.BatchModule.Cache, je.BatchModule.Current)) || !String.IsNullOrEmpty(PXUIFieldAttribute.GetError <Batch.curyDebitTotal>(je.BatchModule.Cache, je.BatchModule.Current))) { je.BatchModule.Current.Hold = true; je.BatchModule.Update(je.BatchModule.Current); } je.Save.Press(); if (exception == null) { exception = new PXException(Messages.ConsolidationBatchOutOfBalance, je.BatchModule.Current.BatchNbr); } else { exception = new PXException(exception.Message + Messages.ConsolidationBatchOutOfBalance, je.BatchModule.Current.BatchNbr); } } catch { throw e; } } }
public virtual void RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { AmountLineFields lineAmountsFields = GetDiscountDocumentLine(sender, e.Row); if (lineAmountsFields.FreezeManualDisc == true) { lineAmountsFields.FreezeManualDisc = false; return; } DiscountLineFields lineDiscountFields = GetDiscountedLine(sender, e.Row); if (lineDiscountFields.LineType == SOLineType.Discount) { return; } AmountLineFields oldLineAmountsFields = GetDiscountDocumentLine(sender, e.OldRow); DiscountLineFields oldLineDiscountFields = GetDiscountedLine(sender, e.OldRow); LineEntitiesFields lineEntities = LineEntitiesFields.GetMapFor(e.Row, sender); LineEntitiesFields oldLineEntities = LineEntitiesFields.GetMapFor(e.OldRow, sender); bool manualMode = false; //by default AutoMode. bool useDiscPct = false; //by default value in DiscAmt has higher priority than DiscPct when both are modified. bool keepDiscountID = true; //should be set to true if user changes discount code code manually bool manualDiscUnchecked = false; //Force Auto Mode if (lineDiscountFields.ManualDisc == false && oldLineDiscountFields.ManualDisc == true) { manualMode = false; manualDiscUnchecked = true; } //Change to Manual Mode based on fields changed: if (lineDiscountFields.ManualDisc == true || sender.Graph.IsCopyPasteContext) { manualMode = true; } //if (row.IsFree == true && oldRow.IsFree != true) // manualMode = true; if (lineDiscountFields.DiscPct != oldLineDiscountFields.DiscPct && lineEntities.InventoryID == oldLineEntities.InventoryID) { manualMode = true; useDiscPct = true; } //use DiscPct when only Quantity/CuryUnitPrice/CuryExtPrice was changed if (lineDiscountFields.DiscPct == oldLineDiscountFields.DiscPct && lineDiscountFields.CuryDiscAmt == oldLineDiscountFields.CuryDiscAmt && (lineAmountsFields.Quantity != oldLineAmountsFields.Quantity || lineAmountsFields.CuryUnitPrice != oldLineAmountsFields.CuryUnitPrice || lineAmountsFields.CuryExtPrice != oldLineAmountsFields.CuryExtPrice)) { useDiscPct = true; } if (lineDiscountFields.CuryDiscAmt != oldLineDiscountFields.CuryDiscAmt && lineAmountsFields.Quantity == oldLineAmountsFields.Quantity && lineAmountsFields.CuryUnitPrice == oldLineAmountsFields.CuryUnitPrice) { manualMode = true; useDiscPct = false; } if (e.ExternalCall && (((Math.Abs((lineDiscountFields.CuryDiscAmt ?? 0m) - (oldLineDiscountFields.CuryDiscAmt ?? 0m)) > 0.0000005m) || (Math.Abs((lineDiscountFields.DiscPct ?? 0m) - (oldLineDiscountFields.DiscPct ?? 0m)) > 0.0000005m)) && lineDiscountFields.DiscountID == oldLineDiscountFields.DiscountID)) { keepDiscountID = false; } //if only CuryLineAmt (Ext.Price) was changed for a line with DiscoutAmt<>0 //for Contracts Qty * UnitPrice * Prorate(<>1) = ExtPrice if (lineAmountsFields.CuryLineAmount != oldLineAmountsFields.CuryLineAmount && lineAmountsFields.Quantity == oldLineAmountsFields.Quantity && lineAmountsFields.CuryUnitPrice == oldLineAmountsFields.CuryUnitPrice && lineAmountsFields.CuryExtPrice == oldLineAmountsFields.CuryExtPrice && lineDiscountFields.DiscPct == oldLineDiscountFields.DiscPct && lineDiscountFields.CuryDiscAmt == oldLineDiscountFields.CuryDiscAmt && lineDiscountFields.CuryDiscAmt != 0) { manualMode = true; } decimal?validLineAmtRaw; decimal?validLineAmt = null; if (lineAmountsFields.CuryLineAmount != oldLineAmountsFields.CuryLineAmount) { if (useDiscPct) { decimal val = lineAmountsFields.CuryExtPrice ?? 0; decimal disctAmt; if (GetLineDiscountTarget(sender, lineEntities) == LineDiscountTargetType.SalesPrice) { disctAmt = PXCurrencyAttribute.Round(sender, lineAmountsFields, (lineAmountsFields.Quantity ?? 0m) * (lineAmountsFields.CuryUnitPrice ?? 0m), CMPrecision.TRANCURY) - PXCurrencyAttribute.Round(sender, lineAmountsFields, (lineAmountsFields.Quantity ?? 0m) * PXDBPriceCostAttribute.Round((lineAmountsFields.CuryUnitPrice ?? 0m) * (1 - (lineDiscountFields.DiscPct ?? 0m) * 0.01m)), CMPrecision.TRANCURY); } else { disctAmt = val * (lineDiscountFields.DiscPct ?? 0m) * 0.01m; disctAmt = PXCurrencyAttribute.Round(sender, lineDiscountFields, disctAmt, CMPrecision.TRANCURY); } validLineAmtRaw = lineAmountsFields.CuryExtPrice - disctAmt; validLineAmt = PXCurrencyAttribute.Round(sender, lineAmountsFields, validLineAmtRaw ?? 0, CMPrecision.TRANCURY); } else { if (lineDiscountFields.CuryDiscAmt > lineAmountsFields.CuryExtPrice) { validLineAmtRaw = lineAmountsFields.CuryExtPrice; } else { validLineAmtRaw = lineAmountsFields.CuryExtPrice - lineDiscountFields.CuryDiscAmt; } validLineAmt = PXCurrencyAttribute.Round(sender, lineAmountsFields, validLineAmtRaw ?? 0, CMPrecision.TRANCURY); } if (lineAmountsFields.CuryLineAmount != validLineAmt && lineDiscountFields.DiscPct != oldLineDiscountFields.DiscPct) { manualMode = true; } } sender.SetValue(e.Row, this.FieldName, manualMode); //Process only Manual Mode: if (manualMode || sender.Graph.IsCopyPasteContext) { if (manualMode && !keepDiscountID && !sender.Graph.IsImport) { lineDiscountFields.DiscountID = null; lineDiscountFields.DiscountSequenceID = null; } //Update related fields: if (lineAmountsFields.Quantity == 0 && oldLineAmountsFields.Quantity != 0) { sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), 0m); sender.SetValueExt(e.Row, sender.GetField(typeof(discPct)), 0m); } else if (lineAmountsFields.CuryLineAmount != oldLineAmountsFields.CuryLineAmount && !useDiscPct) { decimal?extAmt = lineAmountsFields.CuryExtPrice ?? 0; decimal?lineAmt = lineAmountsFields.CuryLineAmount ?? 0; if (extAmt - lineAmountsFields.CuryLineAmount >= 0) { if (lineDiscountFields.CuryDiscAmt > Math.Abs(extAmt ?? 0m)) { sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), lineAmountsFields.CuryExtPrice); PXUIFieldAttribute.SetWarning <DiscountLineFields.curyDiscAmt>(sender, e.Row, PXMessages.LocalizeFormatNoPrefix(AR.Messages.LineDiscountAmtMayNotBeGreaterExtPrice, lineAmountsFields.ExtPriceDisplayName)); } else { sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), extAmt - lineAmountsFields.CuryLineAmount); } if (extAmt != 0 && !sender.Graph.IsCopyPasteContext) { decimal?pct = 100 * lineDiscountFields.CuryDiscAmt / extAmt; sender.SetValueExt(e.Row, sender.GetField(typeof(discPct)), pct); } } else if (extAmt != 0 && !sender.Graph.IsCopyPasteContext) { if (lineDiscountFields.CuryDiscAmt != oldLineDiscountFields.CuryDiscAmt) { decimal?pct = 100 * lineDiscountFields.CuryDiscAmt / extAmt; sender.SetValueExt(e.Row, sender.GetField(typeof(discPct)), (pct ?? 0m) < -100m ? -100m : pct); if ((pct ?? 0m) < -100m) { sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), -lineAmountsFields.CuryExtPrice); PXUIFieldAttribute.SetWarning <DiscountLineFields.curyDiscAmt>(sender, e.Row, PXMessages.LocalizeFormatNoPrefix(AR.Messages.LineDiscountAmtMayNotBeGreaterExtPrice, lineAmountsFields.ExtPriceDisplayName)); } } else { sender.SetValueExt(e.Row, sender.GetField(typeof(discPct)), 0m); sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), 0m); sender.SetValueExt(e.Row, sender.GetField(typeof(curyLineAmt)), lineAmt); } } } else if (lineDiscountFields.CuryDiscAmt != oldLineDiscountFields.CuryDiscAmt) { if (lineAmountsFields.CuryExtPrice != 0 && !sender.Graph.IsCopyPasteContext) { if (lineAmountsFields.CuryExtPrice != 0 && !sender.Graph.IsCopyPasteContext) { decimal?pct = (lineDiscountFields.CuryDiscAmt ?? 0) * 100 / lineAmountsFields.CuryExtPrice; sender.SetValueExt(e.Row, sender.GetField(typeof(discPct)), pct); } } } else if (lineDiscountFields.DiscPct != oldLineDiscountFields.DiscPct) { decimal val = lineAmountsFields.CuryExtPrice ?? 0; decimal amt; if (GetLineDiscountTarget(sender, lineEntities) == LineDiscountTargetType.SalesPrice) { if (lineAmountsFields.CuryUnitPrice != 0 && lineAmountsFields.Quantity != 0)//if sales price is available { amt = PXCurrencyAttribute.Round(sender, lineAmountsFields, (lineAmountsFields.Quantity ?? 0m) * (lineAmountsFields.CuryUnitPrice ?? 0m), CMPrecision.TRANCURY) - PXCurrencyAttribute.Round(sender, lineAmountsFields, (lineAmountsFields.Quantity ?? 0m) * PXDBPriceCostAttribute.Round((lineAmountsFields.CuryUnitPrice ?? 0m) * (1 - (lineDiscountFields.DiscPct ?? 0m) * 0.01m)), CMPrecision.TRANCURY); } else { amt = val * (lineDiscountFields.DiscPct ?? 0m) * 0.01m; } } else { amt = val * (lineDiscountFields.DiscPct ?? 0m) * 0.01m; } sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), amt); } else if (validLineAmt != null && lineAmountsFields.CuryLineAmount != validLineAmt) { decimal val = lineAmountsFields.CuryExtPrice ?? 0; decimal amt; if (GetLineDiscountTarget(sender, lineEntities) == LineDiscountTargetType.SalesPrice) { if (lineAmountsFields.CuryUnitPrice != 0 && lineAmountsFields.Quantity != 0)//if sales price is available { amt = PXCurrencyAttribute.Round(sender, lineAmountsFields, (lineAmountsFields.Quantity ?? 0m) * (lineAmountsFields.CuryUnitPrice ?? 0m), CMPrecision.TRANCURY) - PXCurrencyAttribute.Round(sender, lineAmountsFields, (lineAmountsFields.Quantity ?? 0m) * PXDBPriceCostAttribute.Round((lineAmountsFields.CuryUnitPrice ?? 0m) * (1 - (lineDiscountFields.DiscPct ?? 0m) * 0.01m)), CMPrecision.TRANCURY); } else { amt = val * (lineDiscountFields.DiscPct ?? 0m) * 0.01m; } } else { amt = val * (lineDiscountFields.DiscPct ?? 0m) * 0.01m; } sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), amt); } } else if (manualDiscUnchecked && lineDiscountFields.DiscountID == null) { sender.SetValueExt(e.Row, sender.GetField(typeof(discPct)), 0m); sender.SetValueExt(e.Row, sender.GetField(typeof(curyDiscAmt)), 0m); } }
public CRCommunicationInbox() : base(new ButtonMenu("markAsRead", Messages.MarkAsRead, String.Empty), new ButtonMenu("markAsUnread", Messages.MarkAsUnread, String.Empty), new ButtonMenu("relate", Messages.LinkTo, String.Empty), new ButtonMenu("archive", Messages.Archive, String.Empty)) { var actionSource = PXAccess.FeatureInstalled <FeaturesSet.customerModule>() ? (PXStringListAttribute) new CREmailActivityMaint.EntityList() : new CREmailActivityMaint.EntityListSimple(); Create.SetMenu(actionSource.ValueLabelDic.Select(entity => new ButtonMenu(entity.Key, PXMessages.LocalizeFormatNoPrefix(entity.Value), null) { OnClosingPopup = PXSpecialButtonType.Cancel }).ToArray()); }