private void PopulateClaims(AttestableItems items) { ExpenseClaims allClaims = ExpenseClaims.FromOrganization(Organization.PPSE); ExpenseClaims unattestedClaims = new ExpenseClaims(); // LINQ would be nice here. "Where Attested=0". foreach (ExpenseClaim claim in allClaims) { if (!claim.Attested && claim.Open) { if (attestationRights.ContainsKey(claim.BudgetId)) { unattestedClaims.Add(claim); } } } unattestedClaims.Sort(SortGridClaims); foreach (ExpenseClaim claim in unattestedClaims) { AddAttestableItem(items, claim); } }
private void PopulateGrid() { string personIdString = Request.QueryString["PersonId"]; string organizationIdString = Request.QueryString["OrganizationId"]; Person person = Person.FromIdentity(Int32.Parse(personIdString)); Organization organization = Organization.FromIdentity(Int32.Parse(organizationIdString)); this.LabelOrganization.Text = organization.Name; this.LabelDebtor.Text = person.Canonical; ExpenseClaims allClaims = ExpenseClaims.FromClaimingPersonAndOrganization(person, organization); // again, this needs a "get open only" ExpenseClaims gridClaims = new ExpenseClaims(); foreach (ExpenseClaim claim in allClaims) { // If ready for payout, add to list. if (claim.Open) { if (claim.Attested && claim.Validated && !claim.Repaid) { gridClaims.Add(claim); } } } // Now, we have grouped all ready but unsettled expenses per person. Let's add only those with a positive debt to the final list. gridClaims.Sort(SortGridItems); this.GridDebts.DataSource = gridClaims; }
public SampleData() { var designService = new DesignExpenseClaimService(); foreach (var item in designService.GetExpenseClaimsForStatus("Open").Result) { ExpenseClaims.Add(item); } foreach (var item in designService.GetMostRecentExpenseClaimsByStatus().Result) { GroupedExpenseClaims.Add(item); } }
private void LoadDependencies() { DependentExpenseClaims = new ExpenseClaims(); DependentInvoices = new InboundInvoices(); DependentSalariesNet = new Salaries(); DependentSalariesTax = new Salaries(); DependentCashAdvancesPayout = new CashAdvances(); DependentCashAdvancesPayback = new CashAdvances(); BasicFinancialDependency[] dependencies = SwarmDb.GetDatabaseForReading().GetPayoutDependencies(this.Identity); foreach (BasicFinancialDependency dependency in dependencies) { switch (dependency.DependencyType) { case FinancialDependencyType.ExpenseClaim: DependentExpenseClaims.Add(ExpenseClaim.FromIdentity(dependency.ForeignId)); break; case FinancialDependencyType.InboundInvoice: DependentInvoices.Add(InboundInvoice.FromIdentity(dependency.ForeignId)); break; case FinancialDependencyType.Salary: Salary salary = Salary.FromIdentity(dependency.ForeignId); if (salary.NetSalaryCents == this.AmountCents) // HACK: Assumes that tax total is not identical { DependentSalariesNet.Add(salary); } else { DependentSalariesTax.Add(salary); } break; case FinancialDependencyType.CashAdvance: DependentCashAdvancesPayout.Add(CashAdvance.FromIdentity(dependency.ForeignId)); break; case FinancialDependencyType.CashAdvancePayback: DependentCashAdvancesPayback.Add(CashAdvance.FromIdentity(dependency.ForeignId)); break; default: throw new NotImplementedException("Unknown financial dependency type in Payout.LoadDependencies(): " + dependency.ToString()); } } }
private void PopulateGrid() { ExpenseClaims allClaims = ExpenseClaims.ForOrganization(Organization.PPSE); ExpenseClaims unvalidatedClaims = new ExpenseClaims(); // LINQ would be nice here. "Where Validated=0". foreach (ExpenseClaim claim in allClaims) { if (!claim.Validated) { unvalidatedClaims.Add(claim); } } unvalidatedClaims.Sort(SortGridItems); this.GridExpenseClaims.DataSource = unvalidatedClaims; }
private void PopulateGrid() { ExpenseClaims allClaims = ExpenseClaims.ForOrganization(Organization.PPSE); ExpenseClaims unvalidatedClaims = new ExpenseClaims(); // LINQ would be nice here. "Where Validated=0". foreach (ExpenseClaim claim in allClaims) { if (!claim.Validated) { unvalidatedClaims.Add(claim); } } unvalidatedClaims.Sort(SortGridItems); this.GridExpenseClaims.DataSource = unvalidatedClaims; }
private void PopulateGrid() { ExpenseClaims allClaims = ExpenseClaims.FromClaimingPerson(_currentUser); ExpenseClaims gridData = new ExpenseClaims(); DateTime oneYearAgo = DateTime.Today.AddYears(-1); foreach (ExpenseClaim claim in allClaims) { // Add those that are less than a year old AND/OR not repaid yet. if (claim.ExpenseDate > oneYearAgo || claim.Open) { gridData.Add(claim); } } gridData.Sort(SortGridItems); this.GridExpenseClaims.DataSource = gridData; this.GridExpenseClaims.Rebind(); }
private void PopulatePreattested() { ExpenseClaims allClaims = ExpenseClaims.FromClaimingPersonAndOrganization(_currentUser, Organization.PPSE); ExpenseClaims preAttested = new ExpenseClaims(); foreach (ExpenseClaim claim in allClaims) { if (claim.Open && claim.Attested && !claim.Claimed) { preAttested.Add(claim); } } if (preAttested.Count > 0) { this.RadioPreattested.Checked = true; this.RadioNewClaim.Checked = false; this.DropPreattested.Items.Clear(); this.DropPreattested.Items.Add(new ListItem("-- Select One --", "0")); foreach (ExpenseClaim claim in preAttested) { this.DropPreattested.Items.Add(new ListItem(string.Format("Up to {0:N2}: {1} ({2})", claim.Amount, claim.Description, claim.Budget.Name), claim.Identity.ToString())); } this.DropPreattested.SelectedIndex = 0; } else { this.RadioNewClaim.Checked = true; this.RadioPreattested.Checked = false; this.RadioPreattested.Enabled = false; this.DropPreattested.Items.Clear(); this.DropPreattested.Items.Add(new ListItem("-- None --", "0")); this.DropPreattested.Enabled = false; } }
public static ExpensePayout FromOrganizationAndPerson(int organizationId, int personId) { ExpenseClaims allExpenseClaims = ExpenseClaims.FromOrganization(Organization.FromIdentity(organizationId)); ExpenseClaims expenseClaims = new ExpenseClaims(); // Aggregate per person foreach (ExpenseClaim expense in allExpenseClaims) { if (expense.ClaimingPersonId == personId) { if (expense.Approved && expense.Open) { // Ready for payout expenseClaims.Add(expense); } } } // Create ExpensePayout object return(new ExpensePayout(Person.FromIdentity(personId), expenseClaims)); }
public static ExpensePayout FromOrganizationAndPerson (int organizationId, int personId) { ExpenseClaims allExpenseClaims = ExpenseClaims.FromOrganization(Organization.FromIdentity(organizationId)); ExpenseClaims expenseClaims = new ExpenseClaims(); // Aggregate per person foreach (ExpenseClaim expense in allExpenseClaims) { if (expense.ClaimingPersonId == personId) { if (expense.Approved && expense.Open) { // Ready for payout expenseClaims.Add(expense); } } } // Create ExpensePayout object return new ExpensePayout(Person.FromIdentity(personId), expenseClaims); }
public static void ProcessExpensesRepaidClosed (BasicPWEvent newPwEvent) { Person expenser = Person.FromIdentity(newPwEvent.AffectedPersonId); Person payer = Person.FromIdentity(newPwEvent.ActingPersonId); // The ParameterText field is like a,b,c,d where a..d are expense IDs string[] idStrings = newPwEvent.ParameterText.Split(','); ExpenseClaims expenseClaims = new ExpenseClaims(); decimal totalAmount = 0.0m; foreach (string idString in idStrings) { ExpenseClaim newExpenseClaim = ExpenseClaim.FromIdentity(Int32.Parse(idString)); totalAmount += newExpenseClaim.Amount; expenseClaims.Add(newExpenseClaim); } string body = "The following expenses, totaling " + totalAmount.ToString("#,##0.00") + ", have been repaid to your registered account, " + expenser.BankName + " " + expenser.BankAccount + ".\r\n\r\n"; body += FormatExpenseLine("#", "Description", "Amount"); body += FormatExpenseLine("===", "========================================", "========="); foreach (ExpenseClaim expense in expenseClaims) { body += FormatExpenseLine(expense.Identity.ToString(), expense.Description, expense.Amount.ToString("#,##0.00")); } body += FormatExpenseLine("---", "----------------------------------------", "---------"); body += FormatExpenseLine(string.Empty, "TOTAL", totalAmount.ToString("#,##0.00")); body += "\r\nIf you see any problems with this, please contact the treasurer, " + payer.Name + ", at " + payer.PartyEmail + ". Thank you for helping the pirate movement succeed.\r\n"; new MailTransmitter(Strings.MailSenderNameFinancial, Strings.MailSenderAddress, "Expenses Repaid: " + totalAmount.ToString("#,##0.00"), body, expenser, true).Send(); }
private void PopulateGrid() { ExpenseClaims allClaims = ExpenseClaims.FromClaimingPerson(_currentUser); ExpenseClaims gridData = new ExpenseClaims(); DateTime oneYearAgo = DateTime.Today.AddYears(-1); foreach (ExpenseClaim claim in allClaims) { // Add those that are less than a year old AND/OR not repaid yet. if (claim.ExpenseDate > oneYearAgo || claim.Open) { gridData.Add(claim); } } gridData.Sort(SortGridItems); this.GridExpenseClaims.DataSource = gridData; this.GridExpenseClaims.Rebind(); }
private void PopulatePreattested() { ExpenseClaims allClaims = ExpenseClaims.FromClaimingPersonAndOrganization(_currentUser, Organization.PPSE); ExpenseClaims preAttested = new ExpenseClaims(); foreach (ExpenseClaim claim in allClaims) { if (claim.Open && claim.Attested && !claim.Claimed) { preAttested.Add(claim); } } if (preAttested.Count > 0) { this.RadioPreattested.Checked = true; this.RadioNewClaim.Checked = false; this.DropPreattested.Items.Clear(); this.DropPreattested.Items.Add(new ListItem("-- Select One --", "0")); foreach (ExpenseClaim claim in preAttested) { this.DropPreattested.Items.Add(new ListItem(string.Format("Up to {0:N2}: {1} ({2})", claim.Amount, claim.Description, claim.Budget.Name), claim.Identity.ToString())); } this.DropPreattested.SelectedIndex = 0; } else { this.RadioNewClaim.Checked = true; this.RadioPreattested.Checked = false; this.RadioPreattested.Enabled = false; this.DropPreattested.Items.Clear(); this.DropPreattested.Items.Add(new ListItem("-- None --", "0")); this.DropPreattested.Enabled = false; } }