Ejemplo n.º 1
0
    private void AddSalaryEvent(int parentId, Salary salary, bool tax)
    {
        int newId = transactionEvents.Count + 1;

        transactionEvents.Add(new TransactionEvent(newId, parentId, (tax? "Tax for ": string.Empty) + "Salary #" + salary.Identity.ToString()));
        transactionEvents.Add(
            new TransactionEvent(newId + 1, newId,
                                 "To: " + salary.PayrollItem.Person.Canonical));
        transactionEvents.Add(
            new TransactionEvent(newId + 2, newId,
                                 "Payday: " + salary.PayoutDate.ToString("yyyy-MM-dd")));

        AddValidations(newId, salary);

        transactionEvents.Add(
            new TransactionEvent(transactionEvents.Count + 1, newId,
                                 "Base Salary: " + salary.BaseSalaryDecimal.ToString("N2")));

        PayrollAdjustments adjustments = salary.Adjustments;

        foreach (PayrollAdjustment adjustment in adjustments)
        {
            if (adjustment.Type == PayrollAdjustmentType.GrossAdjustment)
            {
                transactionEvents.Add(
                    new TransactionEvent(transactionEvents.Count + 1, newId,
                                         adjustment.Description + ": " + adjustment.AmountDecimal.ToString("N2")));
            }
        }

        transactionEvents.Add(
            new TransactionEvent(transactionEvents.Count + 1, newId,
                                 "Primary Income Tax: " + (-salary.SubtractiveTaxDecimal).ToString("N2")));

        foreach (PayrollAdjustment adjustment in adjustments)
        {
            if (adjustment.Type == PayrollAdjustmentType.NetAdjustment)
            {
                transactionEvents.Add(
                    new TransactionEvent(transactionEvents.Count + 1, newId,
                                         adjustment.Description + ": " + adjustment.AmountDecimal.ToString("N2")));
            }
        }

        transactionEvents.Add(
            new TransactionEvent(transactionEvents.Count + 1, newId,
                                 "NET PAYOUT: " + salary.NetSalaryDecimal.ToString("N2")));

        transactionEvents.Add(
            new TransactionEvent(transactionEvents.Count + 1, newId,
                                 "Additional Tax: " + salary.AdditiveTaxDecimal.ToString("N2")));
    }
    private void PopulateGrid()
    {
        List <PayrollLineItem> lines       = new List <PayrollLineItem>();
        PayrollAdjustments     adjustments = PayrollAdjustments.ForPayrollItem(_payrollItem);

        lines.Add(new PayrollLineItem("BASE SALARY", _payrollItem.BaseSalaryCents / 100.0));
        double pay = _payrollItem.BaseSalaryCents / 100.0;

        foreach (PayrollAdjustment adjustment in adjustments)
        {
            if (adjustment.Type == PayrollAdjustmentType.GrossAdjustment)
            {
                pay += adjustment.AmountCents / 100.0;
                lines.Add(new PayrollLineItem(adjustment.Description, adjustment.AmountCents / 100.0));
            }
        }

        lines.Add(new PayrollLineItem("GROSS SALARY", pay));

        double subtractiveTax = TaxLevels.GetTax(_payrollItem.Country, _payrollItem.SubtractiveTaxLevelId, pay);

        if (subtractiveTax < 1.0)
        {
            // this is a percentage and not an absolute number

            subtractiveTax = pay * subtractiveTax;
        }

        lines.Add(new PayrollLineItem("Income Tax", -subtractiveTax));
        pay -= subtractiveTax;

        foreach (PayrollAdjustment adjustment in adjustments)
        {
            if (adjustment.Type == PayrollAdjustmentType.NetAdjustment)
            {
                pay += adjustment.AmountCents / 100.0;
                lines.Add(new PayrollLineItem(adjustment.Description, adjustment.AmountCents / 100.0));
            }
        }

        if (pay < 0.0)
        {
            lines.Add(new PayrollLineItem("Negative amount rolling over to next salary", -pay));
            pay = 0.0;
        }

        lines.Add(new PayrollLineItem("NET SALARY PAYOUT", pay));

        this.GridProjectedPayroll.DataSource = lines;
        this.GridProjectedPayroll.DataBind();
    }