Skip to main content

firefly_iii/models/
transaction_split.rs

1/*
2 * Firefly III API v6.4.14
3 *
4 * This is the documentation of the Firefly III API. Please report any bugs or issues. You may use the \"Authorize\" button to try the API below. <br><br> Please keep in mind that the demo site does **not** accept requests from `curl`, `colly`, `wget`, etc. You must use a browser or a tool like Insomnia to make your test requests. <br><br> To learn more about the idiosyncrasies of this API, please read about the API in the [Firefly III API documentation](https://docs.firefly-iii.org/references/firefly-iii/api/). <br><br> <small>This file was last generated on 2025-12-26 @ 15:17:41 (Europe/Amsterdam)</small>
5 *
6 * The version of the OpenAPI document: v6.4.14
7 * Contact: james@firefly-iii.org
8 * Generated by: https://openapi-generator.tech
9 */
10
11#![allow(unused_imports)]
12
13use crate::models::{self, *};
14use std::fmt;
15
16#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
17pub struct TransactionSplit {
18    /// User ID
19    #[serde(rename = "user", skip_serializing_if = "Option::is_none")]
20    pub user: Option<String>,
21    /// ID of the underlying transaction journal. Each transaction consists of a transaction group (see the top ID) and one or more journals making up the splits of the transaction.
22    #[serde(
23        rename = "transaction_journal_id",
24        skip_serializing_if = "Option::is_none"
25    )]
26    pub transaction_journal_id: Option<String>,
27    #[serde(rename = "type")]
28    pub r#type: models::TransactionTypeProperty,
29    /// Date of the transaction
30    #[serde(rename = "date")]
31    pub date: String,
32    /// Order of this entry in the list of transactions.
33    #[serde(rename = "order", skip_serializing_if = "Option::is_none")]
34    pub order: Option<i32>,
35    /// Indicates whether the transaction has a currency setting. For transactions this is always true.
36    #[serde(
37        rename = "object_has_currency_setting",
38        skip_serializing_if = "Option::is_none"
39    )]
40    pub object_has_currency_setting: Option<bool>,
41    /// Currency ID for the currency of this transaction.
42    #[serde(rename = "currency_id", skip_serializing_if = "Option::is_none")]
43    pub currency_id: Option<String>,
44    /// Currency code for the currency of this transaction.
45    #[serde(rename = "currency_code", skip_serializing_if = "Option::is_none")]
46    pub currency_code: Option<String>,
47    /// Currency symbol for the currency of this transaction.
48    #[serde(rename = "currency_symbol", skip_serializing_if = "Option::is_none")]
49    pub currency_symbol: Option<String>,
50    /// Currency name for the currency of this transaction.
51    #[serde(rename = "currency_name", skip_serializing_if = "Option::is_none")]
52    pub currency_name: Option<String>,
53    /// Number of decimals used in this currency.
54    #[serde(
55        rename = "currency_decimal_places",
56        skip_serializing_if = "Option::is_none"
57    )]
58    pub currency_decimal_places: Option<i32>,
59    /// Currency ID of the foreign currency, if this transaction has a foreign amount.
60    #[serde(
61        rename = "foreign_currency_id",
62        skip_serializing_if = "Option::is_none"
63    )]
64    pub foreign_currency_id: Option<String>,
65    /// Currency code of the foreign currency. Default is NULL.
66    #[serde(
67        rename = "foreign_currency_code",
68        skip_serializing_if = "Option::is_none"
69    )]
70    pub foreign_currency_code: Option<String>,
71    #[serde(
72        rename = "foreign_currency_symbol",
73        skip_serializing_if = "Option::is_none"
74    )]
75    pub foreign_currency_symbol: Option<String>,
76    /// Number of decimals in the foreign currency.
77    #[serde(
78        rename = "foreign_currency_decimal_places",
79        skip_serializing_if = "Option::is_none"
80    )]
81    pub foreign_currency_decimal_places: Option<i32>,
82    /// Returns the primary currency ID of the administration. This currency is used as the currency for all `pc_*` amount and balance fields of this account.
83    #[serde(
84        rename = "primary_currency_id",
85        skip_serializing_if = "Option::is_none"
86    )]
87    pub primary_currency_id: Option<String>,
88    /// Returns the primary currency code of the administration. This currency is used as the currency for all `pc_*` amount and balance fields of this account.
89    #[serde(
90        rename = "primary_currency_code",
91        skip_serializing_if = "Option::is_none"
92    )]
93    pub primary_currency_code: Option<String>,
94    /// See the other `primary_*` fields.
95    #[serde(
96        rename = "primary_currency_symbol",
97        skip_serializing_if = "Option::is_none"
98    )]
99    pub primary_currency_symbol: Option<String>,
100    /// See the other `primary_*` fields.
101    #[serde(
102        rename = "primary_currency_decimal_places",
103        skip_serializing_if = "Option::is_none"
104    )]
105    pub primary_currency_decimal_places: Option<i32>,
106    /// Amount of the transaction.
107    #[serde(rename = "amount")]
108    pub amount: String,
109    /// Amount of the transaction in the primary currency of this administration. The `primary_currency_*` fields reflect the currency used. This field is NULL if the user does have 'convert to primary' set to true in their settings.
110    #[serde(rename = "pc_amount", skip_serializing_if = "Option::is_none")]
111    pub pc_amount: Option<String>,
112    /// The amount in the set foreign currency. May be NULL if the transaction does not have a foreign amount.
113    #[serde(rename = "foreign_amount", skip_serializing_if = "Option::is_none")]
114    pub foreign_amount: Option<String>,
115    /// Foreign amount of the transaction in the primary currency of this administration. The `primary_currency_*` fields reflect the currency used. This field is NULL if the user does have 'convert to primary' set to true in their settings.
116    #[serde(rename = "pc_foreign_amount", skip_serializing_if = "Option::is_none")]
117    pub pc_foreign_amount: Option<String>,
118    /// The balance of the source account. This is the balance in the account's currency which may be different from this transaction, and is not provided in this model.
119    #[serde(
120        rename = "source_balance_after",
121        skip_serializing_if = "Option::is_none"
122    )]
123    pub source_balance_after: Option<String>,
124    /// The balance of the source account in the primary currency of this administration. The `primary_currency_*` fields reflect the currency used. This field is NULL if the user does have 'convert to primary' set to true in their settings.
125    #[serde(
126        rename = "pc_source_balance_after",
127        skip_serializing_if = "Option::is_none"
128    )]
129    pub pc_source_balance_after: Option<String>,
130    /// The balance of the destination account. This is the balance in the account's currency which may be different from this transaction, and is not provided in this model.
131    #[serde(
132        rename = "destination_balance_after",
133        skip_serializing_if = "Option::is_none"
134    )]
135    pub destination_balance_after: Option<String>,
136    /// The balance of the destination account in the primary currency of this administration. The `primary_currency_*` fields reflect the currency used. This field is NULL if the user does have 'convert to primary' set to true in their settings.
137    #[serde(
138        rename = "pc_destination_balance_after",
139        skip_serializing_if = "Option::is_none"
140    )]
141    pub pc_destination_balance_after: Option<String>,
142    /// Description of the transaction.
143    #[serde(rename = "description")]
144    pub description: String,
145    /// ID of the source account. For a withdrawal or a transfer, this must always be an asset account. For deposits, this must be a revenue account.
146    #[serde(rename = "source_id")]
147    pub source_id: Option<String>,
148    /// Name of the source account. For a withdrawal or a transfer, this must always be an asset account. For deposits, this must be a revenue account. Can be used instead of the source_id. If the transaction is a deposit, the source_name can be filled in freely: the account will be created based on the name.
149    #[serde(rename = "source_name", skip_serializing_if = "Option::is_none")]
150    pub source_name: Option<String>,
151    #[serde(rename = "source_iban", skip_serializing_if = "Option::is_none")]
152    pub source_iban: Option<String>,
153    #[serde(rename = "source_type", skip_serializing_if = "Option::is_none")]
154    pub source_type: Option<models::AccountTypeProperty>,
155    /// ID of the destination account. For a deposit or a transfer, this must always be an asset account. For withdrawals this must be an expense account.
156    #[serde(rename = "destination_id")]
157    pub destination_id: Option<String>,
158    /// Name of the destination account. You can submit the name instead of the ID. For everything except transfers, the account will be auto-generated if unknown, so submitting a name is enough.
159    #[serde(rename = "destination_name", skip_serializing_if = "Option::is_none")]
160    pub destination_name: Option<String>,
161    #[serde(rename = "destination_iban", skip_serializing_if = "Option::is_none")]
162    pub destination_iban: Option<String>,
163    #[serde(rename = "destination_type", skip_serializing_if = "Option::is_none")]
164    pub destination_type: Option<models::AccountTypeProperty>,
165    /// The budget ID for this transaction.
166    #[serde(rename = "budget_id", skip_serializing_if = "Option::is_none")]
167    pub budget_id: Option<String>,
168    /// The name of the budget used.
169    #[serde(rename = "budget_name", skip_serializing_if = "Option::is_none")]
170    pub budget_name: Option<String>,
171    /// The category ID for this transaction.
172    #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")]
173    pub category_id: Option<String>,
174    /// The name of the category to be used. If the category is unknown, it will be created. If the ID and the name point to different categories, the ID overrules the name.
175    #[serde(rename = "category_name", skip_serializing_if = "Option::is_none")]
176    pub category_name: Option<String>,
177    /// The associated subscription ID for this transaction. `bill` refers to the OLD name for subscriptions and this field will be removed.
178    #[serde(rename = "bill_id", skip_serializing_if = "Option::is_none")]
179    pub bill_id: Option<String>,
180    /// The associated subscription name for this transaction. `bill` refers to the OLD name for subscriptions and this field will be removed.
181    #[serde(rename = "bill_name", skip_serializing_if = "Option::is_none")]
182    pub bill_name: Option<String>,
183    /// The associated subscription ID for this transaction.
184    #[serde(rename = "subscription_id", skip_serializing_if = "Option::is_none")]
185    pub subscription_id: Option<String>,
186    /// The associated subscription name for this transaction.
187    #[serde(rename = "subscription_name", skip_serializing_if = "Option::is_none")]
188    pub subscription_name: Option<String>,
189    /// If the transaction has been reconciled already. When you set this, the amount can no longer be edited by the user.
190    #[serde(rename = "reconciled", skip_serializing_if = "Option::is_none")]
191    pub reconciled: Option<bool>,
192    #[serde(rename = "notes", skip_serializing_if = "Option::is_none")]
193    pub notes: Option<String>,
194    /// Array of tags.
195    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
196    pub tags: Option<Vec<String>>,
197    /// Reference to internal reference of other systems.
198    #[serde(rename = "internal_reference", skip_serializing_if = "Option::is_none")]
199    pub internal_reference: Option<String>,
200    /// Reference to external ID in other systems.
201    #[serde(rename = "external_id", skip_serializing_if = "Option::is_none")]
202    pub external_id: Option<String>,
203    /// External, custom URL for this transaction.
204    #[serde(rename = "external_url", skip_serializing_if = "Option::is_none")]
205    pub external_url: Option<String>,
206    /// System generated identifier for original creator of transaction.
207    #[serde(rename = "original_source", skip_serializing_if = "Option::is_none")]
208    pub original_source: Option<String>,
209    /// Reference to recurrence that made the transaction.
210    #[serde(rename = "recurrence_id", skip_serializing_if = "Option::is_none")]
211    pub recurrence_id: Option<String>,
212    /// Total number of transactions expected to be created by this recurrence repetition. Will be 0 if infinite.
213    #[serde(rename = "recurrence_total", skip_serializing_if = "Option::is_none")]
214    pub recurrence_total: Option<i32>,
215    /// The # of the current transaction created under this recurrence.
216    #[serde(rename = "recurrence_count", skip_serializing_if = "Option::is_none")]
217    pub recurrence_count: Option<i32>,
218    /// Hash value of original import transaction (for duplicate detection).
219    #[serde(rename = "import_hash_v2", skip_serializing_if = "Option::is_none")]
220    pub import_hash_v2: Option<String>,
221    /// SEPA Clearing Code
222    #[serde(rename = "sepa_cc", skip_serializing_if = "Option::is_none")]
223    pub sepa_cc: Option<String>,
224    /// SEPA Opposing Account Identifier
225    #[serde(rename = "sepa_ct_op", skip_serializing_if = "Option::is_none")]
226    pub sepa_ct_op: Option<String>,
227    /// SEPA end-to-end Identifier
228    #[serde(rename = "sepa_ct_id", skip_serializing_if = "Option::is_none")]
229    pub sepa_ct_id: Option<String>,
230    /// SEPA mandate identifier
231    #[serde(rename = "sepa_db", skip_serializing_if = "Option::is_none")]
232    pub sepa_db: Option<String>,
233    /// SEPA Country
234    #[serde(rename = "sepa_country", skip_serializing_if = "Option::is_none")]
235    pub sepa_country: Option<String>,
236    /// SEPA External Purpose indicator
237    #[serde(rename = "sepa_ep", skip_serializing_if = "Option::is_none")]
238    pub sepa_ep: Option<String>,
239    /// SEPA Creditor Identifier
240    #[serde(rename = "sepa_ci", skip_serializing_if = "Option::is_none")]
241    pub sepa_ci: Option<String>,
242    /// SEPA Batch ID
243    #[serde(rename = "sepa_batch_id", skip_serializing_if = "Option::is_none")]
244    pub sepa_batch_id: Option<String>,
245    #[serde(rename = "interest_date", skip_serializing_if = "Option::is_none")]
246    pub interest_date: Option<String>,
247    #[serde(rename = "book_date", skip_serializing_if = "Option::is_none")]
248    pub book_date: Option<String>,
249    #[serde(rename = "process_date", skip_serializing_if = "Option::is_none")]
250    pub process_date: Option<String>,
251    #[serde(rename = "due_date", skip_serializing_if = "Option::is_none")]
252    pub due_date: Option<String>,
253    #[serde(rename = "payment_date", skip_serializing_if = "Option::is_none")]
254    pub payment_date: Option<String>,
255    #[serde(rename = "invoice_date", skip_serializing_if = "Option::is_none")]
256    pub invoice_date: Option<String>,
257    /// Latitude of the transaction's location, if applicable. Can be used to draw a map.
258    #[serde(rename = "latitude", skip_serializing_if = "Option::is_none")]
259    pub latitude: Option<f64>,
260    /// Latitude of the transaction's location, if applicable. Can be used to draw a map.
261    #[serde(rename = "longitude", skip_serializing_if = "Option::is_none")]
262    pub longitude: Option<f64>,
263    /// Zoom level for the map, if drawn. This to set the box right. Unfortunately this is a proprietary value because each map provider has different zoom levels.
264    #[serde(rename = "zoom_level", skip_serializing_if = "Option::is_none")]
265    pub zoom_level: Option<i32>,
266    /// If the transaction has attachments.
267    #[serde(rename = "has_attachments", skip_serializing_if = "Option::is_none")]
268    pub has_attachments: Option<bool>,
269}
270
271impl TransactionSplit {
272    pub fn new(
273        r#type: models::TransactionTypeProperty,
274        date: String,
275        amount: String,
276        description: String,
277        source_id: Option<String>,
278        destination_id: Option<String>,
279    ) -> TransactionSplit {
280        TransactionSplit {
281            user: None,
282            transaction_journal_id: None,
283            r#type,
284            date,
285            order: None,
286            object_has_currency_setting: None,
287            currency_id: None,
288            currency_code: None,
289            currency_symbol: None,
290            currency_name: None,
291            currency_decimal_places: None,
292            foreign_currency_id: None,
293            foreign_currency_code: None,
294            foreign_currency_symbol: None,
295            foreign_currency_decimal_places: None,
296            primary_currency_id: None,
297            primary_currency_code: None,
298            primary_currency_symbol: None,
299            primary_currency_decimal_places: None,
300            amount,
301            pc_amount: None,
302            foreign_amount: None,
303            pc_foreign_amount: None,
304            source_balance_after: None,
305            pc_source_balance_after: None,
306            destination_balance_after: None,
307            pc_destination_balance_after: None,
308            description,
309            source_id,
310            source_name: None,
311            source_iban: None,
312            source_type: None,
313            destination_id,
314            destination_name: None,
315            destination_iban: None,
316            destination_type: None,
317            budget_id: None,
318            budget_name: None,
319            category_id: None,
320            category_name: None,
321            bill_id: None,
322            bill_name: None,
323            subscription_id: None,
324            subscription_name: None,
325            reconciled: None,
326            notes: None,
327            tags: None,
328            internal_reference: None,
329            external_id: None,
330            external_url: None,
331            original_source: None,
332            recurrence_id: None,
333            recurrence_total: None,
334            recurrence_count: None,
335            import_hash_v2: None,
336            sepa_cc: None,
337            sepa_ct_op: None,
338            sepa_ct_id: None,
339            sepa_db: None,
340            sepa_country: None,
341            sepa_ep: None,
342            sepa_ci: None,
343            sepa_batch_id: None,
344            interest_date: None,
345            book_date: None,
346            process_date: None,
347            due_date: None,
348            payment_date: None,
349            invoice_date: None,
350            latitude: None,
351            longitude: None,
352            zoom_level: None,
353            has_attachments: None,
354        }
355    }
356}
357
358impl fmt::Display for TransactionSplit {
359    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
360        match serde_json::to_string(self) {
361            Ok(json) => write!(f, "{}", json),
362            Err(_) => write!(f, "{{{{}}}}"),
363        }
364    }
365}