def npv_case1(self): annualCostsReduction = 751.5 yearlyPayments = 0.9 contractDuration = 10 npv_val = calculate_npv(nbu_rate, annualCostsReduction, yearlyPayments, contractDuration) self.assertEqual(npv_val, 698.444)
def npv_case4(self): annualCostsReduction = 75.15 yearlyPayments = 0.9 contractDuration = 2 npv_val = calculate_npv(nbu_rate, annualCostsReduction, yearlyPayments, contractDuration) self.assertEqual(npv_val, 234.309)
def npv_case3(self): annualCostsReduction = 225.45 yearlyPayments = 0.9 contractDuration = 4 npv_val = calculate_npv(nbu_rate, annualCostsReduction, yearlyPayments, contractDuration) self.assertEqual(npv_val, 499.595)
def npv_case2(self): annualCostsReduction = 300.6 yearlyPayments = 0.9 contractDuration = 6 npv_val = calculate_npv(nbu_rate, annualCostsReduction, yearlyPayments, contractDuration) self.assertEqual(npv_val, 483.978)
def validate_value(self, data, value): if value and isinstance(data['__parent__'], Model) and (data['__parent__'].status not in ('invalid', 'deleted', 'draft')) and data['relatedLot']: lots = [i for i in get_tender(data['__parent__']).lots if i.id == data['relatedLot']] if not lots: return lot = lots[0] tender = lot['__parent__'] amount = calculate_npv(tender.NBUdiscountRate, value.annualCostsReduction, value.yearlyPayments, value.contractDuration) #XXX: Calculating value.amount manually if lot.minValue.amount > amount: raise ValidationError(u"value of bid should be greater than minValue of lot") if lot.get('minValue').currency != value.currency: raise ValidationError(u"currency of bid should be identical to currency of minValue of lot") if lot.get('minValue').valueAddedTaxIncluded != value.valueAddedTaxIncluded: raise ValidationError(u"valueAddedTaxIncluded of bid should be identical to valueAddedTaxIncluded of minValue of lot")
def validate_value(self, data, value): if isinstance(data['__parent__'], Model): tender = data['__parent__'] if tender.lots: if value: raise ValidationError(u'value should be posted for each lot of bid') else: if not value: raise ValidationError(u'This field is required.') amount = calculate_npv(tender.NBUdiscountRate, value.annualCostsReduction, value.yearlyPayments, value.contractDuration) #XXX: Calculating value.amount manually if tender.minValue.amount > amount: raise ValidationError(u'value of bid should be greater than minValue of tender') if tender.get('minValue').currency != value.currency: raise ValidationError(u"currency of bid should be identical to currency of minValue of tender") if tender.get('minValue').valueAddedTaxIncluded != value.valueAddedTaxIncluded: raise ValidationError(u"valueAddedTaxIncluded of bid should be identical to valueAddedTaxIncluded of minValue of tender")
def amount_npv(self): """ Calculated energy service contract perfomance indicator """ return calculate_npv(get_root(self).NBUdiscountRate, self.annualCostsReduction, self.yearlyPayments, self.contractDuration)
put_tender_2lot_award_complaint_document, patch_tender_2lot_award_complaint_document, ) from openprocurement.tender.esco.utils import calculate_npv from openprocurement.tender.esco.tests.base import ( BaseESCOContentWebTest, test_bids, test_lots, NBU_DISCOUNT_RATE ) award_amount = calculate_npv(NBU_DISCOUNT_RATE, test_bids[0]['value']['annualCostsReduction'], test_bids[0]['value']['yearlyPayments'], test_bids[0]['value']['contractDuration']) class TenderAwardResourceTest(BaseESCOContentWebTest, TenderAwardResourceTestMixin): initial_status = 'active.tendering' initial_bids = test_bids initial_lots = test_lots initial_auth = ('Basic', ('broker', '')) expected_award_amount = award_amount def setUp(self): super(TenderAwardResourceTest, self).setUp() # switch to active.pre-qualification