private static void AddUnpaidInboundInvoices(Payouts payoutList, int organizationId) { InboundInvoices invoices = InboundInvoices.ForOrganization(Organization.PPSE); foreach (InboundInvoice invoice in invoices) { if (invoice.Attested) { BasicPayout basicPayout = new BasicPayout(0, organizationId, string.Empty, invoice.PayToAccount, invoice.Ocr.Length > 0? "OCR " + invoice.Ocr : "Ref# " + invoice.InvoiceReference, (Int64)(invoice.Amount * 100), invoice.DueDate, false, DateTime.Now, 0); Payout payout = Payout.FromBasic(basicPayout); payout.DependentInvoices.Add(invoice); payoutList.Add(payout); } } }
private static void AddUnpaidInboundInvoices(Payouts payoutList, Organization organization) { InboundInvoices invoices = InboundInvoices.ForOrganization(organization); foreach (InboundInvoice invoice in invoices) { if (invoice.Attested) { BasicPayout basicPayout = new BasicPayout(0, organization.Identity, string.Empty, invoice.PayToAccount, invoice.Ocr.Length > 0 ? invoice.Ocr : invoice.InvoiceReference, // prefer OCR (automatic) over Reference (manual) (Int64)(invoice.Amount * 100), invoice.DueDate, false, DateTime.Now, 0); Payout payout = Payout.FromBasic(basicPayout); payout.DependentInvoices.Add(invoice); payoutList.Add(payout); } } }
public static Dictionary <int, Int64> GetBudgetAttestationSpaceAdjustments(Organization organization) { // This function returns a dictionary for the cents that are either accounted for but not attested, // or attested but accounted for, to be used to understand how much is really left in budget // Positive adjustment means more [cost] budget available, negative less [cost] budget available if (_organizationBudgetAttestationSpaceLookup.ContainsKey(organization.Identity)) { return(_organizationBudgetAttestationSpaceLookup [organization.Identity]); } // TODO: This is expensive research, we should cache this result and clear cache on any attestation or create op Dictionary <int, Int64> result = new Dictionary <int, long>(); // Cash advances are accounted for when paid out. Make sure they count toward the budget when attested. CashAdvances advances = CashAdvances.ForOrganization(organization); foreach (CashAdvance advance in advances) { if (!result.ContainsKey(advance.BudgetId)) { result[advance.BudgetId] = 0; } if (advance.Attested) { result[advance.BudgetId] -= advance.AmountCents; } } // Expense claims, Inbound invoices, and Salaries are accounted for when filed. Make sure they DON'T // count toward the budget while they are NOT attested. ExpenseClaims claims = ExpenseClaims.ForOrganization(organization); // gets all open claims foreach (ExpenseClaim claim in claims) { if (!result.ContainsKey(claim.BudgetId)) { result[claim.BudgetId] = 0; } if (!claim.Attested) { result[claim.BudgetId] += claim.AmountCents; } } InboundInvoices invoices = InboundInvoices.ForOrganization(organization); foreach (InboundInvoice invoice in invoices) { if (!result.ContainsKey(invoice.BudgetId)) { result[invoice.BudgetId] = 0; } if (!invoice.Attested) { result[invoice.BudgetId] += invoice.AmountCents; } } Salaries salaries = Salaries.ForOrganization(organization); foreach (Salary salary in salaries) { if (!result.ContainsKey(salary.PayrollItem.BudgetId)) { result[salary.PayrollItem.BudgetId] = 0; } if (!salary.Attested) { result[salary.PayrollItem.BudgetId] += (salary.GrossSalaryCents + salary.AdditiveTaxCents); } } _organizationBudgetAttestationSpaceLookup[organization.Identity] = result; return(result); }