/// <summary> /// Constructor /// </summary> public Bill(IServiceRtService serviceRtService, IInsuranceRateService insuranceRateService, IRentalCharge rentalCharge, IRaDriverHelper raDriverHelper) { if (serviceRtService == null) { throw new ArgumentNullException("serviceRtService"); } if (insuranceRateService == null) { throw new ArgumentNullException("insuranceRateService"); } if (rentalCharge == null) { throw new ArgumentNullException("rentalCharge"); } if (raDriverHelper == null) { throw new ArgumentNullException("raDriverHelper"); } this.serviceRtService = serviceRtService; this.insuranceRateService = insuranceRateService; this.rentalCharge = rentalCharge; this.raDriverHelper = raDriverHelper; BillingSummary = new BillingSummary(); }
/// <summary> /// Calculate Bill /// </summary> public void CalculateBill(ref RaMain raMain, List <TariffType> oTariffTypeList) { List <RaHireGroup> raHireGroupList = raMain.RaHireGroups.ToList(); List <RaServiceItem> raServiceItems = raMain.RaServiceItems.ToList(); List <RaDriver> raDrivers = raMain.RaDrivers.ToList(); List <RaPayment> raPayments = raMain.RaPayments.ToList(); List <RaAdditionalCharge> raAdditionalCharges = raMain.RaAdditionalCharges.ToList(); CalculateHireGroupCharges(raMain.RecCreatedDt, raMain.StartDtTime, raMain.EndDtTime, raMain.OperationId, ref raHireGroupList, oTariffTypeList); CalculateRACharges(ref raServiceItems, ref raDrivers, raMain.RecCreatedDt, raMain.OperationId, oTariffTypeList); BillingSummary billingSummary = GenerateBillingSummary(raHireGroupList, raServiceItems, raDrivers, raPayments, raAdditionalCharges, raMain.SpecialDiscountPerc != null ? (float)raMain.SpecialDiscountPerc : 0, (float)raMain.SpecialDiscount, raMain.IsSpecialDiscountPerc); MapBilling(raMain, billingSummary); }
private static void MapBilling(RaMain raMain, BillingSummary billingSummary) { raMain.TotalVehicleCharge = billingSummary.TotalVehicleCharge; raMain.TotalAdditionalCharge = billingSummary.TotalAdditionalCharge; raMain.TotalExcessMileageCharge = billingSummary.TotalExcessMileageCharge; raMain.TotalDropOffCharge = billingSummary.TotalDropOffCharge; raMain.TotalInsuranceCharge = billingSummary.TotalInsuranceCharge; raMain.SeasonalDiscount = billingSummary.SeasonalDiscount; raMain.StandardDiscount = billingSummary.StandardDiscount; raMain.SpecialDiscount = billingSummary.SpecialDiscount; raMain.NetBillAfterDiscount = billingSummary.NetBillAfterDiscount; raMain.AmountPaid = billingSummary.AmountPaid; raMain.TotalDriverCharge = billingSummary.TotalDriverCharge; raMain.TotalServiceCharge = billingSummary.TotalServiceCharge; raMain.TotalOtherCharge = billingSummary.TotalOtherCharge; raMain.Balance = billingSummary.Balance; }
public async void Account_GetBillingSummary_valid() { // Arrange MockHttpMessageHandler mockHttp = MockTools.GetNewMockHandler(); mockHttp.When(HttpMethod.Get, "*/billing").Respond(HttpStatusCode.OK, "application/json", JsonConvert.SerializeObject(CorrectBillingSummary)); AccountKey accKey = new AccountKey(); accKey.SetToken("17989543-2154-6867-3566-71474693165007735103-0594-4591-2132-259238857481", mockHttp); Account account = new Account(accKey); // Act BillingSummary summary = await account.GetBillingSummary(); // Assert Assert.Equal(CorrectBillingSummary.Balance, summary.Balance); Assert.Equal(CorrectBillingSummary.BillingRecords.Length, summary.BillingRecords.Length); Assert.Equal(CorrectBillingSummary.BillingRecords[0].Timestamp, summary.BillingRecords[0].Timestamp); }