refactor: change amount to f32

This commit is contained in:
2025-03-05 21:55:22 +00:00
parent e6c40e5d7b
commit 36ba1f836a
5 changed files with 6 additions and 4 deletions

View File

@ -0,0 +1,2 @@
-- Add migration script here
ALTER TABLE vm_cost_plan MODIFY COLUMN amount float NOT NULL;

View File

@ -179,7 +179,7 @@ pub struct VmCostPlan {
pub id: u64,
pub name: String,
pub created: DateTime<Utc>,
pub amount: u64,
pub amount: f32,
pub currency: String,
pub interval_amount: u64,
pub interval_type: VmCostPlanIntervalType,

View File

@ -175,7 +175,7 @@ impl From<lnvps_db::VmCostPlanIntervalType> for ApiVmCostPlanIntervalType {
pub struct ApiVmCostPlan {
pub id: u64,
pub name: String,
pub amount: u64,
pub amount: f32,
pub currency: String,
pub interval_amount: u64,
pub interval_type: ApiVmCostPlanIntervalType,

View File

@ -102,7 +102,7 @@ impl Default for MockDb {
id: 1,
name: "mock".to_string(),
created: Utc::now(),
amount: 1,
amount: 1f32,
currency: "EUR".to_string(),
interval_amount: 1,
interval_type: VmCostPlanIntervalType::Month,

View File

@ -321,7 +321,7 @@ impl LNVpsProvisioner {
bail!("No exchange rate found")
};
let cost_btc = cost_plan.amount as f32 / rate;
let cost_btc = cost_plan.amount / rate;
let cost_msat = (cost_btc as f64 * BTC_SATS) as u64 * 1000;
info!("Creating invoice for {vm_id} for {} sats", cost_msat / 1000);
let invoice = self