Esempio n. 1
0
 def validate_region(self, data, value):
     root = get_root(data['__parent__'])
     apply_validation = get_first_revision_date(root, default=get_now()) >= VALIDATE_ADDRESS_FROM
     if self.doc_type_allowed(root) and self.validation_allowed(root) and apply_validation:
         if data["countryName"] == "Україна":
             if value and value not in UA_REGIONS:
                 raise ValidationError("field address:region not exist in ua_regions catalog")
Esempio n. 2
0
 def validate_currency(self, data, value):
     try:
         root = get_root(data.get("__parent__", {}))
     except AttributeError:
         root = None
     is_valid_date = get_first_revision_date(root, default=get_now()) >= VALIDATE_CURRENCY_FROM
     if is_valid_date and value not in CURRENCIES:
         raise ValidationError(f"Currency must be only {', '.join(CURRENCIES)}.")
Esempio n. 3
0
 def validate_countryName(self, data, value):
     root = get_root(data['__parent__'])
     apply_validation = get_first_revision_date(
         root, default=get_now()) >= VALIDATE_ADDRESS_FROM
     if self.doc_type_allowed(root) and self.validation_allowed(
             root) and apply_validation:
         if value not in COUNTRIES:
             raise ValidationError(
                 u"field address:countryName not exist in countries catalog"
             )
Esempio n. 4
0
def validate_classification_id(items, *args):
    for item in items:
        if get_first_revision_date(get_root(item["__parent__"]),
                                   default=get_now()) > CPV_336_INN_FROM:
            schemes = [x.scheme for x in item.additionalClassifications]
            schemes_inn_count = schemes.count(INN_SCHEME)
            if item.classification.id == CPV_PHARM_PRODUCTS and schemes_inn_count != 1:
                raise ValidationError(
                    u"Item with classification.id={} have to contain exactly one additionalClassifications "
                    u"with scheme={}".format(CPV_PHARM_PRODUCTS, INN_SCHEME))
            if item.classification.id.startswith(
                    CPV_PHARM_PRODUCTS[:3]) and schemes_inn_count > 1:
                raise ValidationError(
                    u"Item with classification.id that starts with {} and contains additionalClassification "
                    u"objects have to contain no more than one additionalClassifications "
                    u"with scheme={}".format(CPV_PHARM_PRODUCTS[:3],
                                             INN_SCHEME))
Esempio n. 5
0
 def validate_selfEligible(self, data, value):
     tender = get_root(data["__parent__"])
     if get_first_revision_date(tender, default=get_now()) > RELEASE_ECRITERIA_ARTICLE_17:
         if value is not None:
             raise ValidationError("Rogue field.")
Esempio n. 6
0
 def validate_code(self, data, value):
     root = get_root(data['__parent__'])
     validation_date = get_first_revision_date(root, default=get_now())
     if validation_date >= UNIT_PRICE_REQUIRED_FROM:
         if value not in UNIT_CODES:
             raise ValidationError(u"Code should be one of valid unit codes.")
Esempio n. 7
0
 def amount_npv(self):
     """ Calculated energy service contract perfomance indicator """
     return calculate_npv(get_root(self).NBUdiscountRate,
                          self.annualCostsReduction,
                          self.yearlyPayments,
                          self.contractDuration)