Exemple #1
0
 def test_calculate_document_price(self):
     datetime_now = datetime.datetime(2024, 1, 1, 0, 00)
     date_now = datetime_now.date()
     test_quote = Quote.objects.get(description="ThisIsATestOffer")
     Calculations.calculate_document_price(document=test_quote,
                                           pricing_date=date_now)
     self.assertEqual(test_quote.last_calculated_price.__str__(), "5431.50")
     self.assertEqual(test_quote.last_calculated_tax.__str__(), "418.05")
 def test_calculate_document_with_unit_transform(self):
     quote_10 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_with_alternative_unit,
         overwrite_product_price=False,
         sales_document=quote_10)
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(document=quote_10,
                                           pricing_date=date_now)
     self.assertEqual(quote_10.last_calculated_price.__str__(), "36.00")
     self.assertEqual(quote_10.last_calculated_tax.__str__(), "4.00")
 def test_calculate_document_price_without_date_until(self):
     quote_3 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_without_date_until,
         overwrite_product_price=False,
         sales_document=quote_3)
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(document=quote_3,
                                           pricing_date=date_now)
     self.assertEqual(quote_3.last_calculated_price.__str__(), "117.00")
     self.assertEqual(quote_3.last_calculated_tax.__str__(), "13.00")
 def test_calculate_document_price_with_currency_rounding(self):
     quote_5 = StandardQuoteFactory.create(
         customer=self.customer, currency=self.test_currency_with_rounding)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=7.5,
         unit=self.unit,
         product_type=self.product_with_currency_rounding,
         overwrite_product_price=False,
         sales_document=quote_5)
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(document=quote_5,
                                           pricing_date=date_now)
     self.assertEqual(quote_5.last_calculated_price.__str__(), "27")
     self.assertEqual(quote_5.last_calculated_tax.__str__(), "3")
 def test_calculate_document_with_unit_transform(self):
     quote_10 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_with_alternative_unit,
         overwrite_product_price=False,
         sales_document=quote_10
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_10,
         pricing_date=date_now)
     self.assertEqual(
         quote_10.last_calculated_price.__str__(), "36.00")
     self.assertEqual(
         quote_10.last_calculated_tax.__str__(), "4.00")
 def test_calculate_document_price_without_date_until(self):
     quote_3 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_without_date_until,
         overwrite_product_price=False,
         sales_document=quote_3
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_3,
         pricing_date=date_now)
     self.assertEqual(
         quote_3.last_calculated_price.__str__(), "117.00")
     self.assertEqual(
         quote_3.last_calculated_tax.__str__(), "13.00")
 def test_calculate_document_price_overwritten(self):
     quote_1 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         product_type=self.product_without_dates,
         overwrite_product_price=True,
         position_price_per_unit=90,
         unit=self.unit,
         sales_document=quote_1
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_1,
         pricing_date=date_now)
     self.assertEqual(
         quote_1.last_calculated_price.__str__(), "81.00")
     self.assertEqual(
         quote_1.last_calculated_tax.__str__(), "9.00")
 def test_calculate_document_price_without_currency_rounding(self):
     quote_6 = StandardQuoteFactory.create(
         customer=self.customer,
         currency=self.test_currency_without_rounding
     )
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=7.5,
         unit=self.unit,
         product_type=self.product_without_currency_rounding,
         overwrite_product_price=False,
         sales_document=quote_6
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_6,
         pricing_date=date_now)
     self.assertEqual(
         quote_6.last_calculated_price.__str__(), "20.80")
     self.assertEqual(
         quote_6.last_calculated_tax.__str__(), "2.30")
Exemple #9
0
    def test_calculate_document_price(self):
        quote_1 = StandardQuoteFactory.create(customer=self.customer)
        StandardSalesDocumentPositionFactory.create(
            quantity=1,
            discount=0,
            product_type=self.product_without_customer_group,
            overwrite_product_price=False,
            unit=self.unit,
            sales_document=quote_1)
        datetime_now = datetime.datetime(2024, 1, 1, 0, 00)
        date_now = datetime_now.date()
        Calculations.calculate_document_price(document=quote_1,
                                              pricing_date=date_now)
        self.assertEqual(quote_1.last_calculated_price.__str__(), "90.00")
        self.assertEqual(quote_1.last_calculated_tax.__str__(), "10.00")

        quote_2 = StandardQuoteFactory.create(customer=self.customer)
        StandardSalesDocumentPositionFactory.create(
            quantity=1,
            discount=0,
            unit=self.unit,
            product_type=self.product_without_date_from,
            overwrite_product_price=False,
            sales_document=quote_2)
        datetime_now = datetime.datetime(2024, 1, 1, 0, 00)
        date_now = datetime_now.date()
        Calculations.calculate_document_price(document=quote_2,
                                              pricing_date=date_now)
        self.assertEqual(quote_2.last_calculated_price.__str__(), "45.00")
        self.assertEqual(quote_2.last_calculated_tax.__str__(), "5.00")

        quote_3 = StandardQuoteFactory.create(customer=self.customer)
        StandardSalesDocumentPositionFactory.create(
            quantity=1,
            discount=0,
            unit=self.unit,
            product_type=self.product_without_date_until,
            overwrite_product_price=False,
            sales_document=quote_3)
        datetime_now = datetime.datetime(2024, 1, 1, 0, 00)
        date_now = datetime_now.date()
        Calculations.calculate_document_price(document=quote_3,
                                              pricing_date=date_now)
        self.assertEqual(quote_3.last_calculated_price.__str__(), "117.00")
        self.assertEqual(quote_3.last_calculated_tax.__str__(), "13.00")

        quote_4 = StandardQuoteFactory.create(customer=self.customer)
        StandardSalesDocumentPositionFactory.create(
            quantity=1,
            discount=0,
            unit=self.unit,
            product_type=self.product_without_dates,
            overwrite_product_price=False,
            sales_document=quote_4)
        datetime_now = datetime.datetime(2024, 1, 1, 0, 00)
        date_now = datetime_now.date()
        Calculations.calculate_document_price(document=quote_4,
                                              pricing_date=date_now)
        self.assertEqual(quote_4.last_calculated_price.__str__(), "72.00")
        self.assertEqual(quote_4.last_calculated_tax.__str__(), "8.00")

        quote_5 = StandardQuoteFactory.create(
            customer=self.customer, currency=self.test_currency_with_rounding)
        StandardSalesDocumentPositionFactory.create(
            quantity=1,
            discount=7.5,
            unit=self.unit,
            product_type=self.product_with_currency_rounding,
            overwrite_product_price=False,
            sales_document=quote_5)
        datetime_now = datetime.datetime(2024, 1, 1, 0, 00)
        date_now = datetime_now.date()
        Calculations.calculate_document_price(document=quote_5,
                                              pricing_date=date_now)
        self.assertEqual(quote_5.last_calculated_price.__str__(), "27")
        self.assertEqual(quote_5.last_calculated_tax.__str__(), "3")

        quote_6 = StandardQuoteFactory.create(
            customer=self.customer,
            currency=self.test_currency_without_rounding)
        StandardSalesDocumentPositionFactory.create(
            quantity=1,
            discount=7.5,
            unit=self.unit,
            product_type=self.product_without_currency_rounding,
            overwrite_product_price=False,
            sales_document=quote_6)
        datetime_now = datetime.datetime(2024, 1, 1, 0, 00)
        date_now = datetime_now.date()
        Calculations.calculate_document_price(document=quote_6,
                                              pricing_date=date_now)
        self.assertEqual(quote_6.last_calculated_price.__str__(), "20.80")
        self.assertEqual(quote_6.last_calculated_tax.__str__(), "2.30")