Quotas

Business rules for quotas.

class quotas.business_rules.BlockingOnlyOfFCFSQuotas(transaction=None)[source]

Blocking periods are only applicable to FCFS quotas.

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

Blocking periods are only applicable to FCFS quotas.

validate(blocking)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.CertificateValidityPeriodMustSpanQuotaOrderNumber(transaction=None)[source]

The validity period of the required certificates must span the validity period of the quota order number.

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

The validity period of the required certificates must span the validity period of the quota order number.

class quotas.business_rules.CertificatesMustExist(transaction=None)[source]

The referenced certificates must exist.

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

The referenced certificates must exist.

class quotas.business_rules.ON1(transaction=None)[source]

Quota order number id + start date must be unique.

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

Quota order number id + start date must be unique.

class quotas.business_rules.ON10(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(order_number_origin)[source]

Loop over measures that reference the same quota order number as origin.

Get all the origins linked to this measure. Loop over these origins and check that every measure is contained by at least one origin.

class quotas.business_rules.ON11(transaction=None)[source]

The quota order number cannot be deleted if it is used in a measure.

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

The quota order number cannot be deleted if it is used in a measure.

validate(model)

Check whether the specified model violates this business rule.

Parameters

TrackedModel (model) – The model to check

Raises

BusinessRuleViolation – Raised if the passed model violates this business rule.

class quotas.business_rules.ON12(transaction=None)[source]

The quota order number origin cannot be deleted if it is used in a measure.

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

The quota order number origin cannot be deleted if it is used in a measure.

validate(order_number_origin)[source]

Loop over measures that reference the same quota order number as origin.

Get all the origins linked to this measure. Loop over these origins and check that there are no measures linked to the origin .

class quotas.business_rules.ON13(transaction=None)[source]

An exclusion can only be entered if the order number origin is 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 order number origin is a geographical area group (area code = 1).

validate(exclusion)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.ON14(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 quotas.business_rules.ON2(transaction=None)[source]

There may be no overlap in time of two quota order numbers with the same quota order number id.

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

There may be no overlap in time of two quota order numbers with the same quota order number id.

validate(order_number)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.ON4(transaction=None)[source]

The referenced geographical area must exist.

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

The referenced geographical area must exist.

validate(order_number)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.ON5(transaction=None)[source]

There may be no overlap in time of two quota order number origins with the same quota order number SID and geographical area id.

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

There may be no overlap in time of two quota order number origins with the same quota order number SID and geographical area id.

validate(origin)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.ON6(transaction=None)[source]

The validity period of the geographical area must span the validity period of the quota order number origin.

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 quota order number origin.

validate(model)

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.ON7(transaction=None)[source]

The validity period of the quota order number must span the validity period of the quota order number origin.

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

The validity period of the quota order number must span the validity period of the quota order number origin.

class quotas.business_rules.ON8(transaction=None)[source]

The validity period of the quota order number must span the validity period of the referencing quota definition.

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

The validity period of the quota order number must span the validity period of the referencing quota definition.

class quotas.business_rules.ON9(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 quotas.business_rules.OverlappingQuotaDefinition(transaction=None)[source]

There may be no overlap in time of two quota definitions with the same quota order number id.

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

There may be no overlap in time of two quota definitions with the same quota order number id.

validate(quota_definition)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.PreventDeletingLinkedQuotaDefinitions(transaction=None)[source]

A deleted Quota Definition must not be referred to by a non-deleted relation.

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

A deleted Quota Definition must not be referred to by a non-deleted relation.

validate(quota_definition)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.PreventQuotaDefinitionDeletion(transaction=None)[source]

A Quota Definition cannot be deleted once the start date is in the past.

The Quota Definition may be end-dated instead.

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

A Quota Definition cannot be deleted once the start date is in the past.

The Quota Definition may be end-dated instead.

validate(quota_definition)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.QA1(transaction=None)[source]

The association between two quota definitions must be unique.

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

The association between two quota definitions must be unique.

class quotas.business_rules.QA2(transaction=None)[source]

The sub-quota’s validity period must be entirely enclosed within the validity period of the main quota.

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

The sub-quota’s validity period must be entirely enclosed within the validity period of the main quota.

class quotas.business_rules.QA3(transaction=None)[source]

When converted to the measurement unit of the main quota, the volume of a sub-quota must always be lower than or equal to the volume of the main quota.

(The wording of this rule implies that quotas with different units can be linked together and there is no business rule that prevents this from happening. However, historically there have been no quotas where the units have been different and we should maintain this going forward as the system has no conversion ratios or other way of relating units to each other.)

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

When converted to the measurement unit of the main quota, the volume of a sub-quota must always be lower than or equal to the volume of the main quota.

(The wording of this rule implies that quotas with different units can be linked together and there is no business rule that prevents this from happening. However, historically there have been no quotas where the units have been different and we should maintain this going forward as the system has no conversion ratios or other way of relating units to each other.)

validate(association)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.QA4(transaction=None)[source]

Whenever a sub-quota receives a coefficient, this has to be a strictly positive decimal number.

When it is not specified a value 1 is always assumed.

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

Whenever a sub-quota receives a coefficient, this has to be a strictly positive decimal number.

When it is not specified a value 1 is always assumed.

validate(association)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.QA5(transaction=None)[source]

Whenever a sub-quota is defined with the ‘equivalent’ type, it must have the same volume as the ones associated with the parent quota.

Moreover it must be defined with a coefficient not equal to 1. A sub-quota defined with the ‘normal’ type must have a coefficient of 1.

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

Whenever a sub-quota is defined with the ‘equivalent’ type, it must have the same volume as the ones associated with the parent quota.

Moreover it must be defined with a coefficient not equal to 1. A sub-quota defined with the ‘normal’ type must have a coefficient of 1.

validate(association)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.QA6(transaction=None)[source]

Sub-quotas associated with the same main quota must have the same relation type.

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

Sub-quotas associated with the same main quota must have the same relation type.

validate(association)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.QBP2(transaction=None)[source]

The start date of the quota blocking period must be later than or equal to the start date of the quota validity period.

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

The start date of the quota blocking period must be later than or equal to the start date of the quota validity period.

validate(blocking)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.QD1(transaction=None)[source]

Quota order number id + start date must be unique.

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

Quota order number id + start date must be unique.

class quotas.business_rules.QD10(transaction=None)[source]

The validity period measurement unit code must span the validity period of the quota definition.

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

The validity period measurement unit code must span the validity period of the quota definition.

class quotas.business_rules.QD11(transaction=None)[source]

The validity period of the measurement unit qualifier code must span the validity period of the quota definition.

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

The validity period of the measurement unit qualifier code must span the validity period of the quota definition.

class quotas.business_rules.QD7(transaction=None)[source]

The validity period of the quota definition must be spanned by one of the validity periods of the referenced quota order number.

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

The validity period of the quota definition must be spanned by one of the validity periods of the referenced quota order number.

class quotas.business_rules.QD8(transaction=None)[source]

The validity period of the monetary unit code must span the validity period of the quota definition.

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

The validity period of the monetary unit code must span the validity period of the quota definition.

class quotas.business_rules.QSP2(transaction=None)[source]

The validity period of the quota must span the quota suspension period.

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

The validity period of the quota must span the quota suspension period.

class quotas.business_rules.QuotaAssociationMustReferToANonDeletedSubQuota(transaction=None)[source]

A Quota Association must refer to a non-deleted sub quota.

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

A Quota Association must refer to a non-deleted sub quota.

class quotas.business_rules.QuotaBlockingPeriodMustReferToANonDeletedQuotaDefinition(transaction=None)[source]

A Quota Blocking Period must refer to a non-deleted Quota Definition.

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

A Quota Blocking Period must refer to a non-deleted Quota Definition.

class quotas.business_rules.QuotaSuspensionMustReferToANonDeletedQuotaDefinition(transaction=None)[source]

A Quota Suspension must refer to a non-deleted Quota Definition.

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

A Quota Suspension must refer to a non-deleted Quota Definition.

class quotas.business_rules.SameMainAndSubQuota(transaction=None)[source]

A quota association may only exist between two distinct quota definitions.

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

A quota association may only exist between two distinct quota definitions.

validate(association)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.SuspensionsOnlyToFCFSQuotas(transaction=None)[source]

Quota suspensions are only applicable to First Come First Served quotas.

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

Quota suspensions are only applicable to First Come First Served quotas.

validate(suspension)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses

class quotas.business_rules.VolumeAndInitialVolumeMustMatch(transaction=None)[source]

Unless it is the main quota in a quota association, a definition’s volume and initial_volume values should always be the same.

the exception is when we are updating quotas in the current period, these can have differing vol and initial vol

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

Unless it is the main quota in a quota association, a definition’s volume and initial_volume values should always be the same.

the exception is when we are updating quotas in the current period, these can have differing vol and initial vol

validate(quota_definition)[source]

Perform business rule validation.

Raises

NotImplementedError – Must be overridden by subclasses