mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
new enum variant
This commit is contained in:
1 parent
908f5cd3d6
commit
413c286470
1 file changed
+11
+11
@@ -41,6 +41,10 @@ pub enum WalletLedgerEntryType {
|
||||
#[serde(rename = "refund_banked")]
|
||||
RefundBanked,
|
||||
|
||||
/// Support staff manually credit account
|
||||
#[serde(rename = "staff_credit_banked")]
|
||||
StaffCreditBanked,
|
||||
|
||||
// TODO: No clean way to do "mixed" refunds yet, and if we
|
||||
// refund close to the cutoff it might be unfair. Let's
|
||||
// just not do monthly refunds yet and instead credit our
|
||||
@@ -66,6 +70,7 @@ impl WalletLedgerEntryType {
|
||||
Self::DeductBanked => "deduct_banked",
|
||||
Self::DeductMonthly => "deduct_monthly",
|
||||
Self::RefundBanked => "refund_banked",
|
||||
Self::StaffCreditBanked => "staff_credit_banked",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +83,7 @@ impl WalletLedgerEntryType {
|
||||
"deduct_banked" => Ok(Self::DeductBanked),
|
||||
"deduct_monthly" => Ok(Self::DeductMonthly),
|
||||
"refund_banked" => Ok(Self::RefundBanked),
|
||||
"staff_credit_banked" => Ok(Self::StaffCreditBanked),
|
||||
_ => Err(format!("invalid value: {:?}", value)),
|
||||
}
|
||||
}
|
||||
@@ -93,6 +99,7 @@ impl WalletLedgerEntryType {
|
||||
Self::DeductBanked,
|
||||
Self::DeductMonthly,
|
||||
Self::RefundBanked,
|
||||
Self::StaffCreditBanked,
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -114,6 +121,7 @@ mod tests {
|
||||
assert_serialization(WalletLedgerEntryType::DeductBanked, "deduct_banked");
|
||||
assert_serialization(WalletLedgerEntryType::DeductMonthly, "deduct_monthly");
|
||||
assert_serialization(WalletLedgerEntryType::RefundBanked, "refund_banked");
|
||||
assert_serialization(WalletLedgerEntryType::StaffCreditBanked, "staff_credit_banked");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +137,7 @@ mod tests {
|
||||
assert_eq!(WalletLedgerEntryType::DeductBanked.to_str(), "deduct_banked");
|
||||
assert_eq!(WalletLedgerEntryType::DeductMonthly.to_str(), "deduct_monthly");
|
||||
assert_eq!(WalletLedgerEntryType::RefundBanked.to_str(), "refund_banked");
|
||||
assert_eq!(WalletLedgerEntryType::StaffCreditBanked.to_str(), "staff_credit_banked");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -140,6 +149,7 @@ mod tests {
|
||||
assert_eq!(WalletLedgerEntryType::from_str("deduct_banked").unwrap(), WalletLedgerEntryType::DeductBanked);
|
||||
assert_eq!(WalletLedgerEntryType::from_str("deduct_monthly").unwrap(), WalletLedgerEntryType::DeductMonthly);
|
||||
assert_eq!(WalletLedgerEntryType::from_str("refund_banked").unwrap(), WalletLedgerEntryType::RefundBanked);
|
||||
assert_eq!(WalletLedgerEntryType::from_str("staff_credit_banked").unwrap(), WalletLedgerEntryType::StaffCreditBanked);
|
||||
assert!(WalletLedgerEntryType::from_str("foo").is_err());
|
||||
}
|
||||
}
|
||||
@@ -158,6 +168,7 @@ mod tests {
|
||||
assert_eq!(variants.pop_first(), Some(WalletLedgerEntryType::DeductBanked));
|
||||
assert_eq!(variants.pop_first(), Some(WalletLedgerEntryType::DeductMonthly));
|
||||
assert_eq!(variants.pop_first(), Some(WalletLedgerEntryType::RefundBanked));
|
||||
assert_eq!(variants.pop_first(), Some(WalletLedgerEntryType::StaffCreditBanked));
|
||||
assert_eq!(variants.pop_first(), None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user