public bool AddCommercialTax(TaxCode taxCode) { if (taxCode == null) { return(false); } if (CommercialTaxes == null) { CommercialTaxes = new List <CommercialTax>(); } var existCommercialTax = CommercialTaxes .Where(ct => ct.TaxCodeId == taxCode.Id) .FirstOrDefault(); if (existCommercialTax == null) { var newCommercialTax = new CommercialTax() { Id = Guid.NewGuid(), TaxCode = taxCode, Commercial = this, CommercialId = Id }; CommercialTaxes.Add(newCommercialTax); ReCalculate(); return(true); } return(false); }
public void ReCalculateTax() { this.CommercialTaxes .ToList() .ForEach(commercialTax => { commercialTax.UpdateTaxBalance(this.TaxOffset); }); this.Tax = (CommercialTaxes?.ToList().Sum(i => i.TaxBalance) ?? 0); }
public bool RemoveCommercialTax(TaxCode taxCode) { if (taxCode == null) { throw new NotImplementedException("TaxCode is null"); } var existCommercialTax = CommercialTaxes .Where(ct => ct.TaxCodeId == taxCode.Id) .FirstOrDefault(); if (existCommercialTax != null && existCommercialTax.TaxPeriodId == null) { CommercialTaxes.Remove(existCommercialTax); ReCalculate(); return(true); } throw new NotImplementedException("Cannot Remove"); }
public bool RemoveCommercialTaxs() { if (PostStatus == LedgerPostStatus.Posted) { throw new Exception("Transaction is posted"); } var CommercialTaxs = CommercialTaxes.ToList(); CommercialTaxs.ForEach(ct => { if (ct.TaxPeriodId != null) { throw new Exception("Transaction is areardy assign to tax period"); } else { CommercialTaxes.Remove(ct); } }); ReCalculate(); return(true); }