protected string PickAddressError <TFieldSource>(IAddressBase address) where TFieldSource : IBqlField { if (typeof(TFieldSource) == typeof(SOOrder.shipAddressID)) { return(PXSelect <SOOrder, Where <SOOrder.shipAddressID, Equal <Required <Address.addressID> > > > .SelectWindowed(Base, 0, 1, ((SOAddress)address).AddressID).First().GetItem <SOOrder>() .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <SOOrder>(), new EntityHelper(Base).GetRowID(e)))); } if (typeof(TFieldSource) == typeof(Vendor.defLocationID)) { return(PXSelectReadonly2 <Vendor, InnerJoin <Location, On <Location.locationID, Equal <Vendor.defLocationID> > >, Where <Location.defAddressID, Equal <Required <Address.addressID> > > > .SelectWindowed(Base, 0, 1, ((Address)address).AddressID).First().GetItem <Vendor>() .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <Vendor>(), new EntityHelper(Base).GetRowID(e)))); } if (typeof(TFieldSource) == typeof(INSite.addressID)) { return(PXSelectReadonly <INSite, Where <INSite.addressID, Equal <Required <Address.addressID> > > > .SelectWindowed(Base, 0, 1, ((Address)address).AddressID).First().GetItem <INSite>() .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <INSite>(), new EntityHelper(Base).GetRowID(e)))); } if (typeof(TFieldSource) == typeof(BAccountR.defAddressID)) { return(PXSelectReadonly <BAccountR, Where <BAccountR.defAddressID, Equal <Required <Address.addressID> > > > .SelectWindowed(Base, 0, 1, ((Address)address).AddressID).First().GetItem <BAccountR>() .With(e => PXMessages.LocalizeFormat(AR.Messages.AvalaraAddressSourceError, EntityHelper.GetFriendlyEntityName <BAccountR>(), new EntityHelper(Base).GetRowID(e)))); } throw new ArgumentOutOfRangeException("Unknown address source used"); }
public virtual void CheckPartiallyReceiptedPOServices(PXCache sender, PXFieldUpdatedEventArgs e, string poOrderType) { POSetup row = (POSetup)e.Row; if (row != null) { PXResultset <POLine> partiallyReceiptedPOServices = PXSelectReadonly2 <POLine, InnerJoin <IN.InventoryItem, On <POLine.FK.InventoryItem> >, Where <POLine.orderType, Equal <Required <POLine.orderType> >, And <POLine.lineType, Equal <POLineType.service>, And <POLine.completed, NotEqual <True>, And <POLine.receivedQty, NotEqual <decimal0> > > > > > .SelectWindowed(this, 0, 1000, poOrderType); if (partiallyReceiptedPOServices.Count > 0) { if (poOrderType == POOrderType.RegularOrder) { if (row.AddServicesFromNormalPOtoPR == true) { PXUIFieldAttribute.SetWarning <POSetup.addServicesFromNormalPOtoPR>(sender, row, Messages.PossibleOverbillingAPNormalPO); } else { PXUIFieldAttribute.SetWarning <POSetup.addServicesFromNormalPOtoPR>(sender, row, Messages.PossibleOverbillingPRNormalPO); } } else { if (row.AddServicesFromDSPOtoPR == true) { PXUIFieldAttribute.SetWarning <POSetup.addServicesFromDSPOtoPR>(sender, row, Messages.PossibleOverbillingAPDSPO); } else { PXUIFieldAttribute.SetWarning <POSetup.addServicesFromDSPOtoPR>(sender, row, Messages.PossibleOverbillingPRDSPO); } } string overbillingMessage = Messages.PossibleOverbillingTraceList + " \n"; int i = 0; foreach (PXResult <POLine, IN.InventoryItem> line in partiallyReceiptedPOServices) { POLine poline = (POLine)line; IN.InventoryItem item = (IN.InventoryItem)line; overbillingMessage += string.Format(Messages.PossibleOverbillingTraceMessage, (poOrderType == POOrderType.RegularOrder ? Messages.RegularOrder : Messages.DropShip), poline.OrderNbr, poline.LineNbr, item.InventoryCD) + "\n"; i++; if (i >= 1000) { break; } } PXTrace.WriteWarning(overbillingMessage); } } }
/// <summary><see cref="InventoryByClassFilter.InventoryID"/> Updated</summary> protected virtual void InventoryByClassFilter_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { var row = (InventoryByClassFilter)e.Row; if (row?.InventoryID != null) { INItemClass current = PXSelectReadonly2 <INItemClass, InnerJoin <InventoryItem, On <InventoryItem.FK.ItemClass> >, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .SelectWindowed(this, 0, 1, row.InventoryID); _allowToSyncTreeCurrentWithPrimaryViewCurrent = true; _forbidToSyncTreeCurrentWithPrimaryViewCurrent = false; _keepInventoryFilter = true; ItemClassFilter.Current = current; } }
protected virtual void GenerateStatement(ARStatementCycle cycle, DateTime statementDate, bool clearExisting) { PXSelectBase <Customer> selectCustomer = new PXSelectJoin <Customer, InnerJoin <CustomerMaster, On <CustomerMaster.bAccountID, Equal <Customer.statementCustomerID> > >, Where <CustomerMaster.statementCycleId, Equal <Required <Customer.statementCycleId> > >, OrderBy <Asc <Customer.statementCustomerID> > >(this); var statementGraph = CreateInstance <StatementCreateBO>(); var family = new List <Customer> { }; foreach (Customer customer in selectCustomer.Select(cycle.StatementCycleId)) { if (family.Any() == false || family.First().StatementCustomerID == customer.StatementCustomerID) { family.Add(customer); } else { GenerateStatementForCustomerFamily(statementGraph, cycle, family, statementDate, clearExisting); family = new List <Customer> { customer }; } } if (family.Any()) { GenerateStatementForCustomerFamily(statementGraph, cycle, family, statementDate, clearExisting); } Customer leftToProcess = PXSelectReadonly2 <Customer, InnerJoin <CustomerMaster, On <CustomerMaster.bAccountID, Equal <Customer.statementCustomerID> > >, Where <CustomerMaster.statementCycleId, Equal <Required <Customer.statementCycleId> >, And <Where <Customer.statementLastDate, IsNull, Or <Customer.statementLastDate, Less <Required <Customer.statementLastDate> > > > > > > .SelectWindowed(this, 0, 1, cycle.StatementCycleId, statementDate); if (leftToProcess == null) { cycle.LastStmtDate = statementDate; this.CyclesList.Update(cycle); this.Actions.PressSave(); } }
public override void Persist() { using (var ts = new PXTransactionScope()) { foreach (INSite record in site.Cache.Deleted) { PXDatabase.Delete <INSiteStatus>( new PXDataFieldRestrict <INSiteStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ), new PXDataFieldRestrict <INSiteStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ), new PXDataFieldRestrict <INSiteStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ)); PXDatabase.Delete <INLocationStatus>( new PXDataFieldRestrict <INLocationStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ), new PXDataFieldRestrict <INLocationStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ), new PXDataFieldRestrict <INLocationStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ)); PXDatabase.Delete <INLotSerialStatus>( new PXDataFieldRestrict <INLotSerialStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ), new PXDataFieldRestrict <INLotSerialStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ), new PXDataFieldRestrict <INLotSerialStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ)); InventoryItem item = PXSelectReadonly2 <InventoryItem, InnerJoin <INSiteStatus, On <INSiteStatus.FK.InventoryItem> >, Where <INSiteStatus.siteID, Equal <Required <INSiteStatus.siteID> > > > .SelectWindowed(this, 0, 1, record.SiteID); if (item?.InventoryCD != null) { throw new PXRowPersistingException(typeof(INSite.siteCD).Name, record, Messages.SiteUsageDeleted, item.InventoryCD.TrimEnd()); } } ts.Complete(); } base.Persist(); location.Cache.Clear(); }
public static PXResultset <ARInvoice> GetCustDocs(PX.Objects.AR.ARPaymentEntry.LoadOptions opts, ARPayment currentARPayment, ARSetup currentARSetup, PXGraph graph) { PXSelectBase <ARInvoice> cmd = new PXSelectReadonly2 <ARInvoice, InnerJoin <Customer, On <Customer.bAccountID, Equal <ARInvoice.customerID> >, LeftJoin <ARAdjust, On <ARAdjust.adjdDocType, Equal <ARInvoice.docType>, And <ARAdjust.adjdRefNbr, Equal <ARInvoice.refNbr>, And <ARAdjust.released, Equal <boolFalse>, And <ARAdjust.voided, Equal <boolFalse>, And <Where <ARAdjust.adjgDocType, NotEqual <Required <ARPayment.docType> >, Or <ARAdjust.adjgRefNbr, NotEqual <Required <ARPayment.refNbr> > > > > > > > >, LeftJoin <ARAdjust2, On <ARAdjust2.adjgDocType, Equal <ARInvoice.docType>, And <ARAdjust2.adjgRefNbr, Equal <ARInvoice.refNbr>, And <ARAdjust2.released, Equal <boolFalse>, And <ARAdjust2.voided, Equal <boolFalse> > > > > > > >, Where <ARInvoice.docType, NotEqual <Required <ARPayment.docType> >, And <ARInvoice.released, Equal <boolTrue>, And <ARInvoice.openDoc, Equal <boolTrue>, And <ARAdjust.adjgRefNbr, IsNull, And <ARAdjust2.adjgRefNbr, IsNull> > > > >, OrderBy <Asc <ARInvoice.dueDate, Asc <ARInvoice.refNbr> > > >(graph); if (opts != null) { if (opts.FromDate != null) { cmd.WhereAnd <Where <ARInvoice.docDate, GreaterEqual <Required <PX.Objects.AR.ARPaymentEntry.LoadOptions.fromDate> > > >(); } if (opts.TillDate != null) { cmd.WhereAnd <Where <ARInvoice.docDate, LessEqual <Required <PX.Objects.AR.ARPaymentEntry.LoadOptions.tillDate> > > >(); } if (!string.IsNullOrEmpty(opts.StartRefNbr)) { cmd.WhereAnd <Where <ARInvoice.refNbr, GreaterEqual <Required <PX.Objects.AR.ARPaymentEntry.LoadOptions.startRefNbr> > > >(); } if (!string.IsNullOrEmpty(opts.EndRefNbr)) { cmd.WhereAnd <Where <ARInvoice.refNbr, LessEqual <Required <PX.Objects.AR.ARPaymentEntry.LoadOptions.endRefNbr> > > >(); } } var loadChildDocs = opts == null ? PX.Objects.AR.ARPaymentEntry.LoadOptions.loadChildDocuments.None : opts.LoadChildDocuments; switch (loadChildDocs) { case PX.Objects.AR.ARPaymentEntry.LoadOptions.loadChildDocuments.IncludeCRM: cmd.WhereAnd <Where <ARInvoice.customerID, Equal <Required <ARRegister.customerID> >, Or <Customer.consolidatingBAccountID, Equal <Required <ARRegister.customerID> > > > >(); break; case PX.Objects.AR.ARPaymentEntry.LoadOptions.loadChildDocuments.ExcludeCRM: cmd.WhereAnd <Where <ARInvoice.customerID, Equal <Required <ARRegister.customerID> >, Or <Customer.consolidatingBAccountID, Equal <Required <ARRegister.customerID> >, And <ARInvoice.docType, NotEqual <ARDocType.creditMemo> > > > >(); break; default: cmd.WhereAnd <Where <ARInvoice.customerID, Equal <Required <ARRegister.customerID> > > >(); break; } switch (currentARPayment.DocType) { case ARDocType.Payment: cmd.WhereAnd <Where <ARInvoice.docType, Equal <ARDocType.invoice>, Or <ARInvoice.docType, Equal <ARDocType.debitMemo>, Or <ARInvoice.docType, Equal <ARDocType.creditMemo>, Or <ARInvoice.docType, Equal <ARDocType.finCharge> > > > > >(); break; case ARDocType.Prepayment: case ARDocType.CreditMemo: cmd.WhereAnd <Where <ARInvoice.docType, Equal <ARDocType.invoice>, Or <ARInvoice.docType, Equal <ARDocType.debitMemo>, Or <ARInvoice.docType, Equal <ARDocType.finCharge> > > > >(); break; default: cmd.WhereAnd <Where <True, Equal <False> > >(); break; } List <object> parametrs = new List <object>(); parametrs.Add(currentARPayment.DocType); parametrs.Add(currentARPayment.RefNbr); parametrs.Add(currentARPayment.DocType); if (opts != null) { if (opts.FromDate != null) { parametrs.Add(opts.FromDate); } if (opts.TillDate != null) { parametrs.Add(opts.TillDate); } if (!string.IsNullOrEmpty(opts.StartRefNbr)) { parametrs.Add(opts.StartRefNbr); } if (!string.IsNullOrEmpty(opts.EndRefNbr)) { parametrs.Add(opts.EndRefNbr); } } switch (loadChildDocs) { case PX.Objects.AR.ARPaymentEntry.LoadOptions.loadChildDocuments.IncludeCRM: case PX.Objects.AR.ARPaymentEntry.LoadOptions.loadChildDocuments.ExcludeCRM: parametrs.Add(currentARPayment.CustomerID); parametrs.Add(currentARPayment.CustomerID); break; default: parametrs.Add(currentARPayment.CustomerID); break; } PXResultset <ARInvoice> custdocs = opts == null || opts.MaxDocs == null?cmd.Select(parametrs.ToArray()) : cmd.SelectWindowed(0, (int)opts.MaxDocs, parametrs.ToArray()); custdocs.Sort(new Comparison <PXResult <ARInvoice> >(delegate(PXResult <ARInvoice> a, PXResult <ARInvoice> b) { int aSortOrder = 0; int bSortOrder = 0; if (currentARPayment.CuryOrigDocAmt > 0m) { aSortOrder += (((ARInvoice)a).DocType == ARDocType.CreditMemo ? 0 : 1000); bSortOrder += (((ARInvoice)b).DocType == ARDocType.CreditMemo ? 0 : 1000); } else { aSortOrder += (((ARInvoice)a).DocType == ARDocType.CreditMemo ? 1000 : 0); bSortOrder += (((ARInvoice)b).DocType == ARDocType.CreditMemo ? 1000 : 0); } if (currentARSetup.FinChargeFirst == true) { aSortOrder += (((ARInvoice)a).DocType == ARDocType.FinCharge ? 0 : 100); bSortOrder += (((ARInvoice)b).DocType == ARDocType.FinCharge ? 0 : 100); } DateTime aDueDate = ((ARInvoice)a).DueDate ?? DateTime.MinValue; DateTime bDueDate = ((ARInvoice)b).DueDate ?? DateTime.MinValue; if (opts == null) { aSortOrder += (1 + aDueDate.CompareTo(bDueDate)) / 2; bSortOrder += (1 - aDueDate.CompareTo(bDueDate)) / 2; } else { object aObj; object bObj; switch (opts.OrderBy) { case PX.Objects.AR.ARPaymentEntry.LoadOptions.orderBy.RefNbr: aObj = ((ARInvoice)a).RefNbr; bObj = ((ARInvoice)b).RefNbr; aSortOrder += (1 + ((IComparable)aObj).CompareTo(bObj)) / 2; bSortOrder += (1 - ((IComparable)aObj).CompareTo(bObj)) / 2; break; case PX.Objects.AR.ARPaymentEntry.LoadOptions.orderBy.DocDateRefNbr: aObj = ((ARInvoice)a).DocDate; bObj = ((ARInvoice)b).DocDate; aSortOrder += (1 + ((IComparable)aObj).CompareTo(bObj)) / 2 * 10; bSortOrder += (1 - ((IComparable)aObj).CompareTo(bObj)) / 2 * 10; aObj = ((ARInvoice)a).RefNbr; bObj = ((ARInvoice)b).RefNbr; aSortOrder += (1 + ((IComparable)aObj).CompareTo(bObj)) / 2; bSortOrder += (1 - ((IComparable)aObj).CompareTo(bObj)) / 2; break; default: aSortOrder += (1 + aDueDate.CompareTo(bDueDate)) / 2 * 10; bSortOrder += (1 - aDueDate.CompareTo(bDueDate)) / 2 * 10; aObj = ((ARInvoice)a).RefNbr; bObj = ((ARInvoice)b).RefNbr; aSortOrder += (1 + ((IComparable)aObj).CompareTo(bObj)) / 2; bSortOrder += (1 - ((IComparable)aObj).CompareTo(bObj)) / 2; break; } } return(aSortOrder.CompareTo(bSortOrder)); })); return(custdocs); }