public void AddTaxInfo_GivenAnExistingTaxInfo_ThrowsException() { // arrange SalesTaxInfo duplicateTax = new SalesTaxInfo() { Country = "Canada", Province = "Quebec" }; var data = new List <SalesTaxInfo>() { new SalesTaxInfo() { Country = "Canada", Province = "Quebec" } }; Mock <DbSet <SalesTaxInfo> > mockTaxesSet = EntityMockFactory.CreateSet(data.AsQueryable()); Mock <AccountingDb> mockContext = new Mock <AccountingDb>(); mockContext.Setup(c => c.Taxes).Returns(mockTaxesSet.Object); SalesTaxRepository sut = new SalesTaxRepository(mockContext.Object); // act sut.AddTaxInfo(duplicateTax); // assert // exception should be thrown }
public SalesTaxExclusion(SalesTaxInfo taxInfo) { InitializeComponent(); TaxInfo = taxInfo; if (taxInfo == null) { return; } txtComments.Text = taxInfo.Comments; chkCity.Checked = taxInfo.ExcludeCity; chkState.Checked = taxInfo.ExcludeState; chkCounty.Checked = taxInfo.ExcludeCounty; //Madhu BZ # 368 if (chkCity.Checked && chkState.Checked && chkCounty.Checked) { chkSelectAll.Checked = true; } lblCityRate.Text = taxInfo.CityStoreTax.TaxRate.ToString("f2"); lblStateRate.Text = taxInfo.StateStoreTax.TaxRate.ToString("f2"); lblCountyRate.Text = taxInfo.CountyStoreTax.TaxRate.ToString("f2"); }
public void UodateTaxInfo_GivenAnUpdatedInfo_UpdatesRecordInDatabase() { // arrange SalesTaxInfo update = new SalesTaxInfo() { Country = "Canada", Province = "Quebec", Federal = 0.05f, Provincial = 0.0975f }; var data = new List <SalesTaxInfo>() { new SalesTaxInfo() { Country = "Canada", Province = "Quebec", Federal = 0.12f, Provincial = 0.04f } }; var actual = data[0]; Mock <DbSet <SalesTaxInfo> > mockTaxesSet = EntityMockFactory.CreateSet(data.AsQueryable()); Mock <AccountingDb> mockContext = new Mock <AccountingDb>(); mockContext.Setup(c => c.Taxes).Returns(mockTaxesSet.Object); SalesTaxRepository sut = new SalesTaxRepository(mockContext.Object); // act sut.UpdateTaxInfo(update); // assert mockContext.Verify(c => c.Taxes, Times.Once()); Assert.AreEqual(0.05f, actual.Federal); Assert.AreEqual(0.0975f, actual.Provincial); }
public void UpdateTaxInfo(SalesTaxInfo salesTax) { var record = FindRecord(salesTax.Country, salesTax.Province); record.Provincial = salesTax.Provincial; record.Federal = salesTax.Federal; db.SaveChanges(); }
private decimal CalculateTotal(decimal subtotal, SalesTaxInfo tax) { var totalTax = tax.Federal + tax.Provincial; var shipping = (decimal)GetShippingCostFromSession(); var result = subtotal + shipping; result += (result * (decimal)totalTax); return(result); }
public void AddTaxInfo(SalesTaxInfo salesTax) { var taxtInfo = FindRecord(salesTax.Country, salesTax.Province); if (taxtInfo != null) { throw new ArgumentException("A record for the same country and province already exists."); } db.Taxes.Add(salesTax); db.SaveChanges(); }
private void CalculateSubTotals() { //_taxRate = 8.25m; //_backGroundCheckfee = 0.0m; //need to get more info on setting this value. //_taxAmount = TaxExclusionInfo.AdjustedTaxRate * _subTotal / 100; //_taxAmount = _taxAmount + _outTheDoorTaxAmt; //_subTotal = _subTotal + _outTheDoorSubTotal; if (LayawayPaymentCalc == null) { LayawayPaymentCalc = GlobalDataAccessor.Instance.DesktopSession.LayawayPaymentCalc; } decimal subTotal = Math.Round(SubTotal, 2); if (CDS.LayawayMode) { BusinessRulesProcedures bProcedures = new BusinessRulesProcedures(CDS); if (bProcedures.IsServiceFeeTaxable(CDS.CurrentSiteId)) { this._taxAmount = this.SalesTaxInfo.CalculateTax(subTotal - this._transactionCouponAmount) + this.LayawayPaymentCalc.ServiceFeeTax; this._retailTotal = subTotal + this.LayawayPaymentCalc.ServiceFee + this._taxAmount + GetBackgroundCheckFee() - this._transactionCouponAmount;//plus other totals after they are calculated if (_transactionCouponAmount > subTotal + this.LayawayPaymentCalc.ServiceFee + GetBackgroundCheckFee()) { MessageBox.Show("Transaction level coupon is more than the total retail price. Cannot proceed"); } } else { this._taxAmount = this.SalesTaxInfo.CalculateTax(subTotal - this._transactionCouponAmount); this._retailTotal = subTotal + this.LayawayPaymentCalc.ServiceFeeTotal + this._taxAmount + GetBackgroundCheckFee() - this._transactionCouponAmount;//plus other totals after they are calculated if (_transactionCouponAmount > subTotal + this.LayawayPaymentCalc.ServiceFeeTotal + GetBackgroundCheckFee()) { MessageBox.Show("Transaction level coupon is more than the total retail price. Cannot proceed"); } } } else { _taxAmount = SalesTaxInfo.CalculateTax(subTotal - _transactionCouponAmount); _retailTotal = Math.Round(subTotal + ShippingAndHandling + _taxAmount + GetBackgroundCheckFee() - _transactionCouponAmount, 2);//plus other totals after they are calculated if (_transactionCouponAmount > subTotal + ShippingAndHandling + GetBackgroundCheckFee()) { MessageBox.Show("Transaction level coupon is more than the total retail price. Cannot proceed"); } } //customButtonOutTheDoor.Enabled = _retailTotal > 0; SetFormValues(); RaiseTotalsChanged(); }
public SalesTaxInfo GetTaxInfo(string country, string province) { string cacheKey = "taxFor" + province + country; SalesTaxInfo result = cache[cacheKey] as SalesTaxInfo; if (result == null) { result = taxRepo.GetTaxInfo(country, province); cache.Set(cacheKey, result, CachingPolicies.OneDayPolicy); } return(result); }
public void AddTaxInfo_GivenANewTaxInfo_AddsToTheDatabase() { // arrange SalesTaxInfo newTax = new SalesTaxInfo() { Country = "Canada", Province = "Ontario" }; List <SalesTaxInfo> data = new List <SalesTaxInfo>(); Mock <DbSet <SalesTaxInfo> > mockTaxesSet = EntityMockFactory.CreateSet(data.AsQueryable()); Mock <AccountingDb> mockContext = new Mock <AccountingDb>(); mockContext.Setup(c => c.Taxes).Returns(mockTaxesSet.Object); SalesTaxRepository sut = new SalesTaxRepository(mockContext.Object); // act sut.AddTaxInfo(newTax); // assert mockContext.Verify(c => c.Taxes, Times.Exactly(2)); mockTaxesSet.Verify(s => s.Add(newTax), Times.Once()); mockContext.Verify(c => c.SaveChanges(), Times.Once()); }
public void Setup() { Calculator = new OutTheDoorCalculator(); RetailItems = new List <RetailItem>(); SalesTaxInfo = new SalesTaxInfo(); }
public void UpdateTaxInfo(SalesTaxInfo taxInfo) { taxRepo.UpdateTaxInfo(taxInfo); }
public void AddTaxInfo(SalesTaxInfo taxInfo) { taxRepo.AddTaxInfo(taxInfo); }
public void UpdateTaxInfo(SalesTaxInfo taxInfo) { Channel.UpdateTaxInfo(taxInfo); }
public void AddTaxInfo(SalesTaxInfo taxInfo) { Channel.AddTaxInfo(taxInfo); }