public void Setup() { _vehicleTax = new VehicleTaxDto() { Id = 2, VehicleTypeId = 1100, ImportDuty = 0.2, Vat = 0.125, Nhil = 0.025, GetfundLevy = 0.025, AuLevy = 0.02, EcowasLevy = 0.05, EximLevy = 0.075, ExamLevy = 0.01, ProcessingFee = 0, SpecialImportLevy = 0.02 }; }
public async Task <Result <double> > CalculateDuty(CalculateDutyViewModel query) { if (!query.Result.IsValid) { _logger.LogError($"Validation failed: {query.Result.Errors.FirstOrDefault().ToString()}"); return(Result.Fail(new Error(query.Result.Errors.FirstOrDefault().ToString()))); } VehicleTaxDto taxInfo = await _vehicleRepository.FetchVehicleTaxByTypeId(query.VehicleTypeId).ConfigureAwait(false); if (taxInfo is null) { _logger.LogError($"Vehicle Type does not exist: {query.Result.Errors.FirstOrDefault().ToString()}"); return(Result.Fail(new Error("Vehicle Type does not exist!"))); } return(Result.Ok(taxInfo.CalculateDuty(query.CIF)) .WithSuccess("Vehicle Tax Listed Succesfully")); }
public static double CalculateDuty(this VehicleTaxDto tax, double CIF) => CIF * (tax.ImportDuty + tax.Nhil + tax.GetfundLevy + tax.AuLevy + tax.EcowasLevy + tax.EximLevy + tax.ExamLevy + tax.ProcessingFee + tax.SpecialImportLevy) + tax.CalculateVat(CIF);
//VAT is on the duty inclusive value (CIF + Duty + NHIL + GETFUND LEVY) public static double CalculateVat(this VehicleTaxDto tax, double CIF) => (CIF + CIF * tax.ImportDuty + CIF * tax.Nhil + CIF * tax.GetfundLevy) * tax.Vat;