Improve transactionality, align invoice model with frontend
This commit is contained in:
+1
-24
@@ -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>> {
|
||||
|
||||
Reference in New Issue
Block a user