From 21745b21add6a925352663b3dc3cece01d1a6b0a Mon Sep 17 00:00:00 2001 From: annawzz Date: Thu, 19 Oct 2017 16:36:50 +0300 Subject: [PATCH 1/2] Enhance precision from 3 to 5 --- openprocurement/tender/esco/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openprocurement/tender/esco/models.py b/openprocurement/tender/esco/models.py index bd8072e..3a6d65a 100644 --- a/openprocurement/tender/esco/models.py +++ b/openprocurement/tender/esco/models.py @@ -100,12 +100,12 @@ class Options: minValue = ModelType(Value, required=False, default={'amount': 0, 'currency': 'UAH', 'valueAddedTaxIncluded': True}) minimalStep = ModelType(Value, required=False) # Not required, blocked for create/edit, since we have minimalStepPercentage in esco - minimalStepPercentage = DecimalType(required=True, min_value=Decimal('0.005'), max_value=Decimal('0.03')) + minimalStepPercentage = DecimalType(required=True, min_value=Decimal('0.005'), max_value=Decimal('0.03'), precision=-5) auctionPeriod = ModelType(LotAuctionPeriod, default={}) auctionUrl = URLType() guarantee = ModelType(Guarantee) fundingKind = StringType(choices=['budget', 'other'], required=True, default='other') - yearlyPaymentsPercentageRange = DecimalType(required=True, default=Decimal('0.8'), min_value=Decimal('0'), max_value=Decimal('1')) + yearlyPaymentsPercentageRange = DecimalType(required=True, default=Decimal('0.8'), min_value=Decimal('0'), max_value=Decimal('1'), precision=-5) @serializable def numberOfBids(self): @@ -176,7 +176,7 @@ class Options: amount = DecimalType(min_value=Decimal('0'), required=False, precision=-2) # Calculated energy service contract value. amountPerformance = DecimalType(required=False, precision=-2) # Calculated energy service contract performance indicator - yearlyPaymentsPercentage = DecimalType(required=True) # The percentage of annual payments in favor of Bidder + yearlyPaymentsPercentage = DecimalType(required=True, precision=-5) # The percentage of annual payments in favor of Bidder annualCostsReduction = ListType(DecimalType(), required=True) # Buyer's annual costs reduction contractDuration = ModelType(ContractDuration, required=True) @@ -342,7 +342,7 @@ class Options: awards = ListType(ModelType(Award), default=list()) contracts = ListType(ModelType(Contract), default=list()) minimalStep = ModelType(Value, required=False) # Not required, blocked for create/edit, since we have minimalStepPercentage in esco - minimalStepPercentage = DecimalType(required=True, min_value=Decimal('0.005'), max_value=Decimal('0.03')) + minimalStepPercentage = DecimalType(required=True, min_value=Decimal('0.005'), max_value=Decimal('0.03'), precision=-5) questions = ListType(ModelType(Question), default=list()) complaints = ListType(ComplaintModelType(Complaint), default=list()) auctionUrl = URLType() @@ -357,7 +357,7 @@ class Options: 'active.qualification', 'active.awarded', 'complete', 'cancelled', 'unsuccessful'], default='active.tendering') NBUdiscountRate = DecimalType(required=True, min_value=Decimal('0'), max_value=Decimal('0.99')) fundingKind = StringType(choices=['budget', 'other'], required=True, default='other') - yearlyPaymentsPercentageRange = DecimalType(required=True, default=Decimal('0.8'), min_value=Decimal('0'), max_value=Decimal('1')) + yearlyPaymentsPercentageRange = DecimalType(required=True, default=Decimal('0.8'), min_value=Decimal('0'), max_value=Decimal('1'), precision=-5) noticePublicationDate = IsoDateTimeType() create_accreditation = 3 From 675d4731d744a3ad39d90c87457318213d40b5ee Mon Sep 17 00:00:00 2001 From: annawzz Date: Thu, 19 Oct 2017 16:38:57 +0300 Subject: [PATCH 2/2] Add tests for checking precision --- openprocurement/tender/esco/tests/base.py | 10 +++++----- openprocurement/tender/esco/tests/bid_blanks.py | 10 ++++++++++ openprocurement/tender/esco/tests/tender_blanks.py | 8 ++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/openprocurement/tender/esco/tests/base.py b/openprocurement/tender/esco/tests/base.py index f210556..cf9d0b9 100644 --- a/openprocurement/tender/esco/tests/base.py +++ b/openprocurement/tender/esco/tests/base.py @@ -15,9 +15,9 @@ test_tender_data = deepcopy(base_eu_test_data) test_tender_data['procurementMethodType'] = "esco" test_tender_data['NBUdiscountRate'] = NBU_DISCOUNT_RATE -test_tender_data['minimalStepPercentage'] = 0.027 +test_tender_data['minimalStepPercentage'] = 0.02712 test_tender_data['fundingKind'] = 'other' -test_tender_data['yearlyPaymentsPercentageRange'] = 0.8 +test_tender_data['yearlyPaymentsPercentageRange'] = 0.80000 del test_tender_data['value'] del test_tender_data['minimalStep'] @@ -27,7 +27,7 @@ test_features_tender_data['NBUdiscountRate'] = NBU_DISCOUNT_RATE test_features_tender_data['minimalStepPercentage'] = 0.027 test_features_tender_data['fundingKind'] = 'other' -test_features_tender_data['yearlyPaymentsPercentageRange'] = 0.8 +test_features_tender_data['yearlyPaymentsPercentageRange'] = 0.80000 test_features_tender_data['features'][0]['enum'][0]['value'] = 0.03 test_features_tender_data['features'][0]['enum'][1]['value'] = 0.07 test_features_tender_data['features'][1]['enum'][0]['value'] = 0.03 @@ -40,9 +40,9 @@ test_lots = deepcopy(base_eu_lots) del test_lots[0]['value'] del test_lots[0]['minimalStep'] -test_lots[0]['minimalStepPercentage'] = 0.025 +test_lots[0]['minimalStepPercentage'] = 0.02514 test_lots[0]['fundingKind'] = 'other' -test_lots[0]['yearlyPaymentsPercentageRange'] = 0.8 +test_lots[0]['yearlyPaymentsPercentageRange'] = 0.80000 test_bids = deepcopy(base_eu_bids) for bid in test_bids: diff --git a/openprocurement/tender/esco/tests/bid_blanks.py b/openprocurement/tender/esco/tests/bid_blanks.py index b9ae6b2..f224f88 100644 --- a/openprocurement/tender/esco/tests/bid_blanks.py +++ b/openprocurement/tender/esco/tests/bid_blanks.py @@ -348,6 +348,16 @@ def patch_tender_bid(self): self.assertNotEqual(response.json['data']['value']['amount'], self.expected_bid_amount) self.assertNotEqual(response.json['data']['value']['amountPerformance'], self.expected_bid_amountPerformance) + response = self.app.patch_json('/tenders/{}/bids/{}?acc_token={}'.format(self.tender_id, bid['id'], bid_token), + {"data": {"value": {"yearlyPaymentsPercentage": 0.91111}, 'tenderers': self.test_bids_data[0]['tenderers']}}) + self.assertEqual(response.status, '200 OK') + self.assertEqual(response.content_type, 'application/json') + self.assertNotEqual(response.json['data']['value'], bid['value']) + self.assertEqual(response.json['data']['tenderers'][0]['name'], bid['tenderers'][0]['name']) + self.assertEqual(response.json['data']['value']['yearlyPaymentsPercentage'], 0.91111) + self.assertNotEqual(response.json['data']['value']['amount'], self.expected_bid_amount) + self.assertNotEqual(response.json['data']['value']['amountPerformance'], self.expected_bid_amountPerformance) + response = self.app.patch_json('/tenders/{}/bids/some_id?acc_token={}'.format(self.tender_id, bid_token), {"data": {"value": {"amount": 400}}}, status=404) self.assertEqual(response.status, '404 Not Found') diff --git a/openprocurement/tender/esco/tests/tender_blanks.py b/openprocurement/tender/esco/tests/tender_blanks.py index 57824fc..fe0055d 100644 --- a/openprocurement/tender/esco/tests/tender_blanks.py +++ b/openprocurement/tender/esco/tests/tender_blanks.py @@ -135,10 +135,10 @@ def tender_yearlyPaymentsPercentageRange(self): tender_id = response.json['data']['id'] tender_token = response.json['access']['token'] - response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, tender_token), {"data": {"fundingKind": "budget", "yearlyPaymentsPercentageRange": 0.3}}) + response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, tender_token), {"data": {"fundingKind": "budget", "yearlyPaymentsPercentageRange": 0.31456}}) self.assertEqual(response.status, '200 OK') self.assertEqual(response.json['data']['fundingKind'], 'budget') - self.assertEqual(response.json['data']['yearlyPaymentsPercentageRange'], 0.3) + self.assertEqual(response.json['data']['yearlyPaymentsPercentageRange'], 0.31456) response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, tender_token), {"data": {"fundingKind": "other"}}, status=422) self.assertEqual(response.status, '422 Unprocessable Entity') @@ -809,9 +809,9 @@ def patch_tender(self): self.assertEqual(response.status, '200 OK') self.assertEqual(response.json['data']['guarantee']['currency'], 'USD') - response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender['id'], owner_token), {"data": {"minimalStepPercentage": 0.025}}) + response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender['id'], owner_token), {"data": {"minimalStepPercentage": 0.02516}}) self.assertEqual(response.status, '200 OK') - self.assertEqual(response.json['data']['minimalStepPercentage'], 0.025) + self.assertEqual(response.json['data']['minimalStepPercentage'], 0.02516) response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender['id'], owner_token), {"data": {"fundingKind": "budget"}}) self.assertEqual(response.status, '200 OK')