public ARBatchEntry() { CASetup caSetup = CASetup.Current; ARSetup arSetup = ARSetup.Current; RowUpdated.AddHandler <CABatch>(ParentFieldUpdated); }
public Closing() { GLSetup setup = GLSetup.Current; APSetup apSetup = APSetup.Select(); ARSetup arSetup = ARSetup.Select(); INSetup inSetup = INSetup.Select(); CASetup caSetup = CASetup.Select(); FASetup faSetup = FASetup.Select(); PRSetup prSetup = PRSetup.Select(); PXCache periodCache = Caches[typeof(FinPeriod)]; PXUIFieldAttribute.SetEnabled <FinPeriod.finPeriodID>(periodCache, null, false); PXUIFieldAttribute.SetEnabled <FinPeriod.descr>(periodCache, null, false); PXUIFieldAttribute.SetVisible <FinPeriod.aPClosed>(periodCache, null, apSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.aRClosed>(periodCache, null, arSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.iNClosed>(periodCache, null, inSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.cAClosed>(periodCache, null, caSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.fAClosed>(periodCache, null, faSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.pRClosed>(periodCache, null, prSetup != null); Caches[typeof(FinPeriod)].AllowInsert = false; Caches[typeof(FinPeriod)].AllowDelete = false; if (this.GetType() != typeof(Closing)) { ShowDocuments.SetCaption(PXMessages.LocalizeNoPrefix(GL.Messages.ShowDocumentsNonGL)); } }
private void RedistributeDeduction(IRUTROTable document, RUTROT rutrot, ARSetup setup, CurrencyInfo curyInfo) { if (document == null || document.IsRUTROTDeductible != true || rutrot == null) { return; } var persons = RRDistribution.Select().ToList(); int count = persons.Count; if (rutrot.AutoDistribution == true && count != 0) { decimal totalFromTrans = rutrot.CuryTotalAmt ?? 0.0m; var distributor = new DistributionRounding(setup, PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>()) { PreventOverflow = true, CuryPlaces = curyInfo?.CuryPrecision ?? 0 }; var amts = distributor.DistributeEven(totalFromTrans, count); foreach (var p in persons.Zip(amts, (p, a) => new { DistributionItem = p, Amount = a })) { var item = (RUTROTDistribution)RRDistribution.Cache.CreateCopy((RUTROTDistribution)p.DistributionItem); if (item.CuryAmount != p.Amount) { item.CuryAmount = p.Amount; RRDistribution.Cache.Update(item); } } } RRDistribution.View.RequestRefresh(); }
private void RedistributeDeduction(IRUTROTable document, RUTROT rutrot, ARSetup setup, CurrencyInfo curyInfo) { if (document == null || document.IsRUTROTDeductible != true || rutrot == null) { return; } var persons = RRDistribution.Select().ToList(); int count = persons.Count; if (rutrot.AutoDistribution == true && count != 0) { decimal totalFromTrans = rutrot.CuryTotalAmt ?? 0.0m; DistributionRounding distributor; PXCache currencyInfoCache = Base.Caches[typeof(CurrencyInfo)]; Currency currency = null; if (currencyInfoCache.Current != null) { currency = PXSelect <Currency, Where <Currency.curyID, Equal <Required <CurrencyInfo.curyID> > > > .Select(Base, (currencyInfoCache.Current as CurrencyInfo).CuryID); } if (currency?.UseARPreferencesSettings == false) { distributor = new DistributionRounding(currency, PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>()) { PreventOverflow = true, CuryPlaces = curyInfo?.CuryPrecision ?? 0 }; } else { distributor = new DistributionRounding(setup, PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>()) { PreventOverflow = true, CuryPlaces = curyInfo?.CuryPrecision ?? 0 }; } var amts = distributor.DistributeEven(totalFromTrans, count); foreach (var p in persons.Zip(amts, (p, a) => new { DistributionItem = p, Amount = a })) { var item = (RUTROTDistribution)RRDistribution.Cache.CreateCopy((RUTROTDistribution)p.DistributionItem); if (item.CuryAmount != p.Amount) { item.CuryAmount = p.Amount; RRDistribution.Cache.Update(item); } } } RRDistribution.View.RequestRefresh(); }
public void BackToMain() { foreach (var obj in FindObjectsOfType <DontDestroyOnLoad>()) { obj.DontDestroyOnLoadEnabled = false; } ARSetup.Reset(); CameraCache.Reset(); SceneManager.LoadScene("0_MainMenu"); }
public ARProcessPayment() { ARSetup setup = ARSetup.Current; PXUIFieldAttribute.SetEnabled(ARPaymentList.Cache, null, false); PXUIFieldAttribute.SetEnabled <ARPayment.selected>(ARPaymentList.Cache, null, true); PXUIFieldAttribute.SetEnabled <ARPayment.extRefNbr>(ARPaymentList.Cache, null, true); ARPaymentList.SetSelected <ARPayment.selected>(); PXUIFieldAttribute.SetDisplayName <ARPayment.customerID>(ARPaymentList.Cache, "Customer ID"); }
protected override bool IsRetainedTaxes(PXGraph graph) { //if (forceRetainedTaxesOff) // return false; PXCache cache = graph.Caches[typeof(ARSetup)]; ARSetup arsetup = cache.Current as ARSetup; return (PXAccess.FeatureInstalled <FeaturesSet.retainage>() && arsetup?.RetainTaxes == true); }
public ARProcessTwilioNotifications() { ARSetup setup = arsetup.Current; PXUIFieldAttribute.SetEnabled(ARDocumentList.Cache, null, false); PXUIFieldAttribute.SetEnabled <ARInvoice.selected>(ARDocumentList.Cache, null, true); ARDocumentList.Cache.AllowInsert = false; ARDocumentList.Cache.AllowDelete = false; ARDocumentList.SetSelected <ARInvoice.selected>(); ARDocumentList.SetProcessCaption(CR.Messages.Send); ARDocumentList.SetProcessAllCaption(CR.Messages.SendAll); }
protected override bool?GetCreditCheckError(PXCache sender, object Row) { if (sender.Graph.GetType() == typeof(SO.SOInvoiceEntry) || sender.Graph.GetType().BaseType == typeof(SO.SOInvoiceEntry)) { PX.Objects.SO.SOSetup soSetup = PXSetup <PX.Objects.SO.SOSetup> .Select(sender.Graph); return(soSetup?.CreditCheckError); } else { ARSetup arSetup = PXSetup <ARSetup> .Select(sender.Graph); return(arSetup?.CreditCheckError); } }
public Closing() { GLSetup setup = GLSetup.Current; APSetup apSetup = APSetup.Select(); ARSetup arSetup = ARSetup.Select(); INSetup inSetup = INSetup.Select(); CASetup caSetup = CASetup.Select(); FASetup faSetup = FASetup.Select(); PXCache periodCache = Caches[typeof(FinPeriod)]; PXUIFieldAttribute.SetEnabled <FinPeriod.finPeriodID>(periodCache, null, false); PXUIFieldAttribute.SetEnabled <FinPeriod.descr>(periodCache, null, false); PXUIFieldAttribute.SetVisible <FinPeriod.aPClosed>(periodCache, null, apSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.aRClosed>(periodCache, null, arSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.iNClosed>(periodCache, null, inSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.cAClosed>(periodCache, null, caSetup != null); PXUIFieldAttribute.SetVisible <FinPeriod.fAClosed>(periodCache, null, faSetup != null); Caches[typeof(FinPeriod)].AllowInsert = false; Caches[typeof(FinPeriod)].AllowDelete = false; }
public static string GetLineDiscountTarget(PXCache sender, LineEntitiesFields efields) { string LineDiscountTarget = LineDiscountTargetType.ExtendedPrice; if (efields != null && efields.VendorID != null) { AP.Vendor vendor = PXSelect <AP.Vendor, Where <AP.Vendor.bAccountID, Equal <Required <AP.Vendor.bAccountID> > > > .SelectSingleBound(sender.Graph, null, efields.VendorID); if (vendor != null) { LineDiscountTarget = vendor.LineDiscountTarget; } } else { ARSetup arsetup = PXSelect <ARSetup> .Select(sender.Graph); if (arsetup != null) { LineDiscountTarget = arsetup.LineDiscountTarget; } } return(LineDiscountTarget); }
public DistributionRounding(ARSetup setup, bool roundingEnabled) : this(roundingEnabled ? setup.InvoiceRounding : RoundingType.Currency, roundingEnabled ? setup.InvoicePrecision : 0.0m) { }
public virtual IEnumerable close(PXAdapter adapter) { APSetup apSetup = APSetup.Select(); ARSetup arSetup = ARSetup.Select(); INSetup inSetup = INSetup.Select(); CASetup caSetup = CASetup.Select(); FASetup faSetup = FASetup.Select(); List <FinPeriod> list = new List <FinPeriod>(); bool YearClosed = true; foreach (FinPeriod period in adapter.Get()) { if (period.Selected == true) { if (period.Active != true) { throw new FiscalPeriodInactiveException(period.FinPeriodID); } if (Accessinfo.ScreenID == "GL.50.30.00") { if (apSetup != null && period.APClosed != true) { throw new PXException(Messages.PeriodOpenInAPModule); } if (arSetup != null && period.ARClosed != true) { throw new PXException(Messages.PeriodOpenInARModule); } if (caSetup != null && period.CAClosed != true) { throw new PXException(Messages.PeriodOpenInCAModule); } if (inSetup != null && PXAccess.FeatureInstalled <CS.FeaturesSet.distributionModule>() && period.INClosed != true) { throw new PXException(Messages.PeriodOpenInINModule); } if (faSetup != null && PXAccess.FeatureInstalled <CS.FeaturesSet.fixedAsset>() && period.FAClosed != true) { throw new PXException(Messages.PeriodOpenInFAModule); } } list.Add(period); } else { YearClosed = false; } } if (YearClosed) { if ((FinPeriod)NextFiscalYear.Select(list[list.Count - 1].FinYear) == null) { throw new PXException(Messages.NoPeriodsForNextYear); } } if (list.Count > 0) { StartClosePeriod(list); } return(adapter.Get()); }
private void CreateSingleSchedule <T>(T originalDocument, Amount lineTotal, int?DefScheduleID, bool isDraft, DRScheduleParameters scheduleParameters) where T : ARRegister { ARSetup arSetup = PXSelect <ARSetup> .Select(this); DRSchedule existingSchedule = PXSelect < DRSchedule, Where < DRSchedule.module, Equal <BatchModule.moduleAR>, And <DRSchedule.docType, Equal <Required <ARRegister.docType> >, And <DRSchedule.refNbr, Equal <Required <ARRegister.refNbr> > > > > > .SelectSingleBound(this, null, originalDocument.DocType, originalDocument.RefNbr, 1); if (existingSchedule?.LineNbr != null) { throw new PXException(Messages.CantCompleteBecauseASC606FeatureIsEnabled); } if (DefScheduleID == null) { Location location = PXSelect <Location, Where <Location.locationID, Equal <Required <DRSchedule.bAccountLocID> > > > .SelectSingleBound(this, null, scheduleParameters.BAccountLocID); CurrencyInfo currencyInfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <DRSchedule.curyInfoID> > > > .SelectSingleBound(this, null, scheduleParameters.CuryInfoID); SingleScheduleCreator scheduleCreator = new SingleScheduleCreator( this, new ARSubaccountProvider(this), this, this, this, this, this, FinPeriodRepository, roundingFunction: x => PXDBCurrencyAttribute.Round(Schedule.Cache, Schedule.Current, x, CMPrecision.TRANCURY), branchID: originalDocument.BranchID, isDraft: isDraft, location: location, currencyInfo: currencyInfo); if (existingSchedule == null) { scheduleCreator.CreateOriginalSchedule( scheduleParameters, lineTotal); } else { scheduleCreator.ReevaluateSchedule( existingSchedule, scheduleParameters, lineTotal, attachedToOriginalSchedule: false); } } else { if (originalDocument.DocType == ARDocType.CreditMemo || originalDocument.DocType == ARDocType.DebitMemo) { bool accountForPostedTransactions = originalDocument.DocType == ARDocType.CreditMemo; if (existingSchedule == null) { CreateRelatedSingleSchedule(scheduleParameters, DefScheduleID, lineTotal, isDraft, accountForPostedTransactions); } else { Location location = PXSelect <Location, Where <Location.locationID, Equal <Required <DRSchedule.bAccountLocID> > > > .SelectSingleBound(this, null, scheduleParameters.BAccountLocID); CurrencyInfo currencyInfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <DRSchedule.curyInfoID> > > > .SelectSingleBound(this, null, scheduleParameters.CuryInfoID); var scheduleCreator = new SingleScheduleCreator( this, new ARSubaccountProvider(this), this, this, this, this, this, FinPeriodRepository, roundingFunction: x => PXCurrencyAttribute.BaseRound(this, x), branchID: originalDocument.BranchID, isDraft: !accountForPostedTransactions, location: location, currencyInfo: currencyInfo); scheduleCreator.ReevaluateSchedule( existingSchedule, scheduleParameters, lineTotal, attachedToOriginalSchedule: true); } } } }
protected virtual bool?IsMigrationMode(PXCache sender) { ARSetup arsetup = PXSetup <ARSetup> .Select(sender.Graph); return(arsetup?.MigrationMode); }
protected virtual bool?GetCreditCheckError(PXCache sender, object Row) { ARSetup arsetup = PXSetup <ARSetup> .Select(sender.Graph); return(arsetup?.CreditCheckError); }
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); }