protected virtual IEnumerable documentList() { foreach (ARInvoiceExt doc in PXSelect <ARInvoiceExt> .Select(this)) { bool hasUnreleasedDocument = false; foreach (PXResult <ARRetainageInvoice, ARTran> res in PXSelectJoin <ARRetainageInvoice, LeftJoin <ARTran, On <ARRetainageInvoice.paymentsByLinesAllowed, Equal <True>, And <ARTran.tranType, Equal <ARRetainageInvoice.docType>, And <ARTran.refNbr, Equal <ARRetainageInvoice.refNbr>, And <ARTran.origLineNbr, Equal <Required <ARTran.origLineNbr> > > > > > >, Where <ARRetainageInvoice.isRetainageDocument, Equal <True>, And <ARRetainageInvoice.origDocType, Equal <Required <ARInvoice.docType> >, And <ARRetainageInvoice.origRefNbr, Equal <Required <ARInvoice.refNbr> >, And <ARRetainageInvoice.released, NotEqual <True> > > > > > .SelectSingleBound(this, null, doc.ARTranLineNbr, doc.DocType, doc.RefNbr)) { ARRetainageInvoice invoice = res; ARTran tran = res; if (invoice.PaymentsByLinesAllowed != true || tran.LineNbr != null) { hasUnreleasedDocument = true; } } if (!hasUnreleasedDocument) { ARRetainageFilter filter = Filter.Current; bool hasProjectTransaction = true; if (doc.PaymentsByLinesAllowed != true && (filter.ProjectTaskID != null || filter.AccountGroupID != null || filter.CostCodeID != null || filter.InventoryID != null)) { ARTran projectTran = SearchProjectTransaction(doc); hasProjectTransaction = projectTran != null; } if (hasProjectTransaction) { yield return(doc); } } } }
protected virtual void ARRetainageFilter_RefNbr_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { ARRetainageFilter filter = e.Row as ARRetainageFilter; if (filter == null) { return; } var document = PXSelectorAttribute.Select <ARRetainageFilter.refNbr>(sender, filter, e.NewValue); if (document is null) { e.NewValue = null; e.Cancel = true; } }
protected virtual void ARRetainageFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { ARRetainageFilter filter = e.Row as ARRetainageFilter; if (filter == null) { return; } bool isAutoRelease = ARSetup.Current.RetainageInvoicesAutoRelease == true; DocumentList.SetProcessDelegate <ARInvoiceEntry>( delegate(ARInvoiceEntry graph, ARInvoiceExt item) { ReleaseRetainage(graph, item, filter, isAutoRelease); } ); }
private ARTran SearchProjectTransaction(ARInvoiceExt doc) { ARRetainageFilter filter = Filter.Current; List <object> parameters = new List <object>(); var selectProjectTransaction = new PXSelectJoin <ARTran, LeftJoin <Account, On <Account.accountID, Equal <ARTran.accountID> > >, Where <ARTran.tranType, Equal <Required <ARTran.tranType> >, And <ARTran.refNbr, Equal <Required <ARTran.refNbr> > > > >(this); parameters.Add(doc.DocType); parameters.Add(doc.RefNbr); if (filter.ProjectTaskID != null) { selectProjectTransaction.WhereAnd <Where <ARTran.taskID, Equal <Required <ARTran.taskID> > > >(); parameters.Add(filter.ProjectTaskID); } if (filter.AccountGroupID != null) { selectProjectTransaction.WhereAnd <Where <Account.accountGroupID, Equal <Required <Account.accountGroupID> > > >(); parameters.Add(filter.AccountGroupID); } if (filter.CostCodeID != null) { selectProjectTransaction.WhereAnd <Where <ARTran.costCodeID, Equal <Required <ARTran.costCodeID> > > >(); parameters.Add(filter.CostCodeID); } if (filter.InventoryID != null) { selectProjectTransaction.WhereAnd <Where <ARTran.inventoryID, Equal <Required <ARTran.inventoryID> > > >(); parameters.Add(filter.InventoryID); } return(selectProjectTransaction.SelectSingle(parameters.ToArray())); }
protected virtual void ARRetainageFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { ARRetainageFilter filter = e.Row as ARRetainageFilter; if (filter == null) { return; } bool isAutoRelease = ARSetup.Current.RetainageInvoicesAutoRelease == true; DocumentList.SetProcessDelegate(delegate(List <ARInvoiceExt> list) { ARInvoiceEntry graph = CreateInstance <ARInvoiceEntry>(); ARInvoiceEntryRetainage retainageExt = graph.GetExtension <ARInvoiceEntryRetainage>(); RetainageOptions retainageOptions = new RetainageOptions(); retainageOptions.DocDate = filter.DocDate; retainageOptions.MasterFinPeriodID = FinPeriodIDAttribute.CalcMasterPeriodID <ARRetainageFilter.finPeriodID>(graph.Caches[typeof(ARRetainageFilter)], filter); retainageExt.ReleaseRetainageProc(list, retainageOptions, isAutoRelease); }); }
public static void ReleaseRetainage(ARInvoiceEntry graph, ARInvoiceExt invoice, ARRetainageFilter filter, bool isAutoRelease) { graph.Clear(PXClearOption.ClearAll); PXUIFieldAttribute.SetError(graph.Document.Cache, null, null, null); RetainageOptions retainageOptions = new RetainageOptions(); retainageOptions.DocDate = filter.DocDate; retainageOptions.FinPeriodID = filter.FinPeriodID; retainageOptions.CuryRetainageAmt = invoice.CuryRetainageReleasedAmt; ARInvoiceEntryRetainage retainageExt = graph.GetExtension <ARInvoiceEntryRetainage>(); ARInvoice retainageInvoice = retainageExt.ReleaseRetainageProc(invoice, retainageOptions, isAutoRelease); graph.Save.Press(); if (isAutoRelease) { List <ARRegister> toRelease = new List <ARRegister>() { retainageInvoice }; using (new PXTimeStampScope(null)) { ARDocumentRelease.ReleaseDoc(toRelease, true); } } }