Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/data_models/src/payouts/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub struct Payouts {
pub attempt_count: i16,
pub profile_id: String,
pub status: storage_enums::PayoutStatus,
pub confirm: Option<bool>,
}

#[derive(Clone, Debug, Eq, PartialEq)]
Expand All @@ -108,9 +109,10 @@ pub struct PayoutsNew {
pub metadata: Option<pii::SecretSerdeValue>,
pub created_at: Option<PrimitiveDateTime>,
pub last_modified_at: Option<PrimitiveDateTime>,
pub attempt_count: i16,
pub profile_id: String,
pub status: storage_enums::PayoutStatus,
pub attempt_count: i16,
pub confirm: Option<bool>,
}

impl Default for PayoutsNew {
Expand All @@ -135,9 +137,10 @@ impl Default for PayoutsNew {
metadata: Option::default(),
created_at: Some(now),
last_modified_at: Some(now),
attempt_count: 1,
profile_id: String::default(),
status: storage_enums::PayoutStatus::default(),
attempt_count: 1,
confirm: None,
}
}
}
Expand All @@ -156,6 +159,7 @@ pub enum PayoutsUpdate {
metadata: Option<pii::SecretSerdeValue>,
profile_id: Option<String>,
status: Option<storage_enums::PayoutStatus>,
confirm: Option<bool>,
},
PayoutMethodIdUpdate {
payout_method_id: String,
Expand Down Expand Up @@ -186,6 +190,7 @@ pub struct PayoutsUpdateInternal {
pub profile_id: Option<String>,
pub status: Option<storage_enums::PayoutStatus>,
pub attempt_count: Option<i16>,
pub confirm: Option<bool>,
}

impl From<PayoutsUpdate> for PayoutsUpdateInternal {
Expand All @@ -203,6 +208,7 @@ impl From<PayoutsUpdate> for PayoutsUpdateInternal {
metadata,
profile_id,
status,
confirm,
} => Self {
amount: Some(amount),
destination_currency: Some(destination_currency),
Expand All @@ -215,6 +221,7 @@ impl From<PayoutsUpdate> for PayoutsUpdateInternal {
metadata,
profile_id,
status,
confirm,
..Default::default()
},
PayoutsUpdate::PayoutMethodIdUpdate { payout_method_id } => Self {
Expand Down
11 changes: 10 additions & 1 deletion crates/diesel_models/src/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct Payouts {
pub attempt_count: i16,
pub profile_id: String,
pub status: storage_enums::PayoutStatus,
pub confirm: Option<bool>,
}

#[derive(
Expand Down Expand Up @@ -67,9 +68,10 @@ pub struct PayoutsNew {
pub created_at: Option<PrimitiveDateTime>,
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub last_modified_at: Option<PrimitiveDateTime>,
pub attempt_count: i16,
pub profile_id: String,
pub status: storage_enums::PayoutStatus,
pub attempt_count: i16,
pub confirm: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -86,6 +88,7 @@ pub enum PayoutsUpdate {
metadata: Option<pii::SecretSerdeValue>,
profile_id: Option<String>,
status: Option<storage_enums::PayoutStatus>,
confirm: Option<bool>,
},
PayoutMethodIdUpdate {
payout_method_id: String,
Expand Down Expand Up @@ -118,6 +121,7 @@ pub struct PayoutsUpdateInternal {
pub status: Option<storage_enums::PayoutStatus>,
pub last_modified_at: PrimitiveDateTime,
pub attempt_count: Option<i16>,
pub confirm: Option<bool>,
}

impl Default for PayoutsUpdateInternal {
Expand All @@ -137,6 +141,7 @@ impl Default for PayoutsUpdateInternal {
status: None,
last_modified_at: common_utils::date_time::now(),
attempt_count: None,
confirm: None,
}
}
}
Expand All @@ -156,6 +161,7 @@ impl From<PayoutsUpdate> for PayoutsUpdateInternal {
metadata,
profile_id,
status,
confirm,
} => Self {
amount: Some(amount),
destination_currency: Some(destination_currency),
Expand All @@ -168,6 +174,7 @@ impl From<PayoutsUpdate> for PayoutsUpdateInternal {
metadata,
profile_id,
status,
confirm,
..Default::default()
},
PayoutsUpdate::PayoutMethodIdUpdate { payout_method_id } => Self {
Expand Down Expand Up @@ -207,6 +214,7 @@ impl PayoutsUpdate {
status,
last_modified_at,
attempt_count,
confirm,
} = self.into();
Payouts {
amount: amount.unwrap_or(source.amount),
Expand All @@ -223,6 +231,7 @@ impl PayoutsUpdate {
status: status.unwrap_or(source.status),
last_modified_at,
attempt_count: attempt_count.unwrap_or(source.attempt_count),
confirm: confirm.or(source.confirm),
..source
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ diesel::table! {
#[max_length = 64]
profile_id -> Varchar,
status -> PayoutStatus,
confirm -> Nullable<Bool>,
}
}

Expand Down
Loading