square_api_client/models/
order_line_item_tax.rs

1//! Model struct for OrderLineItemTax type
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7use super::{
8    enums::{OrderLineItemTaxScope, OrderLineItemTaxType},
9    Money,
10};
11
12/// Represents a tax that applies to one or more line item in the order.
13///
14/// Fixed-amount, order-scoped taxes are distributed across all non-zero line item totals. The
15/// amount distributed to each line item is relative to the amount the item contributes to the order
16/// subtotal.
17#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
18pub struct OrderLineItemTax {
19    /// A unique ID that identifies the tax only within this order.
20    pub uid: Option<String>,
21    /// The catalog object ID referencing [CatalogTax].
22    pub catalog_object_id: Option<String>,
23    /// The version of the catalog object that this tax references.
24    pub catalog_version: Option<i64>,
25    /// The tax's name.
26    pub name: Option<String>,
27    /// Indicates the calculation method used to apply the tax.
28    pub r#type: Option<OrderLineItemTaxType>,
29    /// The percentage of the tax, as a string representation of a decimal number. For example, a
30    /// value of "7.25" corresponds to a percentage of 7.25%.
31    pub percentage: Option<String>,
32    /// Application-defined data attached to this tax. Metadata fields are intended to store
33    /// descriptive references or associations with an entity in another system or store brief
34    /// information about the object. Square does not process this field; it only stores and returns
35    /// it in relevant API calls. Do not use metadata to store any sensitive information (such as
36    /// personally identifiable information or card details).
37    ///
38    /// Keys written by applications must be 60 characters or less and must be in the character set
39    /// `[a-zA-Z0-9_-]`. Entries can also include metadata generated by Square. These keys are
40    /// prefixed with a namespace, separated from the key with a ':' character.
41    ///
42    /// Values have a maximum length of 255 characters.
43    ///
44    /// An application can have up to 10 entries per metadata field.
45    ///
46    /// Entries written by applications are private and can only be read or modified by the same
47    /// application.
48    ///
49    /// For more information,
50    /// see [Metadata](https://developer.squareup.com/docs/build-basics/metadata).
51    pub metadata: Option<HashMap<String, String>>,
52    /// The amount of money applied by the tax in the order.
53    pub applied_money: Option<Money>,
54    /// Indicates the level at which the tax applies. For `ORDER` scoped taxes, Square generates
55    /// references in `applied_taxes` on all order line items that do not have them. For `LINE_ITEM`
56    /// scoped taxes, the tax only applies to line items with references in their `applied_taxes`
57    /// field.
58    ///
59    /// This field is immutable. To change the scope, you must delete the tax and re-add it as a new
60    /// tax.
61    pub scope: Option<OrderLineItemTaxScope>,
62    /// **Read only** Determines whether the tax was automatically applied to the order based on the
63    /// catalog configuration. For an example, see [Automatically Apply Taxes to an
64    /// Order](https://developer.squareup.com/docs/orders-api/apply-taxes-and-discounts/auto-apply-taxes).
65    pub auto_applied: Option<bool>,
66}