Repository: juspay/hyperswitch
File: crates/diesel_models/src/invoice.rs (Rust)

Code before:
    table_name = invoices,
    primary_key(invoice_id),
    check_for_backend(diesel::pg::Pg)
)]
pub struct Invoice {
    pub invoice_id: String,
    pub subscription_id: Option<String>,
    pub connector_subscription_id: Option<String>,
    pub merchant_id: common_utils::id_type::MerchantId,
    pub profile_id: common_utils::id_type::ProfileId,
    pub merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
    pub payment_intent_id: String,
    pub payment_method_id: Option<String>,
    pub customer_id: common_utils::id_type::CustomerId,
    pub amount: i32,
    pub currency: String,
    pub status: String,
    pub provider_name: String,
    pub metadata: Option<serde_json::Value>,
    pub created_at: time::PrimitiveDateTime,
    pub modified_at: time::PrimitiveDateTime,
}

#[derive(Clone, Debug, Eq, PartialEq, AsChangeset, Deserialize)]
#[diesel(table_name = invoices)]
pub struct InvoiceUpdate {
    pub status: Option<String>,
    pub payment_method_id: Option<String>,
    pub modified_at: time::PrimitiveDateTime,
}

impl InvoiceNew {
    #[allow(clippy::too_many_arguments)]
    pub fn new(
        invoice_id: String,
        subscription_id: Option<String>,
        connector_subscription_id: Option<String>,
        merchant_id: common_utils::id_type::MerchantId,
        profile_id: common_utils::id_type::ProfileId,
        merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
        payment_intent_id: String,
        payment_method_id: Option<String>,
        customer_id: common_utils::id_type::CustomerId,
        amount: i32,
        currency: String,
        status: String,
        provider_name: String,
        metadata: Option<SecretSerdeValue>,
    ) -> Self {
        let now = common_utils::date_time::now();
        Self {

Review comment (suggestion):
```suggestion
    pub status: Option<InvoiceStatus>,
```

Code after:
    table_name = invoice,
    primary_key(id),
    check_for_backend(diesel::pg::Pg)
)]
pub struct Invoice {
    id: String,
    subscription_id: String,
    merchant_id: common_utils::id_type::MerchantId,
    profile_id: common_utils::id_type::ProfileId,
    merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
    payment_intent_id: Option<common_utils::id_type::PaymentId>,
    payment_method_id: Option<String>,
    customer_id: common_utils::id_type::CustomerId,
    amount: MinorUnit,
    currency: String,
    status: String,
    provider_name: Connector,
    metadata: Option<SecretSerdeValue>,
    created_at: time::PrimitiveDateTime,
    modified_at: time::PrimitiveDateTime,
}

#[derive(Clone, Debug, Eq, PartialEq, AsChangeset, Deserialize)]
#[diesel(table_name = invoice)]
pub struct InvoiceUpdate {
    pub status: Option<String>,
    pub payment_method_id: Option<String>,
    pub modified_at: time::PrimitiveDateTime,
}

impl InvoiceNew {
    #[allow(clippy::too_many_arguments)]
    pub fn new(
        id: String,
        subscription_id: String,
        merchant_id: common_utils::id_type::MerchantId,
        profile_id: common_utils::id_type::ProfileId,
        merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
        payment_intent_id: Option<common_utils::id_type::PaymentId>,
        payment_method_id: Option<String>,
        customer_id: common_utils::id_type::CustomerId,
        amount: MinorUnit,
        currency: String,
        status: InvoiceStatus,
        provider_name: Connector,
        metadata: Option<SecretSerdeValue>,
    ) -> Self {
        let now = common_utils::date_time::now();
        Self {
            id,
            subscription_id,