Improve transactionality, align invoice model with frontend

This commit is contained in:
Jon Staab
2026-05-29 13:37:11 -07:00
parent ae3e1c316e
commit 0018a5d4f3
12 changed files with 305 additions and 309 deletions
+1 -24
View File
@@ -1,6 +1,6 @@
use anyhow::{Result, anyhow};
use crate::models::{Activity, Bolt11, Intent, Invoice, InvoiceItem, Plan, Relay, Tenant};
use crate::models::{Activity, Bolt11, Invoice, Plan, Relay, Tenant};
use crate::db::pool;
fn select_tenant(tail: &str) -> String {
@@ -156,29 +156,6 @@ pub async fn list_open_invoices(tenant_pubkey: &str) -> Result<Vec<Invoice>> {
.await?)
}
pub async fn get_invoice_items_for_invoice(invoice_id: &str) -> Result<Vec<InvoiceItem>> {
Ok(
sqlx::query_as::<_, InvoiceItem>("SELECT * FROM invoice_item WHERE invoice_id = ?")
.bind(invoice_id)
.fetch_all(pool())
.await?,
)
}
// --- Intents ---
/// The Stripe PaymentIntents recorded against an invoice, newest first.
pub async fn list_intents_for_invoice(invoice_id: &str) -> Result<Vec<Intent>> {
Ok(
sqlx::query_as::<_, Intent>(
"SELECT * FROM intent WHERE invoice_id = ? ORDER BY created_at DESC",
)
.bind(invoice_id)
.fetch_all(pool())
.await?,
)
}
// --- Bolt11 ---
pub async fn get_bolt11(bolt11_id: &str) -> Result<Option<Bolt11>> {