Measures

Business rules for measures.

class measures.business_rules.ActionRequiresDuty(transaction=None)[source]

If a condition’s action code requires a duty, then an associated condition component must be created with a duty amount.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If a condition’s action code requires a duty, then an associated condition component must be created with a duty amount.

validate(condition)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ComponentApplicability(transaction=None)[source]

Rule enforcing component applicability.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

Rule enforcing component applicability.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ConditionCodeAcceptance(transaction=None)[source]

If a condition has a certificate, then the condition’s code must accept a certificate.

If a condition has a duty amount, then the condition’s code must accept a price.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If a condition has a certificate, then the condition’s code must accept a certificate.

If a condition has a duty amount, then the condition’s code must accept a price.

validate(condition)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.MA1(transaction=None)[source]

The code of the measure action must be unique.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The code of the measure action must be unique.

class measures.business_rules.MA2(transaction=None)[source]

The measure action cannot be deleted if it is used in a measure condition component.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The measure action cannot be deleted if it is used in a measure condition component.

class measures.business_rules.MA4(transaction=None)[source]

If a measure action is used in a measure then the validity period of the measure action must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If a measure action is used in a measure then the validity period of the measure action must span the validity period of the measure.

class measures.business_rules.MC1(transaction=None)[source]

The code of the measure condition code must be unique.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The code of the measure condition code must be unique.

class measures.business_rules.MC3(transaction=None)[source]

If a measure condition code is used in a measure then the validity period of the measure condition code must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If a measure condition code is used in a measure then the validity period of the measure condition code must span the validity period of the measure.

class measures.business_rules.MC4(transaction=None)[source]

The measure condition code cannot be deleted if it is used in a measure condition component.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The measure condition code cannot be deleted if it is used in a measure condition component.

class measures.business_rules.ME1(transaction=None)[source]

The combination of measure type, geographical area, goods nomenclature item id, additional code type, additional code, order number, reduction indicator and start date must be unique.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The combination of measure type, geographical area, goods nomenclature item id, additional code type, additional code, order number, reduction indicator and start date must be unique.

class measures.business_rules.ME10(transaction=None)[source]

The order number must be specified if the “order number flag” (specified in the measure type record) has the value “mandatory”.

If the flag is set to “not permitted” then the field cannot be entered.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The order number must be specified if the “order number flag” (specified in the measure type record) has the value “mandatory”.

If the flag is set to “not permitted” then the field cannot be entered.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME104(transaction=None)[source]

The justification regulation must be either:

  • the measure’s measure-generating regulation, or

  • a measure-generating regulation, valid on the day after the measure’s (explicit) end date.

If the measure’s measure-generating regulation is ‘approved’, then so must be the justification regulation.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The justification regulation must be either:

  • the measure’s measure-generating regulation, or

  • a measure-generating regulation, valid on the day after the measure’s (explicit) end date.

If the measure’s measure-generating regulation is ‘approved’, then so must be the justification regulation.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME105(transaction=None)[source]

The referenced duty expression must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced duty expression must exist.

class measures.business_rules.ME106(transaction=None)[source]

The validity period of the duty expression must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the duty expression must span the validity period of the measure.

class measures.business_rules.ME108(transaction=None)[source]

The same duty expression can only be used once within condition components of the same condition of the same measure.

(i.e. it can be re-used in other conditions, no matter what condition type, of the same measure).

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The same duty expression can only be used once within condition components of the same condition of the same measure.

(i.e. it can be re-used in other conditions, no matter what condition type, of the same measure).

validate(component)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME109(transaction=None)[source]

If the flag ‘amount’ on duty expression is ‘mandatory’ then an amount must be specified.

If the flag is set to ‘not permitted’ then no amount may be entered.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the flag ‘amount’ on duty expression is ‘mandatory’ then an amount must be specified.

If the flag is set to ‘not permitted’ then no amount may be entered.

class measures.business_rules.ME110(transaction=None)[source]

If the flag ‘monetary unit’ on duty expression is ‘mandatory’ then a monetary unit must be specified.

If the flag is set to ‘not permitted’ then no monetary unit may be entered.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the flag ‘monetary unit’ on duty expression is ‘mandatory’ then a monetary unit must be specified.

If the flag is set to ‘not permitted’ then no monetary unit may be entered.

class measures.business_rules.ME111(transaction=None)[source]

If the flag ‘measurement unit’ on duty expression is ‘mandatory’ then a measurement unit must be specified.

If the flag is set to ‘not permitted’ then no measurement unit may be entered.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the flag ‘measurement unit’ on duty expression is ‘mandatory’ then a measurement unit must be specified.

If the flag is set to ‘not permitted’ then no measurement unit may be entered.

class measures.business_rules.ME115(transaction=None)[source]

The validity period of the referenced additional code must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the referenced additional code must span the validity period of the measure.

class measures.business_rules.ME116(transaction=None)[source]

When a quota order number is used in a measure then the validity period of the quota order number must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

When a quota order number is used in a measure then the validity period of the quota order number must span the validity period of the measure.

validate(model)

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME117(transaction=None)[source]

When a measure has a quota measure type then the origin must exist as a quota order number origin.

Only origins for quota order numbers managed by the first come first served principle are in scope; these order number are starting with ‘09’; except order numbers starting with ‘094’.

Quota measure types are the following:

122 - Non preferential tariff quota 123 - Non preferential tariff quota under end-use 143 - Preferential tariff quota 146 - Preferential tariff quota under end-use 147 - Customs Union Quota

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

When a measure has a quota measure type then the origin must exist as a quota order number origin.

Only origins for quota order numbers managed by the first come first served principle are in scope; these order number are starting with ‘09’; except order numbers starting with ‘094’.

Quota measure types are the following:

122 - Non preferential tariff quota 123 - Non preferential tariff quota under end-use 143 - Preferential tariff quota 146 - Preferential tariff quota under end-use 147 - Customs Union Quota

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME119(transaction=None)[source]

When a quota order number is used in a measure then the validity period of the quota order number origin must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

When a quota order number is used in a measure then the validity period of the quota order number origin must span the validity period of the measure.

validate(measure)[source]

Get all current QuotaOrderNumberOrigin objects associated with a measure’s QuotaOrderNumber.

Loop over these and raise a violation if the measure validity period is not contained by any of the origins

class measures.business_rules.ME12(transaction=None)[source]

If the additional code is specified then the additional code type must have a relationship with the measure type.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the additional code is specified then the additional code type must have a relationship with the measure type.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME16(transaction=None)[source]

Integrating a measure with an additional code when an equivalent or overlapping measures without additional code already exists and vice-versa, should be forbidden.

Note :

Our understanding is that this should behave like ME32 with except checking for the inverse of the presence of the additional code.

This is based on our understanding of the intention and the poor wording of the business rule and the use of the word “should” are indicators that the language of this rule has not been through the same scrutiny as other similar rules.

Interpreted meaning:
Clashing measures :

Has a goods code in the same nomenclature hierarchy which references the same measure type, geo area, order number and reduction indicator and has no additional code, where one is defined on the validating measure or vice versa.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

Integrating a measure with an additional code when an equivalent or overlapping measures without additional code already exists and vice-versa, should be forbidden.

Note :

Our understanding is that this should behave like ME32 with except checking for the inverse of the presence of the additional code.

This is based on our understanding of the intention and the poor wording of the business rule and the use of the word “should” are indicators that the language of this rule has not been through the same scrutiny as other similar rules.

Interpreted meaning:
Clashing measures :

Has a goods code in the same nomenclature hierarchy which references the same measure type, geo area, order number and reduction indicator and has no additional code, where one is defined on the validating measure or vice versa.

clashing_measures(measure) measures.querysets.MeasuresQuerySet[source]

Returns all the measures that clash with the passed measure over its lifetime.

Two measures clash if all their fields listed in this business rule description are equal, their date ranges overlap, and one of their commodity codes is an ancestor or equal to the other.

static query_similar_measures(measure)[source]

Query measures where measure type, geo area, reduction, order number (or dead order number) match and additional code is null when the target measure has a populated additional code, or is not null when the target measure has a null additional code.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME17(transaction=None)[source]

If the additional code type has as application “non-Meursing” then the additional code must exist as a non-Meursing additional code.

UK tariff does not use meursing tables, so this is essentially saying that an additional code must exist.

This refers to the fact that the TARIC Measure record has separate additional_code_type and additional_code fields. Our data model combines these into a single foreign key relation to AdditionalCode.

It is not possible to violate this rule as a result.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the additional code type has as application “non-Meursing” then the additional code must exist as a non-Meursing additional code.

UK tariff does not use meursing tables, so this is essentially saying that an additional code must exist.

This refers to the fact that the TARIC Measure record has separate additional_code_type and additional_code fields. Our data model combines these into a single foreign key relation to AdditionalCode.

It is not possible to violate this rule as a result.

class measures.business_rules.ME2(transaction=None)[source]

The measure type must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The measure type must exist.

class measures.business_rules.ME24(transaction=None)[source]

The role + regulation id must exist.

If no measure start date is specified it defaults to the regulation start date.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The role + regulation id must exist.

If no measure start date is specified it defaults to the regulation start date.

class measures.business_rules.ME25(transaction=None)[source]

If the measure’s end date is specified (implicitly or explicitly) then the start date of the measure must be less than or equal to the end date.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the measure’s end date is specified (implicitly or explicitly) then the start date of the measure must be less than or equal to the end date.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME27(transaction=None)[source]

The entered regulation may not be fully replaced.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The entered regulation may not be fully replaced.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME3(transaction=None)[source]

The validity period of the measure type must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the measure type must span the validity period of the measure.

class measures.business_rules.ME32(transaction=None)[source]

There may be no overlap in time with other measure occurrences with a goods code in the same nomenclature hierarchy which references the same measure type, geo area, order number, additional code and reduction indicator.

This rule is not applicable for Meursing additional codes.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

There may be no overlap in time with other measure occurrences with a goods code in the same nomenclature hierarchy which references the same measure type, geo area, order number, additional code and reduction indicator.

This rule is not applicable for Meursing additional codes.

clashing_measures(measure) measures.querysets.MeasuresQuerySet[source]

Returns all of the measures that clash with the passed measure over its lifetime.

Two measures clash if any of their fields listed in this business rule description are equal, their date ranges overlap, and one of their commodity codes is an ancestor or equal to the other.

compile_query(measure)[source]

Create a query that can be applied in a MeasureQuerySet.filter() expression to find Measure instances that match measure for the purpose of ME32 checking.

For instance, matching Measure`s will be of the same measure type, have the same geographical area and the same reduction. Matching measures will also be matched depending upon `measure’s order_number, dead order number and additional code.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME33(transaction=None)[source]

A justification regulation may not be entered if the measure end date is not filled in.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

A justification regulation may not be entered if the measure end date is not filled in.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME34(transaction=None)[source]

A justification regulation must be entered if the measure end date is filled in.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

A justification regulation must be entered if the measure end date is filled in.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME4(transaction=None)[source]

The geographical area must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The geographical area must exist.

class measures.business_rules.ME40(transaction=None)[source]

If the flag “duty expression” on measure type is “mandatory” then at least one measure component or measure condition component record must be specified. If the flag is set “not permitted” then no measure component or measure condition component must exist. Measure components and measure condition components are mutually exclusive. A measure can have either components or condition components (if the “duty expression” flag is “mandatory” or “optional”) but not both.

This describes the fact that measures of certain types MUST have components (duties) assigned to them, whereas others must not. Note the sub-clause also – if the value of the field “Component applicable” is set to 1 (mandatory) on a measure type, then when the measure is created, there must be either measure components or measure condition components assigned to the measure, but not both. CDS will generate errors if either of these conditions are not met.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the flag “duty expression” on measure type is “mandatory” then at least one measure component or measure condition component record must be specified. If the flag is set “not permitted” then no measure component or measure condition component must exist. Measure components and measure condition components are mutually exclusive. A measure can have either components or condition components (if the “duty expression” flag is “mandatory” or “optional”) but not both.

This describes the fact that measures of certain types MUST have components (duties) assigned to them, whereas others must not. Note the sub-clause also – if the value of the field “Component applicable” is set to 1 (mandatory) on a measure type, then when the measure is created, there must be either measure components or measure condition components assigned to the measure, but not both. CDS will generate errors if either of these conditions are not met.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME41(transaction=None)[source]

The referenced duty expression must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced duty expression must exist.

class measures.business_rules.ME42(transaction=None)[source]

The validity period of the duty expression must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the duty expression must span the validity period of the measure.

class measures.business_rules.ME43(transaction=None)[source]

The same duty expression can only be used once with the same measure.

Even if an expression that (in English) reads the same needs to be used more than once in a measure, we must use a different expression ID, never the same one twice.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The same duty expression can only be used once with the same measure.

Even if an expression that (in English) reads the same needs to be used more than once in a measure, we must use a different expression ID, never the same one twice.

validate(measure_component)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME45(transaction=None)[source]

If the flag “amount” on duty expression is “mandatory” then an amount must be specified.

If the flag is set “not permitted” then no amount may be entered.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the flag “amount” on duty expression is “mandatory” then an amount must be specified.

If the flag is set “not permitted” then no amount may be entered.

class measures.business_rules.ME46(transaction=None)[source]

If the flag “monetary unit” on duty expression is “mandatory” then a monetary unit must be specified.

If the flag is set “not permitted” then no monetary unit may be entered.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the flag “monetary unit” on duty expression is “mandatory” then a monetary unit must be specified.

If the flag is set “not permitted” then no monetary unit may be entered.

class measures.business_rules.ME47(transaction=None)[source]

If the flag “measurement unit” on duty expression is “mandatory” then a measurement unit must be specified.

If the flag is set “not permitted” then no measurement unit may be entered.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If the flag “measurement unit” on duty expression is “mandatory” then a measurement unit must be specified.

If the flag is set “not permitted” then no measurement unit may be entered.

class measures.business_rules.ME48(transaction=None)[source]

The referenced monetary unit must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced monetary unit must exist.

class measures.business_rules.ME49(transaction=None)[source]

The validity period of the referenced monetary unit must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the referenced monetary unit must span the validity period of the measure.

class measures.business_rules.ME5(transaction=None)[source]

The validity period of the geographical area must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the geographical area must span the validity period of the measure.

class measures.business_rules.ME50(transaction=None)[source]

The combination measurement unit + measurement unit qualifier must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The combination measurement unit + measurement unit qualifier must exist.

class measures.business_rules.ME51(transaction=None)[source]

The validity period of the measurement unit must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the measurement unit must span the validity period of the measure.

class measures.business_rules.ME52(transaction=None)[source]

The validity period of the measurement unit qualifier must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the measurement unit qualifier must span the validity period of the measure.

class measures.business_rules.ME53(transaction=None)[source]

The referenced measure condition must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced measure condition must exist.

class measures.business_rules.ME56(transaction=None)[source]

The referenced certificate must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced certificate must exist.

class measures.business_rules.ME57(transaction=None)[source]

The validity period of the referenced certificate must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the referenced certificate must span the validity period of the measure.

class measures.business_rules.ME58(transaction=None)[source]

The same certificate, volume or price can only be referenced once by the same measure and the same condition type.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The same certificate, volume or price can only be referenced once by the same measure and the same condition type.

validate(measure_condition)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME59(transaction=None)[source]

The referenced action code must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced action code must exist.

class measures.business_rules.ME6(transaction=None)[source]

The goods code must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The goods code must exist.

class measures.business_rules.ME60(transaction=None)[source]

The referenced monetary unit must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced monetary unit must exist.

class measures.business_rules.ME61(transaction=None)[source]

The validity period of the referenced monetary unit must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the referenced monetary unit must span the validity period of the measure.

class measures.business_rules.ME62(transaction=None)[source]

The combination measurement unit + measurement unit qualifier must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The combination measurement unit + measurement unit qualifier must exist.

class measures.business_rules.ME63(transaction=None)[source]

The validity period of the measurement unit must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the measurement unit must span the validity period of the measure.

class measures.business_rules.ME64(transaction=None)[source]

The validity period of the measurement unit qualifier must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the measurement unit qualifier must span the validity period of the measure.

class measures.business_rules.ME65(transaction=None)[source]

An exclusion can only be entered if the measure is applicable to a geographical area group (area code = 1).

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

An exclusion can only be entered if the measure is applicable to a geographical area group (area code = 1).

validate(exclusion)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME66(transaction=None)[source]

The excluded geographical area must be a member of the geographical area group.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The excluded geographical area must be a member of the geographical area group.

class measures.business_rules.ME67(transaction=None)[source]

The membership period of the excluded geographical area must span the valid period of the measure.

interpretation: When a measure has a geo-area exclusion, the valid between date range of the measure is used to check the existence of the excluded geo area in the geo group the measure is linked to (a member of the geo area group), if the members validity date range does not match or extend beyond the measures valid between date range then the change is considered invalid and a violation should be raised.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The membership period of the excluded geographical area must span the valid period of the measure.

interpretation: When a measure has a geo-area exclusion, the valid between date range of the measure is used to check the existence of the excluded geo area in the geo group the measure is linked to (a member of the geo area group), if the members validity date range does not match or extend beyond the measures valid between date range then the change is considered invalid and a violation should be raised.

validate(exclusion)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME68(transaction=None)[source]

The same geographical area can only be excluded once by the same measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The same geographical area can only be excluded once by the same measure.

validate(exclusion)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME69(transaction=None)[source]

The associated footnote must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The associated footnote must exist.

class measures.business_rules.ME7(transaction=None)[source]

The goods nomenclature code must be a product code.

It may not be an intermediate line.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The goods nomenclature code must be a product code.

It may not be an intermediate line.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME70(transaction=None)[source]

The same footnote can only be associated once with the same measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The same footnote can only be associated once with the same measure.

validate(association)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME71(transaction=None)[source]

Footnotes with a footnote type for which the application type = “CN footnotes” cannot be associated with TARIC codes (codes with pos 9-10 different from 00).

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

Footnotes with a footnote type for which the application type = “CN footnotes” cannot be associated with TARIC codes (codes with pos 9-10 different from 00).

class measures.business_rules.ME73(transaction=None)[source]

The validity period of the associated footnote must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the associated footnote must span the validity period of the measure.

class measures.business_rules.ME8(transaction=None)[source]

The validity period of the goods code must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the goods code must span the validity period of the measure.

class measures.business_rules.ME87(transaction=None)[source]

The validity period of the measure (implicit or explicit) must reside within the effective validity period of its supporting regulation.

The effective validity period is the validity period of the regulation taking into account extensions and abrogation.

A regulation’s validity period is hugely complex in the EU’s world.

  • A regulation is initially assigned a start date. It may be assigned an end date as well at the point of creation but this is rare.

  • The EU then may choose to end date the regulation using its end date field – in this case provision must be made to end date all of the measures that would otherwise extend beyond the end of this regulation end date.

  • The EU may also choose to end date the measure (regulation?) via 2 other means which we are abandoning (abrogation and prorogation).

  • Only the measure validity end date and the regulation validity end date field will need to be compared in the UK Tariff. However, in terminating measures from the EU tariff to make way for UK equivalents, and to avoid data clashes such as ME32, we DO need to be aware of this multiplicity of end dates.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the measure (implicit or explicit) must reside within the effective validity period of its supporting regulation.

The effective validity period is the validity period of the regulation taking into account extensions and abrogation.

A regulation’s validity period is hugely complex in the EU’s world.

  • A regulation is initially assigned a start date. It may be assigned an end date as well at the point of creation but this is rare.

  • The EU then may choose to end date the regulation using its end date field – in this case provision must be made to end date all of the measures that would otherwise extend beyond the end of this regulation end date.

  • The EU may also choose to end date the measure (regulation?) via 2 other means which we are abandoning (abrogation and prorogation).

  • Only the measure validity end date and the regulation validity end date field will need to be compared in the UK Tariff. However, in terminating measures from the EU tariff to make way for UK equivalents, and to avoid data clashes such as ME32, we DO need to be aware of this multiplicity of end dates.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME88(transaction=None)[source]

The level of the goods code cannot exceed the explosion level of the measure type.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The level of the goods code cannot exceed the explosion level of the measure type.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.ME9(transaction=None)[source]

If no additional code is specified then the goods code is mandatory.

A measure can be assigned to:

  • a commodity code only (most measures)

  • a commodity code plus an additional code (e.g. trade remedies, pharma duties, routes of ingress)

  • an additional code only (only for Meursing codes, which will be removed in the UK tariff).

This means that a goods code is always mandatory in the UK tariff, however this business rule is still needed for historical EU measures.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

If no additional code is specified then the goods code is mandatory.

A measure can be assigned to:

  • a commodity code only (most measures)

  • a commodity code plus an additional code (e.g. trade remedies, pharma duties, routes of ingress)

  • an additional code only (only for Meursing codes, which will be removed in the UK tariff).

This means that a goods code is always mandatory in the UK tariff, however this business rule is still needed for historical EU measures.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class measures.business_rules.MT1(transaction=None)[source]

The measure type code must be unique.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The measure type code must be unique.

class measures.business_rules.MT10(transaction=None)[source]

The validity period of the measure type series must span the validity period of the measure type.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The validity period of the measure type series must span the validity period of the measure type.

class measures.business_rules.MT3(transaction=None)[source]

When a measure type is used in a measure then the validity period of the measure type must span the validity period of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

When a measure type is used in a measure then the validity period of the measure type must span the validity period of the measure.

class measures.business_rules.MT4(transaction=None)[source]

The referenced measure type series must exist.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The referenced measure type series must exist.

class measures.business_rules.MT7(transaction=None)[source]

A measure type cannot be deleted if it is in use in a measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

A measure type cannot be deleted if it is in use in a measure.

class measures.business_rules.MTS1(transaction=None)[source]

The measure type series must be unique.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The measure type series must be unique.

class measures.business_rules.MTS2(transaction=None)[source]

The measure type series cannot be deleted if it is associated with a measure type.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

The measure type series cannot be deleted if it is associated with a measure type.

class measures.business_rules.MeasureComponentApplicability(transaction=None)[source]
exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)
class measures.business_rules.MeasureConditionComponentApplicability(transaction=None)[source]
exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)
class measures.business_rules.QuotaOriginMatchingArea(transaction=None)[source]

When a quota order number is used in a measure then the quota order number origin’s geographical area(s) must match those of the measure.

exception Violation(model: common.models.trackedmodel.TrackedModel, message: Optional[str] = None)

When a quota order number is used in a measure then the quota order number origin’s geographical area(s) must match those of the measure.

validate(measure)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses