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")
예제 #4
0
 def setUp(self):
     self.test_currency = StandardCurrencyFactory.create()
     self.test_quote = StandardQuoteFactory.create()
     self.test_user = StaffUserFactory.create()
     for i in range(10):
         test_product = StandardProductTypeFactory.create(
             description="This is a test product " + i.__str__(),
             title="This is a test product " + i.__str__(),
             product_type_identifier=12334235 + i,
         )
         StandardPriceFactory.create(product_type=test_product, )
         StandardSalesDocumentPositionFactory.create(
             sales_document=self.test_quote,
             position_number=i * 10,
             quantity=0.333 * i,
             description="This is a test position " + i.__str__(),
             discount=i * 5)
 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")
예제 #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")