Actions
components.payment_gateway.subcomponents.ledgers.business_logic.actions.ledger_actions ¶
LedgerActions ¶
This class contains all the actions related to ledgers.
create_ledger ¶
Create a ledger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description
|
str
|
The description of the ledger. |
required |
reference
|
str | None
|
An optional reference to the ledger. |
None
|
Source code in components/payment_gateway/subcomponents/ledgers/business_logic/actions/ledger_actions.py
record_entry ¶
record_entry(
session,
/,
id,
amount,
occurred_at,
description=None,
reference=None,
metadata=None,
external_transaction_id=None,
)
Record a new entry in a ledger.
This entry will become the latest entry in the ledger. This operation performs the required bookkeeping on balances in the process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
LedgerId
|
The ID of the ledger. |
required |
amount
|
int
|
The amount of the entry. |
required |
occurred_at
|
datetime
|
The time the event occurred (not the time we process it). |
required |
description
|
str | None
|
An optional description of the entry. |
None
|
reference
|
str | None
|
An optional reference to the entry. |
None
|
metadata
|
dict | None
|
An optional metadata dictionary. |
None
|
external_transaction_id
|
str | None
|
An optional external transaction ID. Useful for recording transactions from external systems. |
None
|
Source code in components/payment_gateway/subcomponents/ledgers/business_logic/actions/ledger_actions.py
record_entry_overwriting_created_at ¶
record_entry_overwriting_created_at(
session,
/,
id,
amount,
occurred_at,
created_at,
description=None,
reference=None,
metadata=None,
external_transaction_id=None,
)
Record a new entry in a ledger overwriting the created_at param. ⚠️ WARNING: This method should be used carefully, as it can break the linear history of a ledger if not used carefully
Should only be called from the LedgerLogic.record_entry_overwriting_created_at method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
LedgerId
|
The ID of the ledger. |
required |
amount
|
int
|
The amount of the entry. |
required |
occurred_at
|
datetime
|
The time the event occurred (not the time we process it). |
required |
description
|
str | None
|
An optional description of the entry. |
None
|
reference
|
str | None
|
An optional reference to the entry. |
None
|
metadata
|
dict | None
|
An optional metadata dictionary. |
None
|
external_transaction_id
|
str | None
|
An optional external transaction ID. Useful for recording transactions from external systems. |
None
|
created_at
|
datetime
|
An optional time at which the entry was created. Allows to write an entry in the past and recomputes all entries past this date. This param should only be passed from the record_entry_overwriting_created_at method. |
required |
Source code in components/payment_gateway/subcomponents/ledgers/business_logic/actions/ledger_actions.py
terminate_ledger ¶
Terminate a ledger.
The operation is idempotent, i.e. it has no effect on already terminated entities.
Ledgers in terminal state cannot be modified or used anymore. Any
attempt to use or retrieve a terminated ledger will raise a
LedgerTerminatedException.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
LedgerId
|
The ID of the ledger to terminate. |
required |