ferrosoft.apps.emiflow.models package¶
ORM models for the emiflow application.
The package is split into one module per bounded sub-domain:
booking— emission booking records and lifecycle categories (the immutable journal of calculated emissions).catalog— reference data for emission factors, energy carriers, emitters, and the catalogs they belong to.dataimport— staging tables for bulk transport import.intensity—EmissionIntensityshared by transport operations, treatment operations, and emitters.operation— transport operations (the activity definition reused across chain elements).reporting— report definitions and report templates.settings— per-tenant emiflow and Business Central settings.signals— post-save / post-delete hooks that keep cross-cutting state (allocation, intensity ownership) consistent.tegos— adapters for inbound data from the TEGOS waste-management ERP.transport— transport chains, their elements, and freight items.treatment— treatments, treatment operations, and their input/output lines.
Star-imports below flatten the public names into the package namespace
so callers can from ferrosoft.apps.emiflow.models import Treatment
without knowing which sub-module a model lives in.
Submodules¶
ferrosoft.apps.emiflow.models.booking module¶
Emission booking records and lifecycle categories.
This module defines the immutable journal of calculated emissions:
EmissionBookingRecord— one row per(lifecycle category, emitting entity, material)triple. Fields are denormalised (material arrays, partner names) so reports can query a single table without joining live operational data.LifecycleCategory— user-defined categories plus the four predefined ones (treatment, incoming/outgoing transport, drop shipment) enumerated inPredefinedLCC.LCCValue— abstract base for manually entered per-category emission values that subclasses attach to transports or treatments.
The EmissionBookingRecordQuerySet exposes the aggregations used
by the reporting pipeline (totals by entity, by material, by lifecycle
category) — all keyed off the denormalised columns so they remain valid
even after the originating operation has changed.
- class ferrosoft.apps.emiflow.models.booking.EmissionBookingRecord(*args, **kwargs)[source]¶
Bases:
UUIDModelOne booking entry: an emission figure tied to a lifecycle category and entity.
Records are wide-and-denormalised: material codes/names, partner names, and unit symbols are copied into the row so report aggregations stay valid even if the underlying operation is later edited or deleted.
extraholds optional contextual data (transport/activity distance, intensity at booking time) used by detail views.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- property activity_distance: DecimalWithUnit¶
Activity distance recorded alongside this booking, when applicable.
- booking_date¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- creation_time¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property emission_intensity_operation: DecimalWithUnit¶
Operation-only emission intensity that produced this booking.
- property emission_intensity_total: DecimalWithUnit¶
Total emission intensity that produced this booking.
- property emission_operation¶
Operation-only emission paired with the denormalised unit symbol.
- emission_operation_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property emission_total¶
Total emission paired with the denormalised unit symbol.
- emission_total_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- emission_unit_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- emission_unit_symbol¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- entity_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- entity_reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- extra¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_booking_date(*, field=<django.db.models.fields.DateField: booking_date>, is_next=True, **kwargs)¶
- get_next_by_creation_time(*, field=<django.db.models.fields.DateTimeField: creation_time>, is_next=True, **kwargs)¶
- get_previous_by_booking_date(*, field=<django.db.models.fields.DateField: booking_date>, is_next=False, **kwargs)¶
- get_previous_by_creation_time(*, field=<django.db.models.fields.DateTimeField: creation_time>, is_next=False, **kwargs)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- incoming_partner_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- incoming_partner_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lifecycle_category¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lifecycle_category_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modification_time¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.booking.EmissionBookingRecordManager object>¶
- outgoing_partner_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- outgoing_partner_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- simulation¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property transport_distance: DecimalWithUnit¶
Transport distance recorded alongside this booking (transport records only).
- property weight¶
Booking weight paired with the denormalised unit symbol.
- weight_unit_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- weight_unit_symbol¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- weight_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.booking.EmissionBookingRecordManager(*args, **kwargs)[source]¶
Bases:
ManagerManager exposing aggregation, lookup, and upsert helpers.
- static calculate_proportions(method, lifecycles)[source]¶
Scale lifecycle totals against the chosen authoritative leg’s weight.
Used by PCF reports when the customer wants the incoming or outgoing transport weight to drive the emissions allocation. Lifecycle rows with weights larger than the authoritative leg are scaled down so they share the same denominator; smaller weights are left untouched. Returns the input unchanged when
methodisDISABLEDor no authoritative row is present.- Return type:
- find_first(lifecycle_category, entity_id)[source]¶
Return the first booking record for the given category and entity.
- get_queryset()[source]¶
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
- Return type:
- sum_emissions(lifecycle_category, entity_id)[source]¶
Aggregate the entity’s emissions in one lifecycle category.
- Return type:
- static sum_lifecycles(results)[source]¶
Sum a sequence of
LifecycleResultrows into a singleLifecycleSum.Convenience over Python-side iteration for callers that already have the per-lifecycle rows in memory (e.g. PCF totals).
- Return type:
- upsert(records)[source]¶
Bulk insert-or-update booking records and bump the tenant tonnage counter.
(lifecycle_category, entity_id, material_id)is the conflict target; on conflict every denormalised field is refreshed. Simulation rows are excluded from the tonnage counter so dry runs don’t burn through a customer’s subscription quota.- Return type:
- class ferrosoft.apps.emiflow.models.booking.EmissionBookingRecordQuerySet(*args, **kwargs)[source]¶
Bases:
QuerySetQuerySet that knows how to roll booking records up for reports.
Each aggregation method returns rows with
emission_total,emission_operation,weight, and the twoaverage_*columns annotated asDecimalWithUnitvalues, so reports can format them without re-attaching units in Python.- emission_total()[source]¶
Group rows by
(lifecycle_category, entity_id)and aggregate emissions.- Return type:
- filter_material_name(name)[source]¶
Restrict the queryset to rows whose material array contains
name.
- get_emission_aggregate_columns()[source]¶
Return
Sumexpressions for total, operation, and weight columns.Exposed for callers that need to compose their own aggregations on top of the shared unit-aware output fields.
- Return type:
- pcf_lifecycles(material_name)[source]¶
Group rows for one material by lifecycle category and aggregate.
Used by the PCF report, which is product-specific and therefore always scoped to a single material name.
- Return type:
- class ferrosoft.apps.emiflow.models.booking.EmissionTotal¶
Bases:
TypedDict- average_operation: DecimalWithUnit¶
- average_total: DecimalWithUnit¶
- emission_operation: DecimalWithUnit¶
- emission_total: DecimalWithUnit¶
- weight: DecimalWithUnit¶
- class ferrosoft.apps.emiflow.models.booking.LCCValue(*args, **kwargs)[source]¶
Bases:
UUIDModelAbstract base for manually entered per-lifecycle emission contributions.
Concrete subclasses (
TransportLCCValue,TreatmentLCCValue) add the foreign key to the owning entity. Only custom (non-predefined) categories are intended to be selected on the form.- class Meta[source]¶
Bases:
object- abstract = False¶
- verbose_name = 'Lifecycle Category Value'¶
- verbose_name_plural = 'Lifecycle Category Values'¶
- emission_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emission_unit_id¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lifecycle_category¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- lifecycle_category_id¶
- objects¶
- property operation_emission¶
Operation emission value paired with its unit.
- operation_emission_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property total_emission¶
Total emission value paired with its unit.
- total_emission_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.booking.LCCValueManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that eagerly joins the category and emission unit.
- class ferrosoft.apps.emiflow.models.booking.LifecycleCategory(*args, **kwargs)[source]¶
Bases:
ModelA named bucket that booking records are attributed to.
The primary key is intentionally a small integer (not a UUID) so the four
PredefinedLCCenum values can be used as the canonical PKs for the system-provided categories.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.booking.LifecycleCategoryManager object>¶
- predefined¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.booking.LifecycleCategoryManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that upserts lifecycle categories by primary key.
- upsert_predefined()[source]¶
Ensure the four
PredefinedLCCcategories exist with their canonical IDs.
- class ferrosoft.apps.emiflow.models.booking.LifecycleResult¶
Bases:
TypedDict- average_operation: DecimalWithUnit¶
- average_total: DecimalWithUnit¶
- emission_operation: DecimalWithUnit¶
- emission_total: DecimalWithUnit¶
- weight: DecimalWithUnit¶
- class ferrosoft.apps.emiflow.models.booking.LifecycleSum(emission_total=<factory>, emission_operation=<factory>, weight=<factory>, average_total=<factory>, average_operation=<factory>)[source]¶
Bases:
objectRunning totals over one or more
LifecycleResultrows.- average_operation: DecimalWithUnit¶
- average_total: DecimalWithUnit¶
- emission_operation: DecimalWithUnit¶
- emission_total: DecimalWithUnit¶
- weight: DecimalWithUnit¶
- class ferrosoft.apps.emiflow.models.booking.PCFTotal¶
Bases:
TypedDict- average_operation: DecimalWithUnit¶
- average_total: DecimalWithUnit¶
- emission_operation: DecimalWithUnit¶
- emission_total: DecimalWithUnit¶
- weight: DecimalWithUnit¶
- class ferrosoft.apps.emiflow.models.booking.PredefinedLCC(*values)[source]¶
Bases:
IntegerChoicesPredefined Lifecycle Categories.
These correspond to (not necessarily 1-1) to models found in Emiflow, for which emissions can be calculated.
- DROP_SHIPMENT = 4¶
- INCOMING_TRANSPORT = 2¶
- OUTGOING_TRANSPORT = 3¶
- TREATMENT = 1¶
- classmethod value_from(source)[source]¶
Map an upstream enum value to its corresponding lifecycle category.
Currently supports
TransportChainType; raisesValueErrorfor any other input type so unmapped values fail loudly during booking.
ferrosoft.apps.emiflow.models.catalog module¶
Reference catalog: emitters, energy carriers, and their emission factors.
A EmissionsCatalog is a published bundle of emission data (e.g.
the GLEC public extract) with copyright and licence information. Each
catalog contains Emitter (vehicles or hub equipment),
EnergyCarrier, and EmissionFactor. Models share the
shape of the upstream emiflow.json JSON schema so updates can be
imported in bulk.
- ferrosoft.apps.emiflow.models.catalog.CatalogDecimalField(*args, **kwargs)[source]¶
Build a
DecimalFieldsized for catalog values.Allocates eight fractional digits (factors are small) and only four integer digits, since catalog quantities rarely exceed four digits before the decimal point.
- class ferrosoft.apps.emiflow.models.catalog.DataSource(*values)[source]¶
Bases:
IntegerChoicesProvenance of the figures in a catalog (primary measured vs. defaults).
- DEFAULT_DATA = 3¶
- PRIMARY_DATA = 1¶
- SECONDARY_DATA = 2¶
- class ferrosoft.apps.emiflow.models.catalog.EmissionCategory(*values)[source]¶
Bases:
IntegerChoicesThe two emission categories tracked per energy carrier.
Operation covers tailpipe / process emissions; Energy Provision covers upstream emissions from producing and distributing the energy carrier (well-to-tank).
- ENERGY_PROVISION = 3¶
- OPERATION = 2¶
- class ferrosoft.apps.emiflow.models.catalog.EmissionFactor(*args, **kwargs)[source]¶
Bases:
ReadOnlyMixin,UUIDModelA per-unit emission factor for one
EnergyCarrier.Typically four factors are stored per carrier, formed by the Cartesian product of two units (
gCO2e/MJandkgCOe/kg) and the twoEmissionCategoryvalues. Theread_onlyflag isTruefor factors imported from a published catalog (which must be copied before being changed) andFalsefor user-defined factors, which can be edited in place.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- category¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- energy_carrier¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- energy_carrier_id¶
- property factor: DecimalWithUnit¶
Factor value paired with its unit, as a
DecimalWithUnit.
- get_category_display(*, field=<django.db.models.fields.PositiveIntegerField: category>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.catalog.EmissionFactorManager object>¶
- read_only¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- unit_id¶
- value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.catalog.EmissionFactorManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that eagerly joins the energy carrier and unit.
- class ferrosoft.apps.emiflow.models.catalog.EmissionsCatalog(*args, **kwargs)[source]¶
Bases:
UUIDModelA named bundle of emission-calculation reference data.
Catalogs group
Emitter,EnergyCarrier, andEmissionFactorentries together with their licensing terms. The schema mirrors the publishedemiflow.jsonJSON schema so third-party catalogs can be imported directly.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- copyright¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- data_source¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- emitters¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- energy_carriers¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- get_data_source_display(*, field=<django.db.models.fields.PositiveIntegerField: data_source>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- license_text¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- license_uri¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- class ferrosoft.apps.emiflow.models.catalog.Emitter(*args, **kwargs)[source]¶
Bases:
ReadOnlyMixin,UUIDModelA vehicle or piece of hub equipment that emits greenhouse gases.
The
epitypefield discriminates between vehicles (with a furthervehicle_type) and hub equipment (material handlers, processing units). Each emitter has a defaultEnergyCarrierand an optional cachedEmissionIntensity. Theread_onlyflag inherited fromReadOnlyMixinis set toTruefor rows imported from a published catalog (which must be copied before they can be modified) and leftFalsefor user-defined entries, which are editable in place.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- catalog¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- catalog_id¶
- emission_intensity¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emission_intensity_id¶
- energy_carrier¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- energy_carrier_id¶
- epitype¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_epitype_display(*, field=<django.db.models.fields.PositiveIntegerField: epitype>)¶
- classmethod get_ordered(catalog=None)[source]¶
Return emitters sorted by
(catalog, name), optionally filtered to one catalog.
- get_vehicle_type_display(*, field=<django.db.models.fields.PositiveIntegerField: vehicle_type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.catalog.EmitterManager object>¶
- read_only¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- treatmentoperation_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- vehicle_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.catalog.EmitterEpitype(*values)[source]¶
Bases:
IntegerChoicesMixin,IntegerChoicesTop-level type of an
Emitter.Vehicles are differentiated further by
VehicleType; the term epitype distinguishes this overarching axis from the vehicle sub-type.- MATERIAL_HANDLER = 3¶
- PROCESSING_UNIT = 4¶
- VEHICLE = 1¶
- class ferrosoft.apps.emiflow.models.catalog.EmitterManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that eagerly joins catalog, energy carrier, and intensity unit.
- class ferrosoft.apps.emiflow.models.catalog.EnergyCarrier(*args, **kwargs)[source]¶
Bases:
ReadOnlyMixin,UUIDModelA substance or phenomenon (fuel, electricity, heat) that powers an emitter.
Holds physical attributes (lower heating value, density) needed to translate between mass, volume, and energy when a quantity is expressed in a non-mass unit. The
read_onlyflag distinguishes carriers imported from a published catalog (True, copy-on-write) from user-defined entries (False, editable in place).- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- application¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- catalog¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- catalog_id¶
- composition¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- density¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- emission_factors¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- classmethod get_ordered(catalog=None)[source]¶
Return energy carriers sorted by
(catalog, name), optionally filtered to one catalog.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lower_heating¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- read_only¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- treatmentoperation_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
ferrosoft.apps.emiflow.models.dataimport module¶
Staging models for bulk transport-chain imports.
Rows here represent one input line that the
ferrosoft.apps.emiflow.dataimport services then turn into real
TransportChain records. SimpleImportLine and
MultiLineImportLine differ in whether one row maps to a whole
transport chain or to one element of a multi-hop chain;
MultiLineBookingRecord tracks which chains a given import job
produced so it can post (or roll back) emissions atomically.
- class ferrosoft.apps.emiflow.models.dataimport.ImportLine(*args, **kwargs)[source]¶
Bases:
UUIDModelAbstract base for one row staged for transport-chain creation.
Captures everything required to build a single
FreightItemon aTransportChain: routing (start/destination address), cargo (material and weight), and chain metadata (incoterms, vehicle type, partners).- booking_date¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- consignee¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignee_id¶
- consignor¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignor_id¶
- destination_address()[source]¶
Return the destination location as an
Addressvalue object.- Return type:
- destination_city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- destination_country_id¶
- destination_house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_incoterms_display(*, field=<django.db.models.fields.CharField: incoterms>)¶
- get_transport_type_display(*, field=<django.db.models.fields.PositiveIntegerField: transport_type>)¶
- get_vehicle_type_display(*, field=<django.db.models.fields.PositiveIntegerField: vehicle_type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- incoterms¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- start_country_id¶
- start_house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- transport_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- vehicle_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property weight: DecimalWithUnit¶
Cargo weight paired with its unit.
- weight_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- weight_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.dataimport.MultiLineBookingRecord(*args, **kwargs)[source]¶
Bases:
UUIDModelTracks which transport chains a multi-line import job has produced.
Used to post emissions for all chains an import created, and to clear the bookkeeping rows once posting is complete.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- classmethod clear_transports(job_id)[source]¶
Drop the bookkeeping rows for
job_id(usually after emissions are posted).
- classmethod get_transports(job_id)[source]¶
Return the IDs of all transport chains produced by
job_id.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- job¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- job_id¶
- objects = <django.db.models.manager.Manager object>¶
- transport¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- transport_id¶
- class ferrosoft.apps.emiflow.models.dataimport.MultiLineImportLine(*args, **kwargs)[source]¶
Bases:
ImportLine,UUIDModelOne import row = one transport-chain element (TCE) for a multi-hop chain.
Lines with the same
referencebuild up the chain inpositionorder. Multiple materials per position are supported; the unique constraint includesmaterialso the same leg can carry several materials.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- booking_date¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- consignee¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignee_id¶
- consignor¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignor_id¶
- destination_city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- destination_country_id¶
- destination_house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_incoterms_display(*, field=<django.db.models.fields.CharField: incoterms>)¶
- get_transport_type_display(*, field=<django.db.models.fields.PositiveIntegerField: transport_type>)¶
- get_vehicle_type_display(*, field=<django.db.models.fields.PositiveIntegerField: vehicle_type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- incoterms¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects = <django.db.models.manager.Manager object>¶
- position¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- start_country_id¶
- start_house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- transport_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- vehicle_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- weight_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- weight_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.dataimport.SimpleImportLine(*args, **kwargs)[source]¶
Bases:
ImportLine,UUIDModelOne import row = one transport chain with a single route step and material movement.
Reference is unique per row, so re-importing the same reference updates the staged line in place.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- booking_date¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- consignee¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignee_id¶
- consignor¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignor_id¶
- destination_city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- destination_country_id¶
- destination_house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- destination_street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_incoterms_display(*, field=<django.db.models.fields.CharField: incoterms>)¶
- get_transport_type_display(*, field=<django.db.models.fields.PositiveIntegerField: transport_type>)¶
- get_vehicle_type_display(*, field=<django.db.models.fields.PositiveIntegerField: vehicle_type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- incoterms¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects = <django.db.models.manager.Manager object>¶
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- start_country_id¶
- start_house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- transport_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- vehicle_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- weight_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- weight_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
ferrosoft.apps.emiflow.models.intensity module¶
Emission intensity values shared across transport ops, treatment ops, and emitters.
An EmissionIntensity is the calculated gCO2e per tkm (or
gCO2e per t for treatments) figure with all of the input variables it
was computed from. The owner_type + owner_id pair forms a weak
polymorphic reference so the same intensity row can belong to any of
the three intensity-capable model classes; cleanup is handled by the
post-delete signals in ferrosoft.apps.emiflow.models.signals.
- class ferrosoft.apps.emiflow.models.intensity.EmissionIntensity(*args, **kwargs)[source]¶
Bases:
ReadOnlyMixin,UUIDModelCalculated emission intensity together with its input variables.
The row records both output intensities (operation and energy provision values plus their shared unit) and input variables (factors, quantity of fuel, mass of materials, optional distance) so the calculation is fully reproducible. The
read_onlyflag isTruefor intensities derived from imported catalog data (which must be copied viacopy_with_owner()before modification) andFalsefor user-computed intensities, which remain editable in place.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- copy_with_owner(owner_type, owner_id)[source]¶
Create a copy of this intensity attributed to a new owner.
Distance is zeroed out for owners that are not distance-based (see
IntensityCapableEntity.is_distance_based()).- Parameters:
owner_type (
IntensityCapableEntity) – The new owner’s entity type.owner_id (
UUID) – Primary key of the new owner.
- Returns:
The newly persisted copy.
- Return type:
- property distance: DecimalWithUnit¶
Activity distance used in the calculation (zero when not distance-based).
- distance_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- distance_unit_id¶
- distance_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- enable_distance¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property energy_provision_intensity: DecimalWithUnit¶
Energy-provision emission intensity as a
DecimalWithUnit.
- energy_provision_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- factor_energy_provision_value¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- factor_energy_provision_value_id¶
- factor_operation_value¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- factor_operation_value_id¶
- get_owner_type_display(*, field=<django.db.models.fields.IntegerField: owner_type>)¶
- property grade: int¶
Grade total intensity on a 0..3 scale (higher is better).
Thresholds are centred around the GLEC public-extract average of 117 gCO2e/tkm: 0–80 → 3, 81–140 → 2, 141–200 → 1, above 200 → 0.
- Returns:
Grade number from 0 (worst) to 3 (best).
- Return type:
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property mass: DecimalWithUnit¶
Total mass of treated materials used in the calculation.
- mass_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- mass_unit_id¶
- mass_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.intensity.EmissionIntensityManager object>¶
- property operation_intensity: DecimalWithUnit¶
Operation emission intensity as a
DecimalWithUnit.
- operation_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property owner¶
Resolve and return the owning entity via the weak
owner_type/owner_idpair.- Returns:
The owning
TransportOperation,TreatmentOperation, orEmitterinstance.- Raises:
ValueError – If
owner_typeis not a recognisedIntensityCapableEntityvalue.
- owner_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- owner_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property quantity: DecimalWithUnit¶
Fuel or electricity quantity used in the calculation.
- quantity_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- quantity_unit_id¶
- quantity_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- read_only¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- unit_id¶
- update_foreign_key()[source]¶
Point the owner’s
emission_intensityFK at this row.The relation is duplicated (weak
owner_idhere plus a real FK on the owner) so list views canselect_relatedit; this method keeps the FK side in sync after a new intensity is inserted.- Raises:
ValueError – If the resolved owner has no
emission_intensityattribute.
- class ferrosoft.apps.emiflow.models.intensity.EmissionIntensityManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that prefetches units and the two emission factor relations.
ferrosoft.apps.emiflow.models.operation module¶
Transport-operation model and its operation-type enum.
A TransportOperation is the activity definition (emitter +
energy carrier + activity type) that is reused across one or more
transport-chain elements. It owns an EmissionIntensity once
calculated.
- class ferrosoft.apps.emiflow.models.operation.OperationEpitype(*values)[source]¶
Bases:
IntegerChoicesMixin,IntegerChoicesThe standard defines two kinds of operations, transport and hub operation.
For our data model it is useful to combine them into one data type (OperationCategory) and differentiate between transport and hub operation by the “epitype”. This is an overarching type, because transport operations are further characterized by their own type.
- HUB = 2¶
- TRANSPORT = 1¶
- class ferrosoft.apps.emiflow.models.operation.TransportOperation(*args, **kwargs)[source]¶
Bases:
ReadOnlyMixin,UUIDModelA reusable transport-or-hub activity definition.
Combines an
Emitterand anEnergyCarrierwith an activity type (transport vs. hub) and an optional cachedEmissionIntensity. Theread_onlyflag isTruefor operations derived from imported catalog data (which must be copied before modification) andFalsefor user-defined operations, which remain editable in place.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- activity_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- emission_intensity¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emission_intensity_id¶
- emitter¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emitter_id¶
- energy_carrier¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- energy_carrier_id¶
- get_activity_type_display(*, field=<django.db.models.fields.IntegerField: activity_type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.operation.TransportOperationManager object>¶
- read_only¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- transport_chain_elements¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
ferrosoft.apps.emiflow.models.reporting module¶
Models for emission reports and the templates that render them.
A Report captures the user’s selection (type, filter query
string, proportional-emission method); a ReportTemplate
captures the visual chrome (logo, preamble, epilogue) reused across
generated documents. Logos are inlined as base64 so the rendered HTML
can be turned into PDF by WeasyPrint without external fetches.
- class ferrosoft.apps.emiflow.models.reporting.AspectRatio(*values)[source]¶
Bases:
IntegerChoicesPreset width:height ratios available for logo sizing.
- AUTOMATIC = 0¶
- RATIO_16_10 = 2¶
- RATIO_16_9 = 1¶
- RATIO_1_1 = 3¶
- RATIO_1_2 = 4¶
- class ferrosoft.apps.emiflow.models.reporting.Base64Image(media_type, content)[source]¶
Bases:
objectAn image inlined as a base64 string for embedding in rendered HTML/PDF.
- class ferrosoft.apps.emiflow.models.reporting.PhotoOrientation(*values)[source]¶
Bases:
IntegerChoicesOrientation of a logo image (landscape or portrait).
- LANDSCAPE = 1¶
- PORTRAIT = 2¶
- class ferrosoft.apps.emiflow.models.reporting.ProportionalEmission(*values)[source]¶
Bases:
IntegerChoicesWhich transport leg’s weight overrides the others when computing PCF.
When enabled, the chosen leg’s weight is treated as authoritative and other lifecycle categories’ emissions are scaled down proportionally.
- DISABLED = 0¶
- INCOMING_TRANSPORT = 2¶
- OUTGOING_TRANSPORT = 1¶
- class ferrosoft.apps.emiflow.models.reporting.Report(*args, **kwargs)[source]¶
Bases:
UUIDModelA saved emission report (selection criteria plus presentation options).
Reports persist the filter query string they were generated from so the same set of booking records can be reproduced later through
get_user_filtered().- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- creation_time¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- filters¶
Filter query string for use by FilterSet class
- get_next_by_creation_time(*, field=<django.db.models.fields.DateTimeField: creation_time>, is_next=True, **kwargs)¶
- get_previous_by_creation_time(*, field=<django.db.models.fields.DateTimeField: creation_time>, is_next=False, **kwargs)¶
- get_proportional_emissions_display(*, field=<django.db.models.fields.IntegerField: proportional_emissions>)¶
- get_type_display(*, field=<django.db.models.fields.IntegerField: type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- proportional_emissions¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.reporting.ReportTemplate(*args, **kwargs)[source]¶
Bases:
UUIDModelReusable visual template applied when rendering a
Report.Carries the document title, preamble, epilogue, sender address, and a company logo (with explicit sizing/orientation hints because PDF renderers can’t infer them reliably).
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- company_logo¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- company_logo_aspect_ratio¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property company_logo_base64: Base64Image | None[source]¶
Return the company logo as a
Base64ImageorNonewhen unset.
- company_logo_id¶
- company_logo_orientation¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- company_logo_width¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- document_epilogue¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- document_preamble¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- document_sender¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- document_sender_id¶
- document_title¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_company_logo_aspect_ratio_display(*, field=<django.db.models.fields.IntegerField: company_logo_aspect_ratio>)¶
- get_company_logo_orientation_display(*, field=<django.db.models.fields.IntegerField: company_logo_orientation>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
ferrosoft.apps.emiflow.models.settings module¶
Per-tenant emiflow configuration models.
Settings is a singleton (created lazily on first read) that holds
references to storage directories and the user-defined emissions catalog;
TransportChainDefaults keeps default transport-chain attributes
per vehicle type; BusinessCentralSettings holds OAuth credentials
for the Dynamics 365 Business Central integration.
- class ferrosoft.apps.emiflow.models.settings.BusinessCentralSettings(*args, **kwargs)[source]¶
Bases:
UUIDModelMicrosoft Dynamics 365 Business Central connection settings (per tenant).
Stores the BC tenant ID, environment, API base URL, and OAuth client-credentials parameters used by the BC integration in
ferrosoft.apps.emiflow.services.businesscentral.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- api_base_url¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- environment¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get_instance()[source]¶
Return the singleton BC settings row, creating it on first call.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- oauth_auth_url¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- oauth_client_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- oauth_client_secret¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- oauth_scope¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- tenant_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.settings.Settings(*args, **kwargs)[source]¶
Bases:
UUIDModelUser configurable settings for Emiflow.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- company_logo_directory¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- company_logo_directory_id¶
- get_company_logo_directory()[source]¶
Resolve the company-logo directory, creating it on first call.
Falls back to creating (or fetching) a directory named Company Logos and persisting the FK when the field was unset.
- Return type:
- classmethod get_instance()[source]¶
Return the singleton
Settingsrow, creating it on first call.Prefetches the related
TransportChainDefaultsrows so subsequentget_transport_chain_defaultslookups don’t hit the database.- Return type:
- get_transport_chain_defaults(vehicle_type)[source]¶
Return the defaults row for
vehicle_type, inserting an empty one if absent.- Return type:
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- report_directory¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- report_directory_id¶
- transport_chain_defaults¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- user_catalog¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_catalog_id¶
- class ferrosoft.apps.emiflow.models.settings.TransportChainDefaults(*args, **kwargs)[source]¶
Bases:
UUIDModelPer-vehicle-type defaults applied when creating a new transport chain.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- distance_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_distance_type_display(*, field=<django.db.models.fields.PositiveIntegerField: distance_type>)¶
- get_vehicle_type_display(*, field=<django.db.models.fields.PositiveIntegerField: vehicle_type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- settings¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- settings_id¶
- transport_operation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- transport_operation_id¶
- vehicle_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
ferrosoft.apps.emiflow.models.signals module¶
Cross-model lifecycle hooks for emiflow.
Two concerns are wired up here:
Whenever a treatment-operation output line is inserted or removed, the parent operation’s allocation is recomputed (no-op under manual allocation).
Whenever an entity that owns an
EmissionIntensity(transport operation, treatment operation, or emitter) is deleted, the matching intensity row is removed. The intensity table uses a weak(owner_type, owner_id)reference rather than a real foreign key, so this cascade must be driven explicitly from signals.
The module is loaded via the wildcard import in
ferrosoft.apps.emiflow.models.__init__, which is what registers
these receivers at app startup.
- ferrosoft.apps.emiflow.models.signals.allocate_treatment_emissions_after_deletion(instance, **kwargs)[source]¶
Recompute parent operation’s allocation after an output line is deleted.
- ferrosoft.apps.emiflow.models.signals.allocate_treatment_emissions_after_insertion(instance, **kwargs)[source]¶
Recompute parent operation’s allocation after an output line is saved.
- ferrosoft.apps.emiflow.models.signals.delete_emitter_emission_intensity(instance, **kwargs)[source]¶
Remove the
EmissionIntensityowned by a deleted emitter.
ferrosoft.apps.emiflow.models.tegos module¶
In-memory value objects used by the TEGOS waste-management ERP adapter.
These types are not Django models — they carry data parsed out of TEGOS order documents while transport chains and freight items are being constructed. They live next to the persistent models because they share domain vocabulary (posting types, materials, weights).
- class ferrosoft.apps.emiflow.models.tegos.FreightItemGroup(weight, material_name)[source]¶
Bases:
objectA weight + material pair aggregated from TEGOS order lines.
- weight: DecimalWithUnit¶
- class ferrosoft.apps.emiflow.models.tegos.OrderLineGroup(posting_type, material_reference, lines)[source]¶
Bases:
objectA batch of TEGOS order lines grouped by posting type and material.
- posting_type: PostingType¶
- class ferrosoft.apps.emiflow.models.tegos.PostingType(*values)[source]¶
Bases:
StrEnumTEGOS order posting direction (purchase vs. sales).
- PURCHASE = 'Purchase'¶
- SALES = 'Sales'¶
- to_transport_type()[source]¶
Map the posting type to the corresponding emiflow transport-chain type.
- Returns:
INCOMINGforPURCHASE,OUTGOINGforSALES.- Return type:
- Raises:
ValueError – If a new
PostingTypemember has been added without an explicit mapping.
ferrosoft.apps.emiflow.models.transport module¶
Transport-chain domain models.
A TransportChain is one consignment from consignor to consignee
broken into ordered TransportChainElement (TCE) hops. Each TCE
points at a reusable TransportOperation (the activity
definition) and may carry geo-points for shortest-feasible or great-
circle distance calculations. The chain’s freight is described by
FreightItem rows (material + weight). Custom per-lifecycle
emissions are attached via TransportLCCValue.
- class ferrosoft.apps.emiflow.models.transport.ActivityDistanceParameters(distance_type, distance, daf, origin, destination)[source]¶
Bases:
objectIncludes activity distance along with some related parameters.
Note that “activity distance” only has meaning for TCE’s of epitype TRANSPORT. For those, activity distance is transport activity.
For HUB TCE’s on the other hand, no activity distance exists. Freight item mass is the transport activity in this case.
- daf¶
Distance Adjustment Factor
- destination: TCEGeoDestination | None¶
- distance: DecimalWithUnit¶
- distance_type: DistanceType¶
- origin: TCEGeoOrigin | None¶
- exception ferrosoft.apps.emiflow.models.transport.BookingError[source]¶
Bases:
RuntimeErrorBookingError is raised by TransportChain.book.
Its message is translated and should be shown to the user.
- class ferrosoft.apps.emiflow.models.transport.BookingStatus(*values)[source]¶
Bases:
IntegerChoicesLifecycle state of a
TransportChain.Posted chains are immutable to keep the booking journal consistent.
- OPEN = 1¶
- POSTED = 2¶
- class ferrosoft.apps.emiflow.models.transport.DistanceType(*values)[source]¶
Bases:
IntegerChoicesMixin,IntegerChoicesHow the activity distance for a TCE is determined.
- ACTUAL_DISTANCE = 1¶
- GREAT_CIRCLE = 3¶
- SHORTEST_FEASIBLE = 2¶
- class ferrosoft.apps.emiflow.models.transport.FreightItem(*args, **kwargs)[source]¶
Bases:
UUIDModelQuantified material allocated to a transport chain.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- chain¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- chain_id¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects = <ferrosoft.apps.emiflow.models.transport.FreightItemManager object>¶
- property weight¶
Freight item’s weight paired with its unit.
- weight_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- weight_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.transport.FreightItemManager(*args, **kwargs)[source]¶
Bases:
ManagerManager with upsert and weight-aggregation helpers.
- class ferrosoft.apps.emiflow.models.transport.Incoterm(*values)[source]¶
Bases:
TextChoicesStandard Incoterms® 2020 three-letter codes.
- CFR = 'CFR'¶
- CIF = 'CIF'¶
- CIP = 'CIP'¶
- CPT = 'CPT'¶
- DAP = 'DAP'¶
- DDP = 'DDP'¶
- DPU = 'DPU'¶
- EXW = 'EXW'¶
- FAS = 'FAS'¶
- FCA = 'FCA'¶
- FOB = 'FOB'¶
- class ferrosoft.apps.emiflow.models.transport.TCEGeoDestination(*args, **kwargs)[source]¶
Bases:
TCEGeoPoint,UUIDModelGeographical destination of a transport chain element.
Note that TCE’s don’t necessarily have a GEO destination. It depends on TCE’s activity_distance_type.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- additional_lines¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- company¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- country_id¶
- first_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- latitude¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- longitude¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.transport.TCEGeoPointManager object>¶
- postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- salutation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- salutation_id¶
- street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- tce¶
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- tce_id¶
- class ferrosoft.apps.emiflow.models.transport.TCEGeoOrigin(*args, **kwargs)[source]¶
Bases:
TCEGeoPoint,UUIDModelGeographical origin of a transport chain element.
Note that TCE’s don’t necessarily have a GEO origin. It depends on TCE’s activity_distance_type.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- additional_lines¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- company¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- country_id¶
- first_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- latitude¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- longitude¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.transport.TCEGeoPointManager object>¶
- postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- salutation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- salutation_id¶
- street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- tce¶
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- tce_id¶
- class ferrosoft.apps.emiflow.models.transport.TCEGeoPoint(*args, **kwargs)[source]¶
Bases:
AddressMixin,CoordinatesMixin,UUIDModelAbstract base for the two TCE geo-point models (origin, destination).
- additional_lines¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- city¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- company¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- country¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- country_id¶
- first_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- house_no¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- latitude¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- longitude¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- postal_code¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- salutation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- salutation_id¶
- street¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.transport.TCEGeoPointManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that upserts geo-points keyed by
tce.
- class ferrosoft.apps.emiflow.models.transport.TCEManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that upserts TCEs keyed by
(chain, position).
- class ferrosoft.apps.emiflow.models.transport.TCEManagerPrefetched(*args, **kwargs)[source]¶
Bases:
TCEManagerVariant of
TCEManagerthat joins the operation and distance unit.
- class ferrosoft.apps.emiflow.models.transport.TransportChain(*args, **kwargs)[source]¶
Bases:
UUIDModelA consignment from consignor to consignee, modelled as ordered hops.
Each hop is a
TransportChainElement(TCE); the chain’s cargo is split across one or moreFreightItemrows by material. OncestatusisPOSTEDthe chain is immutable —delete()raises and edit forms are disabled. Generated booking documents are kept forEXPIRE_DOCUMENT_ONand garbage-collected afterwards.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- EXPIRE_DOCUMENT_ON = datetime.timedelta(days=7)¶
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- accept(visitor)[source]¶
Visit this chain and its related objects in canonical order.
The visitor receives callbacks in this sequence:
before_chain(self)on_freight_item(item)for each freight item.on_element(element)for each transport chain element.after_chain(self)
- booking_date¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- consignee¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignee_id¶
- consignor¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- consignor_id¶
- copy(new_reference)[source]¶
Deep-copy this chain (elements, geo-points, freight) under a new reference.
Existing emission booking records for the original chain are re-inserted attached to the new chain via a raw SQL
INSERT ... SELECTto avoid recomputing them. The new chain inherits the original’s status, incoterms, simulation flag, and partners.- Return type:
- classmethod default_document_expiry(creation_time)[source]¶
Return the expiry timestamp for documents created at
creation_time.- Return type:
- delete(*args, **kwargs)[source]¶
Refuse to delete unless the chain is still
OPEN.Posted chains have associated booking records and must not be removed; the call raises
RuntimeErrorto prevent the delete from being silently lost.
- documents¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- elements¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- elements_ordered()[source]¶
Return chain elements in
positionorder with related operation data prefetched.
- freight_items¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- freight_items_ordered()[source]¶
Return freight items sorted by material code with unit and material prefetched.
- get_incoterms_display(*, field=<django.db.models.fields.CharField: incoterms>)¶
- get_next_by_booking_date(*, field=<django.db.models.fields.DateField: booking_date>, is_next=True, **kwargs)¶
- get_previous_by_booking_date(*, field=<django.db.models.fields.DateField: booking_date>, is_next=False, **kwargs)¶
- get_status_display(*, field=<django.db.models.fields.PositiveIntegerField: status>)¶
- get_transport_type_display(*, field=<django.db.models.fields.PositiveIntegerField: transport_type>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- incoterms¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lcc_values¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- next_element_position()[source]¶
Return the next free
positionvalue for a new chain element.- Return type:
- objects = <ferrosoft.apps.emiflow.models.transport.TransportChainManager object>¶
- post_emission()[source]¶
Run the booking service and return the booking records it produced.
- Return type:
- prefetched_objects = <ferrosoft.apps.emiflow.models.transport.TransportChainManagerPrefetched object>¶
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- simulation¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- sum_weight()[source]¶
Return the chain’s total freight weight, normalised to metric tons.
- Return type:
- transport_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.transport.TransportChainElement(*args, **kwargs)[source]¶
Bases:
UUIDModelTransportChainElement describes a single transport or hub operation in a transport chain.
Some characteristics for emissions calculation are defined in the operation category.
- activity_distance_type¶
Informs how activity distance was determined.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- property activity_distance¶
Activity distance normalised to the canonical distance unit (4 dp).
Returns a zero
DecimalWithUnitunchanged so callers can treat unset and zero distances uniformly.
- property activity_distance_parameters: ActivityDistanceParameters¶
Bundle the distance, DAF, and geo-points needed to compute the activity distance.
- Raises:
RuntimeError – When called on a hub (non-transport) element — hub TCEs use freight mass as activity, not distance.
- activity_distance_type¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- activity_distance_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- activity_distance_unit_id¶
- activity_distance_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- chain¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- chain_id¶
- distance_adjustment_factor¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- epitype¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- geo_destination¶
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- geo_origin¶
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- get_activity_distance_type_display(*, field=<django.db.models.fields.PositiveIntegerField: activity_distance_type>)¶
- get_epitype_display(*, field=<django.db.models.fields.PositiveIntegerField: epitype>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.transport.TCEManager object>¶
- operation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- operation_id¶
- position¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- prefetched_objects = <ferrosoft.apps.emiflow.models.transport.TCEManagerPrefetched object>¶
- property show_distance_adjustment_factor¶
Whether the form should expose the DAF input (only for actual distance).
- property show_geo_points¶
Whether the form should expose origin/destination geo-points.
Geo-points only matter for great-circle and shortest-feasible distance computations; actual distance uses the entered number.
- class ferrosoft.apps.emiflow.models.transport.TransportChainManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that upserts transport chains keyed by
reference.
- class ferrosoft.apps.emiflow.models.transport.TransportChainManagerPrefetched(*args, **kwargs)[source]¶
Bases:
TransportChainManagerVariant of
TransportChainManagerthat prefetches elements and LCC values.
- class ferrosoft.apps.emiflow.models.transport.TransportChainType(*values)[source]¶
Bases:
IntegerChoicesDirection of a transport chain relative to the booking organisation.
- DROP_SHIPMENT = 3¶
- INCOMING = 1¶
- OUTGOING = 2¶
- class ferrosoft.apps.emiflow.models.transport.TransportChainVisitor[source]¶
Bases:
ABCVisitor protocol traversed by
TransportChain.accept().Default implementations are no-ops; subclasses override only the callbacks they care about. Used by booking and report-rendering code to walk the chain without coupling either side to the iteration order.
- class ferrosoft.apps.emiflow.models.transport.TransportLCCValue(*args, **kwargs)[source]¶
Bases:
LCCValueCustom lifecycle category values for transports.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- chain¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- chain_id¶
- emission_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emission_unit_id¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lifecycle_category¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- lifecycle_category_id¶
- operation_emission_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- total_emission_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
ferrosoft.apps.emiflow.models.treatment module¶
Treatment and treatment-operation domain models.
A TreatmentOperation is the recipe: what materials go in,
what comes out, which emitter and energy carrier are involved, and how
emissions should be allocated to the outputs (by weight or manually).
A Treatment is a specific application of that recipe on a
booking date, with its own input/output lines that can deviate from
the operation defaults. Operations are certified before they can be
referenced; certifying enforces that emission intensity is set and
output allocations sum to 100 %.
- class ferrosoft.apps.emiflow.models.treatment.Allocation(method, total_allocation, total_weight, materials)[source]¶
Bases:
objectSnapshot of how a treatment operation’s emissions split across its outputs.
- materials: List[MaterialAllocation]¶
- method: AllocationMethod¶
- total_weight: DecimalWithUnit¶
- class ferrosoft.apps.emiflow.models.treatment.AllocationMethod(*values)[source]¶
Bases:
IntegerChoicesHow emissions are distributed across a treatment’s output materials.
- MANUALLY = 2¶
- WEIGHT = 1¶
- class ferrosoft.apps.emiflow.models.treatment.MaterialAllocation(material, fraction)[source]¶
Bases:
objectOne row in an
Allocation: a material and its fraction (0..1).
- class ferrosoft.apps.emiflow.models.treatment.Treatment(*args, **kwargs)[source]¶
Bases:
UUIDModelA specific run of a
TreatmentOperationon a booking date.Each treatment owns its own input and output lines so the realised quantities can deviate from the recipe; emissions are posted via
post_emission(), after which the treatment moves toPOSTEDand becomes effectively read-only.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- booking_date¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- copy_lines_from_operation()[source]¶
Seed input and output lines from the parent operation.
Idempotent and one-sided: each side (inputs, outputs) is only copied when no rows exist yet, so re-running the call after the user has edited one side will not overwrite their edits.
- get_next_by_booking_date(*, field=<django.db.models.fields.DateField: booking_date>, is_next=True, **kwargs)¶
- get_previous_by_booking_date(*, field=<django.db.models.fields.DateField: booking_date>, is_next=False, **kwargs)¶
- get_status_display(*, field=<django.db.models.fields.IntegerField: status>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- inputs¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- lcc_values¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- objects = <ferrosoft.apps.emiflow.models.treatment.TreatmentManager object>¶
- operation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- operation_id¶
- outputs¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- post_emission()[source]¶
Run the booking service, mark the treatment posted, return the records.
No-op (returns an empty list) when the treatment is not in the
OPENstatus — posting is a one-way transition.- Return type:
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class ferrosoft.apps.emiflow.models.treatment.TreatmentInputLine(*args, **kwargs)[source]¶
Bases:
TreatmentLineMaterial used as input to a treatment.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material: Material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects = <ferrosoft.apps.emiflow.models.treatment.TreatmentInputLineManager object>¶
- treatment: Treatment¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- treatment_id¶
- weight_unit: MeasurementUnit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- class ferrosoft.apps.emiflow.models.treatment.TreatmentInputLineManager(*args, **kwargs)[source]¶
Bases:
TreatmentLineManagerManager that upserts input lines keyed by
(treatment, material).
- class ferrosoft.apps.emiflow.models.treatment.TreatmentLCCValue(*args, **kwargs)[source]¶
Bases:
LCCValueCustom lifecycle category values for treatments.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- emission_unit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emission_unit_id¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lifecycle_category¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- lifecycle_category_id¶
- operation_emission_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- total_emission_value¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- treatment¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- treatment_id¶
- class ferrosoft.apps.emiflow.models.treatment.TreatmentLine(*args, **kwargs)[source]¶
Bases:
UUIDModelAbstract base for a material + weight line on either a treatment or operation.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material: Material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects¶
- property weight: DecimalWithUnit¶
Line weight paired with its unit.
- weight_unit: MeasurementUnit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- class ferrosoft.apps.emiflow.models.treatment.TreatmentLineManager(*args, **kwargs)[source]¶
Bases:
ManagerManager using
TreatmentLineQuerySetwith material/unit prefetch.
- class ferrosoft.apps.emiflow.models.treatment.TreatmentLineQuerySet(model=None, query=None, using=None, hints=None)[source]¶
Bases:
QuerySetQuerySet adding a unit-aware
sum_weightaggregation.
- class ferrosoft.apps.emiflow.models.treatment.TreatmentManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that prefetches operation, inputs, outputs, and LCC values.
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOperation(*args, **kwargs)[source]¶
Bases:
UUIDModelA reusable treatment recipe (inputs, outputs, emitter, allocation).
Operations move through
TreatmentOperationStatusfrom Open to Certified; certification is gated bycertification_errors()(intensity present + outputs allocated 100 %). Only certified operations are intended to be referenced byTreatmentrows.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- allocation_method¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- certification_errors()[source]¶
Return user-facing reasons the operation cannot yet be certified.
Currently checks that an
EmissionIntensityis attached and that output allocations sum to exactly 100 %. Returns an empty list when the operation is ready to certify.
- certify()[source]¶
Try to certify the operation; return the blocking errors if any.
On success the status is moved to
CERTIFIEDand the empty list is returned. On failure the status is left unchanged and the caller-facing error messages fromcertification_errors()are returned.
- emission_intensity¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emission_intensity_id¶
- emitter¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- emitter_id¶
- energy_carrier¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- energy_carrier_id¶
- get_allocation_method_display(*, field=<django.db.models.fields.IntegerField: allocation_method>)¶
- get_output_allocation()[source]¶
Bundle the current method, totals, and per-material allocations.
- Return type:
- get_status_display(*, field=<django.db.models.fields.IntegerField: status>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- inputs¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <ferrosoft.apps.emiflow.models.treatment.TreatmentOperationManager object>¶
- outputs¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- reference¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- treatment_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- trigger_allocation()[source]¶
Recompute
allocated_fractionon every output line from its weight.No-op when the operation uses manual allocation. Called from the post-save / post-delete signals on
TreatmentOperationOutputLineso the allocation stays consistent whenever an output is added, edited, or removed.
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOperationInputLine(*args, **kwargs)[source]¶
Bases:
TreatmentLineMaterial used as input to a treatment operation.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material: Material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects = <ferrosoft.apps.emiflow.models.treatment.TreatmentOperationInputLineManager object>¶
- operation: TreatmentOperation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- operation_id¶
- weight_unit: MeasurementUnit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOperationInputLineManager(*args, **kwargs)[source]¶
Bases:
TreatmentLineManagerManager that upserts operation input lines keyed by
(operation, material).
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOperationManager(*args, **kwargs)[source]¶
Bases:
ManagerManager that prefetches inputs, outputs, emitter, and energy carrier.
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOperationOutputLine(*args, **kwargs)[source]¶
Bases:
TreatmentLineMaterial returned by a treatment operation.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- allocated_fraction¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material: Material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects = <ferrosoft.apps.emiflow.models.treatment.TreatmentOperationOutputLineManager object>¶
- operation: TreatmentOperation¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- operation_id¶
- weight_unit: MeasurementUnit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOperationOutputLineManager(*args, **kwargs)[source]¶
Bases:
TreatmentLineManagerManager with allocation aggregation and upsert helpers.
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOperationStatus(*values)[source]¶
Bases:
IntegerChoicesLifecycle state of a
TreatmentOperation(certified ops can be referenced by treatments).- CERTIFIED = 2¶
- OPEN = 1¶
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOutputLine(*args, **kwargs)[source]¶
Bases:
TreatmentLineMaterial returned by a treatment.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- allocated_fraction¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- material: Material¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- material_id¶
- objects = <ferrosoft.apps.emiflow.models.treatment.TreatmentOutputLineManager object>¶
- treatment: Treatment¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- treatment_id¶
- weight_unit: MeasurementUnit¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- weight_unit_id¶
- class ferrosoft.apps.emiflow.models.treatment.TreatmentOutputLineManager(*args, **kwargs)[source]¶
Bases:
TreatmentLineManagerManager that upserts output lines keyed by
(treatment, material).