Beispiel #1
0
 private MotFee GetApplicableMotFee(InvoiceCalculationValues invoiceCalculationValues)
 {
     return(invoiceCalculationValues.MotFees
            .Where(mf => JobDate >= mf.ApplicableFrom)
            .OrderByDescending(mf => mf.ApplicableFrom)
            .FirstOrDefault());
 }
Beispiel #2
0
 private VatRate GetApplicableVatRate(InvoiceCalculationValues invoiceCalculationValues)
 {
     return(invoiceCalculationValues.VatRates
            .Where(vr => JobDate >= vr.ApplicableFrom)
            .OrderByDescending(vr => vr.ApplicableFrom)
            .FirstOrDefault());
 }
Beispiel #3
0
 private LabourRate GetApplicableLabourRate(InvoiceCalculationValues invoiceCalculationValues)
 {
     return(invoiceCalculationValues.LabourRates
            .Where(lr => JobDate >= lr.ApplicableFrom)
            .OrderByDescending(lr => lr.ApplicableFrom)
            .FirstOrDefault());
 }
Beispiel #4
0
        public InvoiceCosts CalculateInvoiceCosts(InvoiceCalculationValues invoiceCalculationValues)
        {
            var applicableVatRate    = GetApplicableVatRate(invoiceCalculationValues);
            var applicableLabourRate = GetApplicableLabourRate(invoiceCalculationValues);
            var applicableMotFee     = GetApplicableMotFee(invoiceCalculationValues);

            applicableVatRate.ShouldNotBeNull($"No historic VAT rate available for {JobDate}");
            applicableLabourRate.ShouldNotBeNull($"No historic Labour rate available for {JobDate}");
            applicableMotFee.ShouldNotBeNull($"No historic MOT fee available for {JobDate}");

            var partsCost  = Parts.Sum(p => p.Cost);
            var labourCost = LabourHours * applicableLabourRate.Rate;
            var vatCost    = (partsCost + labourCost) / 100 * applicableVatRate.Rate;
            var motCost    = IsMotTest ? applicableMotFee.Fee : 0;
            var totalCost  = partsCost + labourCost + vatCost + motCost;

            return(new InvoiceCosts(labourCost, partsCost, vatCost, motCost, totalCost));
        }