public virtual decimal?GetVendorPreparedBalance(APAdjust adjustment) { FinDocumentExtKey actualDocLineKey = InvoiceDataProvider.GetSourceEntityKeyByRetainage(Graph, adjustment.AdjdDocType, adjustment.AdjdRefNbr, adjustment.AdjdLineNbr); decimal?fullAmount; if (adjustment.AdjdLineNbr == 0) { APInvoice bill = InvoiceDataProvider.GetInvoice(Graph, actualDocLineKey.Type, actualDocLineKey.RefNbr); fullAmount = bill.CuryOrigDocAmt + bill.CuryRetainageTotal; } else { APTran tran = TransactionDataProvider.GetTransaction(Graph, actualDocLineKey.Type, actualDocLineKey.RefNbr, actualDocLineKey.LineNbr); fullAmount = tran.CuryOrigTranAmt + tran.CuryRetainageAmt; } var totalJointAmountOwed = JointPayeeDataProvider.GetJointPayees(Graph, actualDocLineKey.RefNbr, actualDocLineKey.LineNbr) .Sum(jp => jp.JointAmountOwed.GetValueOrDefault()); var totalVendorPaymentAmount = GetTotalVendorPaymentAmount(adjustment, actualDocLineKey.RefNbr, actualDocLineKey.LineNbr); var currentVendorPaymentAmount = GetVendorPaymentAmount(adjustment); var reversedRetainageAmount = GetReversedRetainageAmount(actualDocLineKey.RefNbr, actualDocLineKey.LineNbr); return(fullAmount + reversedRetainageAmount - totalJointAmountOwed - (totalVendorPaymentAmount - currentVendorPaymentAmount)); }
public static FinDocumentExtKey GetSourceEntityKeyByRetainage(PXGraph graph, string docType, string refNbr, int?lineNbr) { FinDocumentExtKey key = new FinDocumentExtKey(); APInvoice bill = GetInvoice(graph, docType, refNbr); if (bill.IsRetainageDocument == true) { key.Type = bill.OrigDocType; key.RefNbr = bill.OrigRefNbr; if (lineNbr != null && lineNbr != 0) { key.LineNbr = TransactionDataProvider.GetTransaction(graph, bill.DocType, bill.RefNbr, lineNbr) .OrigLineNbr; } } else { key.Type = docType; key.RefNbr = refNbr; key.LineNbr = lineNbr; } return(key); }
public static IEnumerable <int?> GetProjectIds(APAdjust adjustment, PXGraph graph) { FinDocumentExtKey actualDocLineKey = InvoiceDataProvider.GetSourceEntityKeyByRetainage(graph, adjustment.AdjdDocType, adjustment.AdjdRefNbr, adjustment.AdjdLineNbr); var transactions = adjustment.AdjdLineNbr == 0 ? TransactionDataProvider.GetTransactions(graph, actualDocLineKey.Type, actualDocLineKey.RefNbr) : TransactionDataProvider.GetTransaction(graph, actualDocLineKey.Type, actualDocLineKey.RefNbr, actualDocLineKey.LineNbr).SingleToList(); return(transactions.Select(tran => tran.ProjectID)); }