Пример #1
0
 def test_spec_if_proforma_exist(self):
     discount = {
         'lte__90': 10,
         'gt__90': 10,
     }
     date = '20201014'
     modified_df, cost_file_name = helpers.prepare_data_frame_based_on_proforma_date(
         date)
     specs_profit = helpers.add_profit_to_specs(modified_df,
                                                self.specs,
                                                discount_dict=discount)
     specs_profit_split = helpers.split_specs_if_profit_exists(specs_profit)
     self.assertEqual(len(specs_profit_split['specs_no_profit']), 3)
     self.assertEqual(specs_profit_split['specs_no_profit'][0]['power'],
                      self.not_routine_specs[0]['power'])
Пример #2
0
    def test_specs_have_no_cost(self):
        date = '20201014'
        discount = {
            'lte__90': 15,
            'gt__90': 10,
        }

        modified_df, cost_file_name = helpers.prepare_data_frame_based_on_proforma_date(
            date)
        specs_profit = helpers.add_profit_to_specs(modified_df,
                                                   self.not_routine_specs,
                                                   discount_dict=discount)
        specs_profit_split = helpers.split_specs_if_profit_exists(specs_profit)

        results = helpers.calculate_profit_of_proforma(
            specs_profit_split['specs_has_profit'])
        self.assertEqual(results['profit'], 0)
        self.assertIsNone(results['percent'], None)
Пример #3
0
    def test_calculate_proforma_profit_one_spec(self):
        date = '20201014'
        discount = {
            'lte__90': 15,
            'gt__90': 10,
        }

        modified_df, cost_file_name = helpers.prepare_data_frame_based_on_proforma_date(
            date)
        specs_profit = helpers.add_profit_to_specs(modified_df, [self.spec],
                                                   discount_dict=discount)
        specs_profit_split = helpers.split_specs_if_profit_exists(specs_profit)

        results = helpers.calculate_profit_of_proforma(
            specs_profit_split['specs_has_profit'])
        self.assertEqual(round(results['cost'], 2), 1758933976.00)
        self.assertEqual(round(results['price'], 2), 1800000000.00)
        self.assertEqual(round(results['profit'], 2), 41066024.00)
        self.assertEqual(round(results['percent'], 2), 2.33)
Пример #4
0
    def test_calculate_proforma_profit_temp(self):
        # todo: probably should be removed.
        date = '20201014'
        discount = {
            'lte__90': 15,
            'gt__90': 10,
        }

        modified_df, cost_file_name = helpers.prepare_data_frame_based_on_proforma_date(
            date)
        specs_profit = helpers.add_profit_to_specs(modified_df,
                                                   self.specs,
                                                   discount_dict=discount)
        specs_profit_split = helpers.split_specs_if_profit_exists(specs_profit)

        results = helpers.calculate_profit_of_proforma(
            specs_profit_split['specs_has_profit'])
        self.assertEqual(round(results['cost'], 2), 2018563926.40)
        self.assertEqual(round(results['price'], 2), 2072000000.00)
        self.assertEqual(round(results['profit'], 2), 53436073.60)
        self.assertEqual(round(results['percent'], 2), 2.65)
Пример #5
0
 def test_add_profit_to_specs(self):
     date = '20201014'
     discount = {
         'lte__90': 0,
         'gt__90': 10,
     }
     modified_df, cost_file_name = helpers.prepare_data_frame_based_on_proforma_date(
         date)
     specs_profit = helpers.add_profit_to_specs(modified_df,
                                                self.specs,
                                                discount_dict=discount)
     specs_profit_split = helpers.split_specs_if_profit_exists(specs_profit)
     self.assertEqual(len(specs_profit_split['specs_has_profit']), 2)
     self.assertEqual(len(specs_profit_split['specs_no_profit']), 3)
     self.assertEqual(
         round(specs_profit_split['specs_has_profit'][0]['price'], 2),
         900000000)
     self.assertEqual(
         round(specs_profit_split['specs_has_profit'][0]['profit'], 2),
         20533012.00)
     self.assertEqual(
         round(specs_profit_split['specs_has_profit'][0]['percent'], 2),
         2.33)
     self.assertEqual(
         round(specs_profit_split['specs_has_profit'][0]['total_cost'], 2),
         1758933976)
     self.assertEqual(
         round(specs_profit_split['specs_has_profit'][0]['total_price'], 2),
         1800000000)
     self.assertEqual(
         round(specs_profit_split['specs_has_profit'][0]['total_profit'],
               2), 41066024.00)
     self.assertEqual(
         round(specs_profit_split['specs_no_profit'][0]['price']),
         self.not_routine_specs[0]['price'])
     self.assertEqual(
         round(specs_profit_split['specs_no_profit'][0]['total_price']),
         self.not_routine_specs[0]['price'] *
         self.not_routine_specs[0]['qty'])