Skip to content

Commit

Permalink
Merge branch 'a457306850524443_yppr_and_minStepPercentage_precision'
Browse files Browse the repository at this point in the history
  • Loading branch information
annawzz committed Oct 19, 2017
2 parents 6aad090 + 675d473 commit 6161634
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
10 changes: 5 additions & 5 deletions openprocurement/tender/esco/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand All @@ -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'), precision=-5)
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)
submissionMethodDetails = StringType(default="quick(mode:no-auction)") # TODO: temporary decision, while esco auction is not ready. Remove after adding auction. Remove function "check_submission_method_details" in openprocurement.tender.esco.subscribers
noticePublicationDate = IsoDateTimeType()

Expand Down
10 changes: 5 additions & 5 deletions openprocurement/tender/esco/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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
Expand All @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions openprocurement/tender/esco/tests/bid_blanks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions openprocurement/tender/esco/tests/tender_blanks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 6161634

Please sign in to comment.