ynab_api_async_fork/models/
new_transaction.rs

1/*
2 * YNAB API Endpoints
3 *
4 * Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body.  API Documentation is at https://api.ynab.com
5 *
6 * The version of the OpenAPI document: 1.72.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct NewTransaction {
16    #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")]
17    pub account_id: Option<String>,
18    /// The transaction date in ISO format (e.g. 2016-12-01).  Future dates (scheduled transactions) are not permitted.  Split transaction dates cannot be changed and if a different date is supplied it will be ignored.
19    #[serde(rename = "date", skip_serializing_if = "Option::is_none")]
20    pub date: Option<String>,
21    /// The transaction amount in milliunits format.  Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored.
22    #[serde(rename = "amount", skip_serializing_if = "Option::is_none")]
23    pub amount: Option<i64>,
24    /// The payee for the transaction.  To create a transfer between two accounts, use the account transfer payee pointing to the target account.  Account transfer payees are specified as `transfer_payee_id` on the account resource.
25    #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")]
26    pub payee_id: Option<String>,
27    /// The payee name.  If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee.
28    #[serde(rename = "payee_name", skip_serializing_if = "Option::is_none")]
29    pub payee_name: Option<String>,
30    /// The category for the transaction.  To configure a split transaction, you can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object.  If an existing transaction is a split, the `category_id` cannot be changed.  Credit Card Payment categories are not permitted and will be ignored if supplied.
31    #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")]
32    pub category_id: Option<String>,
33    #[serde(rename = "memo", skip_serializing_if = "Option::is_none")]
34    pub memo: Option<String>,
35    #[serde(rename = "cleared", skip_serializing_if = "Option::is_none")]
36    pub cleared: Option<crate::models::TransactionClearedStatus>,
37    /// Whether or not the transaction is approved.  If not supplied, transaction will be unapproved by default.
38    #[serde(rename = "approved", skip_serializing_if = "Option::is_none")]
39    pub approved: Option<bool>,
40    #[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")]
41    pub flag_color: Option<crate::models::TransactionFlagColor>,
42    /// An array of subtransactions to configure a transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
43    #[serde(rename = "subtransactions", skip_serializing_if = "Option::is_none")]
44    pub subtransactions: Option<Vec<crate::models::SaveSubTransaction>>,
45    /// If specified, a new transaction will be assigned this `import_id` and considered \"imported\".  We will also attempt to match this imported transaction to an existing \"user-entered\" transaction on the same account, with the same amount, and with a date +/-10 days from the imported transaction date.<br><br>Transactions imported through File Based Import or Direct Import (not through the API) are assigned an import_id in the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'.  If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'.  Using a consistent format will prevent duplicates through Direct Import and File Based Import.<br><br>If import_id is omitted or specified as null, the transaction will be treated as a \"user-entered\" transaction. As such, it will be eligible to be matched against transactions later being imported (via DI, FBI, or API).
46    #[serde(rename = "import_id", skip_serializing_if = "Option::is_none")]
47    pub import_id: Option<String>,
48}
49
50impl NewTransaction {
51    pub fn new() -> NewTransaction {
52        NewTransaction {
53            account_id: None,
54            date: None,
55            amount: None,
56            payee_id: None,
57            payee_name: None,
58            category_id: None,
59            memo: None,
60            cleared: None,
61            approved: None,
62            flag_color: None,
63            subtransactions: None,
64            import_id: None,
65        }
66    }
67}
68
69