Skip to main content

lago_types/models/
fixed_charge.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use strum_macros::EnumString;
4use uuid::Uuid;
5
6use crate::models::PlanTax;
7
8/// Fixed charge model types.
9#[derive(Debug, Clone, Serialize, Deserialize, EnumString, PartialEq, Eq)]
10#[serde(rename_all = "snake_case")]
11#[strum(serialize_all = "snake_case")]
12pub enum FixedChargeModel {
13    /// Standard pricing model.
14    Standard,
15    /// Graduated pricing model.
16    Graduated,
17    /// Volume pricing model.
18    Volume,
19}
20
21/// Represents a fixed charge in the Lago billing system.
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct FixedCharge {
24    /// Unique identifier for the fixed charge in Lago.
25    pub lago_id: Uuid,
26    /// The Lago ID of the associated add-on.
27    pub lago_add_on_id: Option<Uuid>,
28    /// Display name for the fixed charge on invoices.
29    pub invoice_display_name: Option<String>,
30    /// The code of the associated add-on.
31    pub add_on_code: Option<String>,
32    /// When the fixed charge was created.
33    pub created_at: DateTime<Utc>,
34    /// Unique code for the fixed charge.
35    pub code: Option<String>,
36    /// The charge model to use.
37    pub charge_model: FixedChargeModel,
38    /// Whether the fixed charge is billed in advance.
39    pub pay_in_advance: Option<bool>,
40    /// Whether the fixed charge is prorated.
41    pub prorated: Option<bool>,
42    /// Fixed charge properties (model-specific configuration).
43    pub properties: Option<serde_json::Value>,
44    /// Number of units.
45    pub units: Option<f64>,
46    /// Parent fixed charge ID (for overrides).
47    pub lago_parent_id: Option<Uuid>,
48    /// Taxes applied to this fixed charge.
49    pub taxes: Option<Vec<PlanTax>>,
50}