private void PopulateSalaries() { Salaries salaries = Salaries.ForOrganization(CurrentOrganization); // No unattestability for previously attested salaries because complex foreach (Salary salary in salaries) { if (this._approvalRights.ContainsKey(salary.PayrollItem.BudgetId) || salary.PayrollItem.Budget.OwnerPersonId == Person.NobodyId) { if (!salary.Attested) { this._approvableCosts.Add(new ApprovableCost("S" + salary.Identity.ToString(CultureInfo.InvariantCulture), salary.PayrollItem.PersonCanonical, salary.CostTotalCents, salary.PayrollItem.Budget, "[Loc]Financial_SalarySpecification|[Date]" + salary.PayoutDate.ToString(CultureInfo.InvariantCulture), "Financial_Salary", false, salary)); } else { this._approvedCosts.Add(new ApprovableCost("S" + salary.Identity.ToString(CultureInfo.InvariantCulture), salary.PayrollItem.PersonCanonical, salary.CostTotalCents, salary.PayrollItem.Budget, "[Loc]Financial_SalarySpecification|[Date]" + salary.PayoutDate.ToString(CultureInfo.InvariantCulture), "Financial_Salary", false, salary)); } } } }
private Dictionary <int, SalaryData> GetSalaryData() { Dictionary <int, SalaryData> result = new Dictionary <int, SalaryData>(); Salaries salaries = Salaries.ForOrganization(_authenticationData.CurrentOrganization, true); foreach (Salary salary in salaries) { int monthKey = salary.PayoutDate.Year * 100 + salary.PayoutDate.Month; if (!result.ContainsKey(monthKey)) { result[monthKey] = new SalaryData(); } result[monthKey].GrossSalaryCents += salary.GrossSalaryCents; result[monthKey].AdditiveTaxCents += salary.AdditiveTaxCents; result[monthKey].DeductedTaxCents += salary.SubtractiveTaxCents; if (monthKey < _minKey) { _minKey = monthKey; } } return(result); }
protected void PopulateGrid() { Salaries salaries = Salaries.ForOrganization(Organization.PPSE, true); List <GridRow> rows = new List <GridRow>(); Dictionary <int, GridRow> sumRows = new Dictionary <int, GridRow>(); foreach (Salary salary in salaries) { int monthKey = salary.PayoutDate.Year * 100 + salary.PayoutDate.Month; rows.Add(new GridRow(salary.Identity, monthKey, salary.PayrollItem.PersonCanonical, salary.GrossSalaryCents / 100.0, salary.SubtractiveTaxCents / 100.0, salary.AdditiveTaxCents / 100.0)); if (sumRows.ContainsKey(monthKey)) { sumRows[monthKey].Add(salary.GrossSalaryCents / 100.0, salary.SubtractiveTaxCents / 100.0, salary.AdditiveTaxCents / 100.0); } else { sumRows[monthKey] = new GridRow(monthKey, 0, salary.PayoutDate.ToString("yyyy MMMM", CultureInfo.InvariantCulture), salary.GrossSalaryCents / 100.0, salary.SubtractiveTaxCents / 100.0, salary.AdditiveTaxCents / 100.0); } } foreach (int key in sumRows.Keys) { rows.Add(sumRows[key]); } this.GridSalaryTaxData.DataSource = rows; }
private SalaryTaxData GetSalaryData(int year, int month, Organization organization, int[] yearBreakpoints) { SalaryTaxData result = new SalaryTaxData(); Salaries salaries = Salaries.ForOrganization(organization, true); foreach (Salary salary in salaries) { if (salary.PayoutDate.Year == year && salary.PayoutDate.Month == month) { int employeeBirthYear = salary.PayrollItem.Person.Birthdate.Year; int ageBracket = 0; // main if (employeeBirthYear >= yearBreakpoints[2]) { ageBracket = 1; // youth rebate } else if (employeeBirthYear < yearBreakpoints[1]) { ageBracket = 2; // pensioners } result.Salary[ageBracket] += salary.GrossSalaryCents / 100.0; result.SalaryTotal += salary.GrossSalaryCents / 100.0; result.TaxSubtractiveTotal += salary.SubtractiveTaxCents / 100.0; result.TaxAdditive[ageBracket] += salary.AdditiveTaxCents / 100.0; result.TaxAdditiveTotal += salary.AdditiveTaxCents / 100.0; result.TaxTotal += salary.TaxTotalCents / 100.0; } } return(result); }
private void PopulateSalaries(AttestableItems items) { Salaries salaries = Salaries.ForOrganization(Organization.PPSE); Salaries unattestedSalaries = new Salaries(); // LINQ would be nice here. "Where Attested=0". foreach (Salary salary in salaries) { if (!salary.Attested) { if (attestationRights.ContainsKey(salary.PayrollItem.BudgetId) && salary.PayrollItem.PersonId != _currentUser.Identity) { unattestedSalaries.Add(salary); } else if (salary.PayrollItem.ReportsToPersonId == _currentUser.Identity) { unattestedSalaries.Add(salary); } } } foreach (Salary salary in unattestedSalaries) { AddAttestableItem(items, salary); } }
private void PopulateSalaries() { Salaries salaries = Salaries.ForOrganization(this.CurrentOrganization).WhereUnattested; foreach (Salary salary in salaries) { if (_attestationRights.ContainsKey(salary.PayrollItem.BudgetId) || salary.PayrollItem.Budget.OwnerPersonId == Person.NobodyId) { _items.Add(new AttestableItem("S" + salary.Identity.ToString(CultureInfo.InvariantCulture), salary.PayrollItem.PersonCanonical, salary.CostTotalCents, salary.PayrollItem.Budget, "[Loc]Financial_SalarySpecification|[Date]" + salary.PayoutDate.ToString(CultureInfo.InvariantCulture), "Financial_Salary", false, salary)); } } }
protected void PopulateGrid() { Salaries salaries = Salaries.ForOrganization(Organization.PPSE, true); List <GridRow> rows = new List <GridRow>(); Dictionary <int, GridRow> yearRows = new Dictionary <int, GridRow>(); Dictionary <string, GridRow> yearEmployeeRows = new Dictionary <string, GridRow>(); foreach (Salary salary in salaries) { int yearKey = salary.PayoutDate.Year; string yearEmployeeKey = salary.PayoutDate.Year.ToString() + salary.PayrollItem.PersonId.ToString(); if (yearEmployeeRows.ContainsKey(yearEmployeeKey)) { yearEmployeeRows[yearEmployeeKey].Add(salary.GrossSalaryCents / 100.0, salary.SubtractiveTaxCents / 100.0, salary.AdditiveTaxCents / 100.0); } else { yearEmployeeRows [yearEmployeeKey] = new GridRow(salary.Identity, yearKey, salary.PayrollItem.PersonCanonical, salary.GrossSalaryCents / 100.0, salary.SubtractiveTaxCents / 100.0, salary.AdditiveTaxCents / 100.0); } if (yearRows.ContainsKey(yearKey)) { yearRows[yearKey].Add(salary.GrossSalaryCents / 100.0, salary.SubtractiveTaxCents / 100.0, salary.AdditiveTaxCents / 100.0); } else { yearRows[yearKey] = new GridRow(yearKey, 0, salary.PayoutDate.ToString("yyyy", CultureInfo.InvariantCulture), salary.GrossSalaryCents / 100.0, salary.SubtractiveTaxCents / 100.0, salary.AdditiveTaxCents / 100.0); } } foreach (string key in yearEmployeeRows.Keys) { rows.Add(yearEmployeeRows[key]); } foreach (int key in yearRows.Keys) { rows.Add(yearRows[key]); } this.GridSalaryTaxData.DataSource = rows; }
private SalaryTaxData GetSalaryData(int year, int month, Organization organization) { SalaryTaxData result = new SalaryTaxData(); Salaries salaries = Salaries.ForOrganization(organization, true); foreach (Salary salary in salaries) { if (salary.PayoutDate.Year == year && salary.PayoutDate.Month == month) { result.SalaryTotal += salary.GrossSalaryCents / 100.0; result.SalaryMain += salary.GrossSalaryCents / 100.0; result.TaxSubtractive += salary.SubtractiveTaxCents / 100.0; result.TaxAdditiveMain += salary.AdditiveTaxCents / 100.0; result.TaxAdditiveTotal += salary.AdditiveTaxCents / 100.0; result.TaxTotal += salary.TaxTotalCents / 100.0; } } return(result); }
private void AddSalaries(Person person, Organization organization) { TaskGroup group = new TaskGroup(TaskGroupType.AttestSalaries); // TODO: Loop over roles, get all open claims for roles where person can attest Salaries salaries = Salaries.ForOrganization(organization); foreach (Salary salary in salaries) { if (salary.AttestationExpectedBy.Identity == person.Identity && !salary.Attested) { group.Tasks.Add(new TaskSalary(salary)); } } if (group.Tasks.Count > 0) { Add(group); } }
private void PopulateDebugInfo() { debugLookup = new Dictionary <int, DebugInfoLine>(); ExpenseClaims expenseClaims = ExpenseClaims.FromOrganization(Organization.PPSE); InboundInvoices inboundInvoices = InboundInvoices.ForOrganization(Organization.PPSE); Salaries salaries = Salaries.ForOrganization(Organization.PPSE); Payouts payouts = Payouts.ForOrganization(Organization.PPSE); debugLookup[Organization.PPSE.FinancialAccounts.DebtsExpenseClaims.Identity] = new DebugInfoLine(); debugLookup[Organization.PPSE.FinancialAccounts.DebtsInboundInvoices.Identity] = new DebugInfoLine(); debugLookup[Organization.PPSE.FinancialAccounts.CostsAllocatedFunds.Identity] = new DebugInfoLine(); debugLookup[Organization.PPSE.FinancialAccounts.DebtsSalary.Identity] = new DebugInfoLine(); debugLookup[Organization.PPSE.FinancialAccounts.DebtsTax.Identity] = new DebugInfoLine(); foreach (Payout payout in payouts) { foreach (ExpenseClaim claim in payout.DependentExpenseClaims) { debugLookup[Organization.PPSE.FinancialAccounts.DebtsExpenseClaims.Identity].Payouts -= claim.Amount; } foreach (InboundInvoice invoice in payout.DependentInvoices) { debugLookup[Organization.PPSE.FinancialAccounts.DebtsInboundInvoices.Identity].Payouts -= (decimal)invoice.Amount; } foreach (Salary salary in payout.DependentSalariesNet) { debugLookup[Organization.PPSE.FinancialAccounts.DebtsSalary.Identity].Payouts -= salary.NetSalaryDecimal; } foreach (Salary salary in payout.DependentSalariesTax) { debugLookup[Organization.PPSE.FinancialAccounts.DebtsTax.Identity].Payouts -= salary.TaxTotalDecimal; } } foreach (ExpenseClaim claim in expenseClaims) { if (claim.Open) { AddExpenseToDebug(claim); } } foreach (InboundInvoice invoice in inboundInvoices) { AddInboundInvoiceToDebug(invoice); } foreach (Salary salary in salaries) { AddSalaryNetToDebug(salary); AddSalaryTaxToDebug(salary); } List <DebugInfoLine> debugInfoLines = new List <DebugInfoLine>(); foreach (int accountId in debugLookup.Keys) { debugLookup[accountId].AccountId = accountId; debugLookup[accountId].Actual = FinancialAccount.FromIdentity(accountId).GetDelta(new DateTime(2006, 1, 1), DateTime.Today.AddDays(2)); // two days to account for all possible time zones } foreach (DebugInfoLine line in debugLookup.Values) { debugInfoLines.Add(line); } this.GridDebug.DataSource = debugInfoLines; }