aeat.adapters.persistence.profile.fincas module

ORM-backed repositories for the rental-register record types.

These concrete repositories are the persistence adapter behind the read-side ports declared in domain.fincas._repository_ports. They bridge the public domain.fincas._models records and the internal adapters.persistence.storage.sql._orm mapper rows; every method routes through _flush_or_wrap so DB integrity violations surface as RepositoryError.

Living in the persistence adapter (not in domain.fincas) keeps the SQLAlchemy and ORM-row coupling out of the domain layer: the domain aggregation functions depend only on the structural * reader ports, never on this module. Storage imports remain deferred behind the methods that consult them so the module stays import-light.

class FincaRepository(session)[source]

Bases: object

Repository for Finca.

Parameters:

session (Session)

list_all()[source]

Return every record in the table, ordered by surrogate id.

Return type:

list[Finca]

Returns:

List of all Finca records.

get(record_id)[source]

Return the record with surrogate id record_id.

Parameters:

record_id (int) – Surrogate integer primary key.

Return type:

Finca

Returns:

The matching Finca record.

Raises:

RepositoryError – When no row matches.

get_by_identifier(identifier)[source]

Return the record matching identifier, or None if absent.

Return type:

Finca | None

Returns:

The matching Finca, or None when not found.

Parameters:

identifier (str)

upsert(record)[source]

Insert or update record and return the persisted entity.

Return type:

Finca

Returns:

The persisted Finca with any database-generated fields populated.

Parameters:

record (Finca)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)

class ArrendamientoRepository(session)[source]

Bases: object

Repository for Arrendamiento.

Parameters:

session (Session)

list_all()[source]

Return every Arrendamiento record in the table, ordered by surrogate id.

Return type:

list[Arrendamiento]

list_for_finca(finca_id)[source]

Return every Arrendamiento record attached to the supplied finca.

Return type:

list[Arrendamiento]

Parameters:

finca_id (int)

get(record_id)[source]

Return the record with surrogate id record_id.

Parameters:

record_id (int) – Surrogate integer primary key.

Return type:

Arrendamiento

Returns:

The matching Arrendamiento record.

Raises:

RepositoryError – When no row matches.

upsert(record)[source]

Insert or update record and return the persisted Arrendamiento.

Return type:

Arrendamiento

Parameters:

record (Arrendamiento)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)

class FincaRendimientoRepository(session)[source]

Bases: object

Repository for FincaRendimientoRecord.

Parameters:

session (Session)

list_for_period(period_year)[source]

Return every record whose period overlaps the supplied window.

Return type:

list[FincaRendimientoRecord]

Returns:

List of FincaRendimientoRecord for the given period year.

Parameters:

period_year (int)

get_for_contract_period(contract_id, period_year)[source]

Return the FincaRendimientoRecord for contract_id matching period, or None.

Return type:

FincaRendimientoRecord | None

Parameters:
  • contract_id (int)

  • period_year (int)

upsert(record)[source]

Insert or update record and return the persisted FincaRendimientoRecord.

Return type:

FincaRendimientoRecord

Parameters:

record (FincaRendimientoRecord)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)

class FincaGastoRepository(session)[source]

Bases: object

Repository for FincaGasto.

Parameters:

session (Session)

list_for_finca_period(finca_id, period_year)[source]

Return every FincaGasto record attached to finca_id within the period window.

Return type:

list[FincaGasto]

Parameters:
  • finca_id (int)

  • period_year (int)

add(record)[source]

Insert record and return the persisted FincaGasto entity.

Return type:

FincaGasto

Parameters:

record (FincaGasto)

upsert(record)[source]

Insert or update record and return the persisted entity.

Return type:

FincaGasto

Returns:

The persisted FincaGasto with any database-generated fields populated.

Parameters:

record (FincaGasto)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)

class FincaAmortizacionLedgerRepository(session)[source]

Bases: object

Repository for FincaAmortizacionLedgerEntry.

Parameters:

session (Session)

list_for_finca(finca_id)[source]

Return every record attached to the supplied finca.

Return type:

list[FincaAmortizacionLedgerEntry]

Returns:

List of FincaAmortizacionLedgerEntry for the finca.

Parameters:

finca_id (int)

get_for_finca_period(finca_id, period_year)[source]

Return the record for finca_id matching period, or None.

Return type:

FincaAmortizacionLedgerEntry | None

Returns:

The matching FincaAmortizacionLedgerEntry, or None when absent.

Parameters:
  • finca_id (int)

  • period_year (int)

upsert(record)[source]

Insert or update record and return the persisted FincaAmortizacionLedgerEntry.

Return type:

FincaAmortizacionLedgerEntry

Parameters:

record (FincaAmortizacionLedgerEntry)

delete(record_id)[source]

Delete the record with surrogate id record_id.

Return type:

None

Parameters:

record_id (int)