public void RoundValueTest() { decimal value = 8.56m; DecimalExtensionMethods.RoundValue(value); Assert.AreEqual(Math.Round(value, 1), 8.6m); Assert.AreEqual(Math.Round(value, 0), 9m); }
public decimal CalculateMonthlyPayableIncomeTax(decimal annualTaxableIncome) { Validator.IsValidValue(annualTaxableIncome); var taxBracket = GetTaxBracket(annualTaxableIncome); var marginalTax = CalculateMarginalTax(annualTaxableIncome, taxBracket); var monthlyIncomeTax = (taxBracket.AccumulatedTaxFromPreviousBracket + marginalTax) / Constants.MonthsInYear; return(DecimalExtensionMethods.RoundValue(monthlyIncomeTax)); }
public void ToFormatTest() { Nullable <Decimal> num = new Nullable <Decimal>(); // TODO: Initialize to an appropriate value string format = string.Empty; // TODO: Initialize to an appropriate value string formatIfPositive = string.Empty; // TODO: Initialize to an appropriate value string formatIfZero = string.Empty; // TODO: Initialize to an appropriate value string formatIfNegative = string.Empty; // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = DecimalExtensionMethods.ToFormat(num, format, formatIfPositive, formatIfZero, formatIfNegative); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
protected void Page_Load(object sender, EventArgs e) { var allp = new ProductsPersistency(); IEnumerable <Product> AllProducts = allp.GetAll(); BasketTable.CssClass = "table-basket"; TableRow r = new TableRow(); r.CssClass = "titlerow-basket"; TableCell tc1 = new TableCell(); tc1.Text = "Produkt"; r.Cells.Add(tc1); TableCell tc2 = new TableCell(); tc2.Text = "Preis"; r.Cells.Add(tc2); BasketTable.Rows.Add(r); foreach (string pid in this.Session) { foreach (Product p in AllProducts) { if (p.Id == this.Session[pid].ToString()) { TableRow row = new TableRow(); TableCell c1 = new TableCell(); c1.Text = p.Name; row.Cells.Add(c1); TableCell c2 = new TableCell(); c2.Text = DecimalExtensionMethods.AsChf(p.SpecialOffer); row.Cells.Add(c2); BasketTable.Rows.Add(row); Total += (double)p.SpecialOffer; } } } TotalPrice.Text = "Total: " + Total.ToString() + " CHF"; }
public PayslipInfo Calculate(PayslipInput payslipInput) { TaxCalculator taxCalculator = new TaxCalculator(); var salary = payslipInput.Salary; var grossIncome = DecimalExtensionMethods.RoundValue(CalculateMonthlyTaxableIncomeFrom(salary)); var incomeTax = taxCalculator.CalculateMonthlyPayableIncomeTax(salary); return(new PayslipInfo(payslipInput.Employee, payslipInput.PayPeriod, payslipInput.SuperRate, grossIncome, incomeTax, grossIncome - incomeTax, DecimalExtensionMethods.RoundValue(grossIncome * payslipInput.SuperRate))); }
public void CalculateMonthlyPayableIncomeTaxTest() { decimal expected = 922m; decimal annualTaxableIncome = 60050; TaxCalculator taxCalculator = new TaxCalculator(); var taxBracket = taxCalculator.GetTaxBracket(annualTaxableIncome); var marginalTax = taxCalculator.CalculateMarginalTax(annualTaxableIncome, taxBracket); var monthlyIncomeTax = (taxBracket.AccumulatedTaxFromPreviousBracket + marginalTax) / Constants.MonthsInYear; decimal actual = DecimalExtensionMethods.RoundValue(monthlyIncomeTax); Assert.AreEqual(expected, actual); }
public decimal GetTransactionFee(CreateRawTransactionRequest transaction, bool checkIfTransactionQualifiesForFreeRelay, bool enforceMinimumTransactionFeePolicy) { if (checkIfTransactionQualifiesForFreeRelay && IsTransactionFree(transaction)) { return(0); } decimal transactionSizeInBytes = GetTransactionSizeInBytes(transaction); var transactionFee = ((transactionSizeInBytes / Parameters.FreeTransactionMaximumSizeInBytes) + (transactionSizeInBytes % Parameters.FreeTransactionMaximumSizeInBytes == 0 ? 0 : 1)) * Parameters.FeePerThousandBytesInCoins; if (transactionFee.GetNumberOfDecimalPlaces() > DecimalExtensionMethods.GetNumberOfDecimalPlaces(Parameters.CoinsPerBaseUnit)) { transactionFee = decimal.Round(transactionFee, DecimalExtensionMethods.GetNumberOfDecimalPlaces(Parameters.CoinsPerBaseUnit), MidpointRounding.AwayFromZero); } if (enforceMinimumTransactionFeePolicy && Parameters.MinimumTransactionFeeInCoins != 0 && transactionFee < Parameters.MinimumTransactionFeeInCoins) { transactionFee = Parameters.MinimumTransactionFeeInCoins; } return(transactionFee); }