コード例 #1
0
    def test_with_vat(self):
        """
        Test that given
            hourly rate: 1000 pence
            vat rate: 19.5

            estimated time: 130 mins
            discount amount: 100 pence

        The calculations are:

            net cost: time * hourly rate
                => 2166.6666 rounded up to 2167
            subtotal cost: net cost - discount amount
                => 2067
            vat cost: 19.5% of subtotal
                => 403.065 rounded down to 403
            total cost: subtotal cost + vat cost
                => 2470
        """
        pricing = _calculate_pricing(
            estimated_time=130,
            hourly_rate=1000,
            vat_value=Decimal(19.5),
            discount_value=100,
        )
        assert pricing.net_cost == 2167
        assert pricing.subtotal_cost == 2067
        assert pricing.vat_cost == 403
        assert pricing.total_cost == 2470
コード例 #2
0
    def test_without_vat(self):
        """
        Test that given
            hourly rate: 1000 pence
            vat rate: 0

            estimated time: 130 mins
            discount amount: 100 pence

        The calculations are:

            net cost: time * hourly rate
                => 2166.6666 rounded up to 2167
            subtotal cost: net cost - discount amount
                => 2067
            vat cost: 0% of subtotal
                => 0
            total cost: subtotal cost + vat cost
                => 2067
        """
        pricing = _calculate_pricing(
            estimated_time=130,
            hourly_rate=1000,
            vat_value=0,
            discount_value=100,
        )
        assert pricing.net_cost == 2167
        assert pricing.subtotal_cost == 2067
        assert pricing.vat_cost == 0
        assert pricing.total_cost == 2067
コード例 #3
0
 def test_zero_hours(self):
     """
     Test that given estimated time = 0, all the calculated values are zero.
     """
     pricing = _calculate_pricing(
         estimated_time=0,
         hourly_rate=1000,
         vat_value=Decimal(20),
         discount_value=100,
     )
     assert pricing == OrderPricing(0, 0, 0, 0)