use super::*;
pub struct AsyncPurchaseOrders {
db: Arc<PostgresDatabase>,
}
impl AsyncPurchaseOrders {
pub(crate) const fn new(db: Arc<PostgresDatabase>) -> Self {
Self { db }
}
pub async fn create_supplier(&self, input: CreateSupplier) -> Result<Supplier> {
self.db.purchase_orders().create_supplier_async(input).await
}
pub async fn get_supplier(&self, id: Uuid) -> Result<Option<Supplier>> {
self.db.purchase_orders().get_supplier_async(id).await
}
pub async fn get_supplier_by_code(&self, code: &str) -> Result<Option<Supplier>> {
self.db.purchase_orders().get_supplier_by_code_async(code).await
}
pub async fn update_supplier(&self, id: Uuid, input: UpdateSupplier) -> Result<Supplier> {
self.db.purchase_orders().update_supplier_async(id, input).await
}
pub async fn list_suppliers(&self, filter: SupplierFilter) -> Result<Vec<Supplier>> {
self.db.purchase_orders().list_suppliers_async(filter).await
}
pub async fn delete_supplier(&self, id: Uuid) -> Result<()> {
self.db.purchase_orders().delete_supplier_async(id).await
}
pub async fn create(&self, input: CreatePurchaseOrder) -> Result<PurchaseOrder> {
self.db.purchase_orders().create_async(input).await
}
pub async fn get(&self, id: Uuid) -> Result<Option<PurchaseOrder>> {
self.db.purchase_orders().get_async(id).await
}
pub async fn get_by_number(&self, po_number: &str) -> Result<Option<PurchaseOrder>> {
self.db.purchase_orders().get_by_number_async(po_number).await
}
pub async fn update(&self, id: Uuid, input: UpdatePurchaseOrder) -> Result<PurchaseOrder> {
self.db.purchase_orders().update_async(id, input).await
}
pub async fn list(&self, filter: PurchaseOrderFilter) -> Result<Vec<PurchaseOrder>> {
self.db.purchase_orders().list_async(filter).await
}
pub async fn for_supplier(&self, supplier_id: Uuid) -> Result<Vec<PurchaseOrder>> {
self.db.purchase_orders().for_supplier_async(supplier_id).await
}
pub async fn delete(&self, id: Uuid) -> Result<()> {
self.db.purchase_orders().delete_async(id).await
}
pub async fn submit(&self, id: Uuid) -> Result<PurchaseOrder> {
self.db.purchase_orders().submit_for_approval_async(id).await
}
pub async fn approve(&self, id: Uuid, approved_by: &str) -> Result<PurchaseOrder> {
self.db.purchase_orders().approve_async(id, approved_by).await
}
pub async fn send(&self, id: Uuid) -> Result<PurchaseOrder> {
self.db.purchase_orders().send_async(id).await
}
pub async fn acknowledge(
&self,
id: Uuid,
supplier_reference: Option<&str>,
) -> Result<PurchaseOrder> {
self.db.purchase_orders().acknowledge_async(id, supplier_reference).await
}
pub async fn hold(&self, id: Uuid) -> Result<PurchaseOrder> {
self.db.purchase_orders().hold_async(id).await
}
pub async fn cancel(&self, id: Uuid) -> Result<PurchaseOrder> {
self.db.purchase_orders().cancel_async(id).await
}
pub async fn receive(
&self,
id: Uuid,
items: ReceivePurchaseOrderItems,
) -> Result<PurchaseOrder> {
self.db.purchase_orders().receive_async(id, items).await
}
pub async fn complete(&self, id: Uuid) -> Result<PurchaseOrder> {
self.db.purchase_orders().complete_async(id).await
}
pub async fn add_item(
&self,
po_id: Uuid,
item: CreatePurchaseOrderItem,
) -> Result<PurchaseOrderItem> {
self.db.purchase_orders().add_item_async(po_id, item).await
}
pub async fn update_item(
&self,
item_id: Uuid,
item: CreatePurchaseOrderItem,
) -> Result<PurchaseOrderItem> {
self.db.purchase_orders().update_item_async(item_id, item).await
}
pub async fn remove_item(&self, item_id: Uuid) -> Result<()> {
self.db.purchase_orders().remove_item_async(item_id).await
}
pub async fn get_items(&self, po_id: Uuid) -> Result<Vec<PurchaseOrderItem>> {
self.db.purchase_orders().get_items_async(po_id).await
}
pub async fn count(&self, filter: PurchaseOrderFilter) -> Result<u64> {
self.db.purchase_orders().count_async(filter).await
}
pub async fn count_suppliers(&self, filter: SupplierFilter) -> Result<u64> {
self.db.purchase_orders().count_suppliers_async(filter).await
}
}
pub struct AsyncInvoices {
db: Arc<PostgresDatabase>,
}
impl AsyncInvoices {
pub(crate) const fn new(db: Arc<PostgresDatabase>) -> Self {
Self { db }
}
pub async fn create(&self, input: CreateInvoice) -> Result<Invoice> {
self.db.invoices().create_async(input).await
}
pub async fn get(&self, id: Uuid) -> Result<Option<Invoice>> {
self.db.invoices().get_async(id).await
}
pub async fn get_by_number(&self, invoice_number: &str) -> Result<Option<Invoice>> {
self.db.invoices().get_by_number_async(invoice_number).await
}
pub async fn update(&self, id: Uuid, input: UpdateInvoice) -> Result<Invoice> {
self.db.invoices().update_async(id, input).await
}
pub async fn list(&self, filter: InvoiceFilter) -> Result<Vec<Invoice>> {
self.db.invoices().list_async(filter).await
}
pub async fn for_customer(&self, customer_id: Uuid) -> Result<Vec<Invoice>> {
self.db.invoices().for_customer_async(customer_id).await
}
pub async fn for_order(&self, order_id: Uuid) -> Result<Vec<Invoice>> {
self.db.invoices().for_order_async(order_id).await
}
pub async fn delete(&self, id: Uuid) -> Result<()> {
self.db.invoices().delete_async(id).await
}
pub async fn send(&self, id: Uuid) -> Result<Invoice> {
self.db.invoices().send_async(id).await
}
pub async fn mark_viewed(&self, id: Uuid) -> Result<Invoice> {
self.db.invoices().mark_viewed_async(id).await
}
pub async fn record_payment(&self, id: Uuid, payment: RecordInvoicePayment) -> Result<Invoice> {
self.db.invoices().record_payment_async(id, payment).await
}
pub async fn void(&self, id: Uuid) -> Result<Invoice> {
self.db.invoices().void_async(id).await
}
pub async fn write_off(&self, id: Uuid) -> Result<Invoice> {
self.db.invoices().write_off_async(id).await
}
pub async fn dispute(&self, id: Uuid) -> Result<Invoice> {
self.db.invoices().dispute_async(id).await
}
pub async fn add_item(&self, invoice_id: Uuid, item: CreateInvoiceItem) -> Result<InvoiceItem> {
self.db.invoices().add_item_async(invoice_id, item).await
}
pub async fn update_item(&self, item_id: Uuid, item: CreateInvoiceItem) -> Result<InvoiceItem> {
self.db.invoices().update_item_async(item_id, item).await
}
pub async fn remove_item(&self, item_id: Uuid) -> Result<()> {
self.db.invoices().remove_item_async(item_id).await
}
pub async fn get_items(&self, invoice_id: Uuid) -> Result<Vec<InvoiceItem>> {
self.db.invoices().get_items_async(invoice_id).await
}
pub async fn recalculate(&self, id: Uuid) -> Result<Invoice> {
self.db.invoices().recalculate_invoice_async(id).await
}
pub async fn get_overdue(&self) -> Result<Vec<Invoice>> {
self.db.invoices().get_overdue_async().await
}
pub async fn count(&self, filter: InvoiceFilter) -> Result<u64> {
self.db.invoices().count_async(filter).await
}
}