def test_calculations(self): for i, val in enumerate(self.test_data['input']): self.bid.update(val) amount_perfomance = npv( self.bid['contractDuration']['years'], self.bid['contractDuration']['days'], self.bid['yearlyPaymentsPercentage'], self.bid['annualCostsReduction'], self.bid['announcementDate'], self.bid['NBUdiscountRate'], ) self.assertTrue(isinstance(amount_perfomance, Fraction)) expected = self.test_data['expected_results'][i][ 'amountPerformance'] self.assertEqual(humanize(amount_perfomance), expected) amount_contract = escp( self.bid['contractDuration']['years'], self.bid['contractDuration']['days'], self.bid['yearlyPaymentsPercentage'], self.bid['annualCostsReduction'], self.bid['announcementDate'], ) self.assertTrue(isinstance(amount_contract, Fraction)) expected = self.test_data['expected_results'][i]['amountContract'] self.assertEqual(humanize(amount_contract), expected)
def amount_escp(self): return to_decimal( escp( self.contractDuration.years, self.contractDuration.days, self.yearlyPaymentsPercentage, self.annualCostsReduction, get_tender(self).noticePublicationDate, ))
test_bids[0]["value"]["contractDuration"]["years"], test_bids[0]["value"]["contractDuration"]["days"], test_bids[0]["value"]["yearlyPaymentsPercentage"], test_bids[0]["value"]["annualCostsReduction"], get_now(), NBU_DISCOUNT_RATE, )), 2, ) lot_bid_amount = round( to_decimal( escp( test_bids[0]["value"]["contractDuration"]["years"], test_bids[0]["value"]["contractDuration"]["days"], test_bids[0]["value"]["yearlyPaymentsPercentage"], test_bids[0]["value"]["annualCostsReduction"], get_now(), )), 2, ) class TenderLotResourceTest(BaseESCOContentWebTest): initial_auth = ("Basic", ("broker", "")) test_lots_data = test_lots # TODO: change attribute identifier test_bids = test_bids initial_data = test_tender_data test_create_tender_lot_invalid = snitch(create_tender_lot_invalid)
bids_invalidation_on_lot_change, ) from openprocurement.tender.esco.utils import to_decimal lot_bid_amountPerformance = round( to_decimal( npv(test_bids[0]['value']['contractDuration']['years'], test_bids[0]['value']['contractDuration']['days'], test_bids[0]['value']['yearlyPaymentsPercentage'], test_bids[0]['value']['annualCostsReduction'], get_now(), NBU_DISCOUNT_RATE)), 2) lot_bid_amount = round( to_decimal( escp(test_bids[0]['value']['contractDuration']['years'], test_bids[0]['value']['contractDuration']['days'], test_bids[0]['value']['yearlyPaymentsPercentage'], test_bids[0]['value']['annualCostsReduction'], get_now())), 2) class TenderLotResourceTest(BaseESCOContentWebTest): initial_auth = ('Basic', ('broker', '')) test_lots_data = test_lots # TODO: change attribute identifier test_bids = test_bids initial_data = test_tender_data test_create_tender_lot_invalid = snitch(create_tender_lot_invalid) test_create_tender_lot = snitch(create_tender_lot) test_lot_yppr_validation = snitch(lot_yppr_validation) test_patch_tender_lot = snitch(patch_tender_lot) test_patch_tender_lot_minValue = snitch(patch_tender_lot_minValue)
def amount_escp(self): return float(escp(self.contractDuration.years, self.contractDuration.days, self.yearlyPaymentsPercentage, self.annualCostsReduction, get_tender(self).__class__.announcementDate or get_tender(self).enquiryPeriod.startDate))