square_api_client/models/order_service_charge.rs
1//! Model struct for OrderServiceCharge type
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7use super::{
8 enums::{OrderServiceChargeCalculationPhase, OrderServiceChargeType},
9 Money, OrderLineItemAppliedTax,
10};
11
12/// Represents a service charge applied to an order.
13#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
14pub struct OrderServiceCharge {
15 /// A unique ID that identifies the service charge only within this order.
16 pub uid: Option<String>,
17 /// The name of the service charge.
18 pub name: Option<String>,
19 /// The catalog object ID referencing the service charge [CatalogObject].
20 pub catalog_object_id: Option<String>,
21 /// The version of the catalog object that this service charge references.
22 pub catalog_version: Option<i64>,
23 /// The service charge percentage as a string representation of a decimal number. For example,
24 /// "7.25" indicates a service charge of 7.25%.
25 ///
26 /// Exactly 1 of `percentage` or `amount_money` should be set.
27 pub percentage: Option<String>,
28 /// The amount of a non-percentage-based service charge.
29 ///
30 /// Exactly one of `percentage` or `amount_money` should be set.
31 pub amount_money: Option<Money>,
32 /// **Read only** The amount of money applied to the order by the service charge, including any
33 /// inclusive tax amounts, as calculated by Square.
34 ///
35 /// For fixed-amount service charges, `applied_money` is equal to `amount_money`.
36 /// For percentage-based service charges, `applied_money` is the money calculated using the
37 /// percentage.
38 pub applied_money: Option<Money>,
39 /// **Read only** The total amount of money to collect for the service charge.
40 ///
41 /// Note: If an inclusive tax is applied to the service charge, `total_money` does not equal
42 /// `applied_money` plus `total_tax_money` because the inclusive tax amount is already included
43 /// in both `applied_money` and `total_tax_money`.
44 pub total_money: Option<Money>,
45 /// **Read only** The total amount of tax money to collect for the service charge.
46 pub total_tax_money: Option<Money>,
47 /// The calculation phase at which to apply the service charge.
48 pub calculation_phase: Option<OrderServiceChargeCalculationPhase>,
49 /// Indicates whether the service charge can be taxed. If set to `true`, order-level taxes
50 /// automatically apply to the service charge. Note that service charges calculated in the
51 /// `TOTAL_PHASE` cannot be marked as taxable.
52 pub taxable: Option<bool>,
53 /// The list of references to the taxes applied to this service charge. Each
54 /// `OrderLineItemAppliedTax` has a `tax_uid` that references the `uid` of a top-level
55 /// `OrderLineItemTax` that is being applied to this service charge. On reads, the amount
56 /// applied is populated.
57 ///
58 /// An `OrderLineItemAppliedTax` is automatically created on every taxable service charge for
59 /// all `ORDER` scoped taxes that are added to the order. `OrderLineItemAppliedTax` records for
60 /// `LINE_ITEM` scoped taxes must be added in requests for the tax to apply to any taxable
61 /// service charge. Taxable service charges have the `taxable` field set to `true` and
62 /// calculated in the `SUBTOTAL_PHASE`.
63 ///
64 /// To change the amount of a tax, modify the referenced top-level tax.
65 pub applied_taxes: Option<Vec<OrderLineItemAppliedTax>>,
66 /// Application-defined data attached to this service charge. Metadata fields are intended to
67 /// store descriptive references or associations with an entity in another system or store brief
68 /// information about the object. Square does not process this field; it only stores and returns
69 /// it in relevant API calls. Do not use metadata to store any sensitive information (such as
70 /// personally identifiable information or card details).
71 ///
72 /// Keys written by applications must be 60 characters or less and must be in the character set
73 /// [a-zA-Z0-9_-]. Entries can also include metadata generated by Square. These keys are
74 /// prefixed with a namespace, separated from the key with a ':' character.
75 ///
76 /// Values have a maximum length of 255 characters.
77 ///
78 /// An application can have up to 10 entries per metadata field.
79 ///
80 /// Entries written by applications are private and can only be read or modified by the same
81 /// application.
82 ///
83 /// For more information, see
84 /// [Metadata](https://developer.squareup.com/docs/build-basics/metadata).
85 pub metadata: Option<HashMap<String, String>>,
86 /// **Read only** The type of the service charge.
87 pub r#type: Option<OrderServiceChargeType>,
88}