feat: generate invoices
All checks were successful
continuous-integration/drone/push Build is passing

closes #29
This commit is contained in:
2025-05-01 17:46:37 +01:00
parent 179d70edb0
commit 1dda3a561d
10 changed files with 421 additions and 53 deletions

View File

@ -0,0 +1,19 @@
-- Add migration script here
create table company
(
id integer unsigned not null auto_increment primary key,
created timestamp not null default current_timestamp,
name varchar(100) not null,
email varchar(100) not null,
phone varchar(100),
address_1 varchar(200),
address_2 varchar(200),
city varchar(100),
state varchar(100),
postcode varchar(50),
country_code varchar(3),
tax_id varchar(50)
);
alter table vm_host_region
add column company_id integer unsigned,
add constraint fk_host_region_company foreign key (company_id) references company (id);

View File

@ -172,6 +172,9 @@ pub trait LNVpsDb: LNVPSNostrDb + Send + Sync {
/// Get access policy
async fn get_access_policy(&self, access_policy_id: u64) -> Result<AccessPolicy>;
/// Get company
async fn get_company(&self, company_id: u64) -> Result<Company>;
}
#[cfg(feature = "nostr-domain")]

View File

@ -71,6 +71,7 @@ pub struct VmHostRegion {
pub id: u64,
pub name: String,
pub enabled: bool,
pub company_id: Option<u64>,
}
#[derive(FromRow, Clone, Debug, Default)]
@ -524,3 +525,19 @@ pub struct NostrDomainHandle {
pub pubkey: Vec<u8>,
pub relays: Option<String>,
}
#[derive(FromRow, Clone, Debug, Default)]
pub struct Company {
pub id: u64,
pub created: DateTime<Utc>,
pub name: String,
pub address_1: Option<String>,
pub address_2: Option<String>,
pub city: Option<String>,
pub state: Option<String>,
pub country_code: Option<String>,
pub tax_id: Option<String>,
pub postcode: Option<String>,
pub phone: Option<String>,
pub email: Option<String>,
}

View File

@ -1,8 +1,4 @@
use crate::{
AccessPolicy, IpRange, LNVPSNostrDb, LNVpsDb, NostrDomain, NostrDomainHandle, Router, User,
UserSshKey, Vm, VmCostPlan, VmCustomPricing, VmCustomPricingDisk, VmCustomTemplate, VmHost,
VmHostDisk, VmHostRegion, VmIpAssignment, VmOsImage, VmPayment, VmTemplate,
};
use crate::{AccessPolicy, Company, IpRange, LNVPSNostrDb, LNVpsDb, NostrDomain, NostrDomainHandle, Router, User, UserSshKey, Vm, VmCostPlan, VmCustomPricing, VmCustomPricingDisk, VmCustomTemplate, VmHost, VmHostDisk, VmHostRegion, VmIpAssignment, VmOsImage, VmPayment, VmTemplate};
use anyhow::{bail, Error, Result};
use async_trait::async_trait;
use sqlx::{Executor, MySqlPool, Row};
@ -562,6 +558,14 @@ impl LNVpsDb for LNVpsDbMysql {
.await
.map_err(Error::new)
}
async fn get_company(&self, company_id: u64) -> Result<Company> {
sqlx::query_as("select * from company where id=?")
.bind(company_id)
.fetch_one(&self.db)
.await
.map_err(Error::new)
}
}
#[cfg(feature = "nostr-domain")]