def test_total_corrections(self): round = OrderRoundFactory() corr1 = OrderProductCorrectionFactory(order_product__order__order_round=round, charge_supplier=True) corr2 = OrderProductCorrectionFactory(order_product__order__order_round=round, charge_supplier=False) self.assertEqual(round.total_corrections(), {'supplier_inc': corr1.calculate_refund(), 'voko_inc': corr2.calculate_refund(), 'supplier_exc': corr1.calculate_supplier_refund()})
def test_calculate_supplier_refund_with_simple_values(self): round = OrderRoundFactory() corr = OrderProductCorrectionFactory(order_product__order__order_round=round, order_product__product__order_round=round, order_product__product__base_price=10, order_product__amount=2, supplied_percentage=25) self.assertEqual(corr.calculate_supplier_refund(), Decimal('15'))
def test_calculate_supplier_refund_with_simple_values(self): order_round = OrderRoundFactory() corr = OrderProductCorrectionFactory( order_product__order__order_round=order_round, order_product__product__order_round=order_round, order_product__product__base_price=10, order_product__amount=2, supplied_percentage=25) self.assertEqual(corr.calculate_supplier_refund(), Decimal('15'))
def test_no_supplier_refund_ignores_corrections_where_charge_supplier_is_false(self): round = OrderRoundFactory() corr = OrderProductCorrectionFactory(order_product__order__order_round=round, order_product__product__order_round=round, order_product__product__base_price=10, order_product__amount=2, supplied_percentage=25, charge_supplier=False) self.assertEqual(corr.calculate_supplier_refund(), Decimal('0'))
def test_calculate_supplier_refund_with_complex_values(self): round = OrderRoundFactory() corr = OrderProductCorrectionFactory(order_product__order__order_round=round, order_product__product__order_round=round, order_product__product__base_price=9.95, order_product__amount=2, supplied_percentage=24) # Total price: 9.95 * 2 = 19.90 # 19.90 * 0.76 = 15.12 self.assertEqual(corr.calculate_supplier_refund(), Decimal('15.12'))
def test_calculate_supplier_refund_with_complex_values(self): order_round = OrderRoundFactory() corr = OrderProductCorrectionFactory( order_product__order__order_round=order_round, order_product__product__order_round=order_round, order_product__product__base_price=9.95, order_product__amount=2, supplied_percentage=24) # Total price: 9.95 * 2 = 19.90 # 19.90 * 0.76 = 15.12 self.assertEqual(corr.calculate_supplier_refund(), Decimal('15.12'))
def test_supplier_refund_ignores_corrections_if_charge_supplier_is_false( self): order_round = OrderRoundFactory() corr = OrderProductCorrectionFactory( order_product__order__order_round=order_round, order_product__product__order_round=order_round, order_product__product__base_price=10, order_product__amount=2, supplied_percentage=25, charge_supplier=False) self.assertEqual(corr.calculate_supplier_refund(), Decimal('0'))
def test_total_corrections(self): order_round = OrderRoundFactory() corr1 = OrderProductCorrectionFactory( order_product__order__order_round=order_round, charge_supplier=True) corr2 = OrderProductCorrectionFactory( order_product__order__order_round=order_round, charge_supplier=False) self.assertEqual( order_round.total_corrections(), { 'supplier_inc': corr1.calculate_refund(), 'voko_inc': corr2.calculate_refund(), 'supplier_exc': corr1.calculate_supplier_refund() })