refactor: change amount to f32
This commit is contained in:
2
lnvps_db/migrations/20250305215123_amount-float.sql
Normal file
2
lnvps_db/migrations/20250305215123_amount-float.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
-- Add migration script here
|
||||||
|
ALTER TABLE vm_cost_plan MODIFY COLUMN amount float NOT NULL;
|
@ -179,7 +179,7 @@ pub struct VmCostPlan {
|
|||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub created: DateTime<Utc>,
|
pub created: DateTime<Utc>,
|
||||||
pub amount: u64,
|
pub amount: f32,
|
||||||
pub currency: String,
|
pub currency: String,
|
||||||
pub interval_amount: u64,
|
pub interval_amount: u64,
|
||||||
pub interval_type: VmCostPlanIntervalType,
|
pub interval_type: VmCostPlanIntervalType,
|
||||||
|
@ -175,7 +175,7 @@ impl From<lnvps_db::VmCostPlanIntervalType> for ApiVmCostPlanIntervalType {
|
|||||||
pub struct ApiVmCostPlan {
|
pub struct ApiVmCostPlan {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub amount: u64,
|
pub amount: f32,
|
||||||
pub currency: String,
|
pub currency: String,
|
||||||
pub interval_amount: u64,
|
pub interval_amount: u64,
|
||||||
pub interval_type: ApiVmCostPlanIntervalType,
|
pub interval_type: ApiVmCostPlanIntervalType,
|
||||||
|
@ -102,7 +102,7 @@ impl Default for MockDb {
|
|||||||
id: 1,
|
id: 1,
|
||||||
name: "mock".to_string(),
|
name: "mock".to_string(),
|
||||||
created: Utc::now(),
|
created: Utc::now(),
|
||||||
amount: 1,
|
amount: 1f32,
|
||||||
currency: "EUR".to_string(),
|
currency: "EUR".to_string(),
|
||||||
interval_amount: 1,
|
interval_amount: 1,
|
||||||
interval_type: VmCostPlanIntervalType::Month,
|
interval_type: VmCostPlanIntervalType::Month,
|
||||||
|
@ -321,7 +321,7 @@ impl LNVpsProvisioner {
|
|||||||
bail!("No exchange rate found")
|
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;
|
let cost_msat = (cost_btc as f64 * BTC_SATS) as u64 * 1000;
|
||||||
info!("Creating invoice for {vm_id} for {} sats", cost_msat / 1000);
|
info!("Creating invoice for {vm_id} for {} sats", cost_msat / 1000);
|
||||||
let invoice = self
|
let invoice = self
|
||||||
|
Reference in New Issue
Block a user