use super::*;
pub struct AsyncWarranties {
db: Arc<PostgresDatabase>,
}
impl AsyncWarranties {
pub(crate) const fn new(db: Arc<PostgresDatabase>) -> Self {
Self { db }
}
pub async fn create(&self, input: CreateWarranty) -> Result<Warranty> {
self.db.warranties().create_async(input).await
}
pub async fn get(&self, id: Uuid) -> Result<Option<Warranty>> {
self.db.warranties().get_async(id.into()).await
}
pub async fn get_by_number(&self, warranty_number: &str) -> Result<Option<Warranty>> {
self.db.warranties().get_by_number_async(warranty_number).await
}
pub async fn get_by_serial(&self, serial_number: &str) -> Result<Option<Warranty>> {
self.db.warranties().get_by_serial_async(serial_number).await
}
pub async fn update(&self, id: Uuid, input: UpdateWarranty) -> Result<Warranty> {
self.db.warranties().update_async(id.into(), input).await
}
pub async fn list(&self, filter: WarrantyFilter) -> Result<Vec<Warranty>> {
self.db.warranties().list_async(filter).await
}
pub async fn for_customer(&self, customer_id: Uuid) -> Result<Vec<Warranty>> {
self.db.warranties().for_customer_async(customer_id.into()).await
}
pub async fn for_order(&self, order_id: Uuid) -> Result<Vec<Warranty>> {
self.db.warranties().for_order_async(order_id.into()).await
}
pub async fn void(&self, id: Uuid) -> Result<Warranty> {
self.db.warranties().void_async(id.into()).await
}
pub async fn expire(&self, id: Uuid) -> Result<Warranty> {
self.db.warranties().expire_async(id.into()).await
}
pub async fn transfer(&self, id: Uuid, new_customer_id: Uuid) -> Result<Warranty> {
self.db.warranties().transfer_async(id.into(), new_customer_id.into()).await
}
pub async fn create_claim(&self, input: CreateWarrantyClaim) -> Result<WarrantyClaim> {
self.db.warranties().create_claim_async(input).await
}
pub async fn get_claim(&self, id: Uuid) -> Result<Option<WarrantyClaim>> {
self.db.warranties().get_claim_async(id).await
}
pub async fn get_claim_by_number(&self, claim_number: &str) -> Result<Option<WarrantyClaim>> {
self.db.warranties().get_claim_by_number_async(claim_number).await
}
pub async fn update_claim(
&self,
id: Uuid,
input: UpdateWarrantyClaim,
) -> Result<WarrantyClaim> {
self.db.warranties().update_claim_async(id, input).await
}
pub async fn list_claims(&self, filter: WarrantyClaimFilter) -> Result<Vec<WarrantyClaim>> {
self.db.warranties().list_claims_async(filter).await
}
pub async fn get_claims(&self, warranty_id: Uuid) -> Result<Vec<WarrantyClaim>> {
self.db.warranties().get_claims_async(warranty_id.into()).await
}
pub async fn approve_claim(&self, id: Uuid) -> Result<WarrantyClaim> {
self.db.warranties().approve_claim_async(id).await
}
pub async fn deny_claim(&self, id: Uuid, reason: &str) -> Result<WarrantyClaim> {
self.db.warranties().deny_claim_async(id, reason).await
}
pub async fn complete_claim(
&self,
id: Uuid,
resolution: ClaimResolution,
) -> Result<WarrantyClaim> {
self.db.warranties().complete_claim_async(id, resolution).await
}
pub async fn cancel_claim(&self, id: Uuid) -> Result<WarrantyClaim> {
self.db.warranties().cancel_claim_async(id).await
}
pub async fn count(&self, filter: WarrantyFilter) -> Result<u64> {
self.db.warranties().count_async(filter).await
}
pub async fn count_claims(&self, filter: WarrantyClaimFilter) -> Result<u64> {
self.db.warranties().count_claims_async(filter).await
}
}
pub struct AsyncBom {
db: Arc<PostgresDatabase>,
}
impl AsyncBom {
pub(crate) const fn new(db: Arc<PostgresDatabase>) -> Self {
Self { db }
}
pub async fn create(&self, input: CreateBom) -> Result<BillOfMaterials> {
self.db.bom().create_async(input).await
}
pub async fn get(&self, id: Uuid) -> Result<Option<BillOfMaterials>> {
self.db.bom().get_async(id).await
}
pub async fn get_by_number(&self, bom_number: &str) -> Result<Option<BillOfMaterials>> {
self.db.bom().get_by_number_async(bom_number).await
}
pub async fn update(&self, id: Uuid, input: UpdateBom) -> Result<BillOfMaterials> {
self.db.bom().update_async(id, input).await
}
pub async fn list(&self, filter: BomFilter) -> Result<Vec<BillOfMaterials>> {
self.db.bom().list_async(filter).await
}
pub async fn delete(&self, id: Uuid) -> Result<()> {
self.db.bom().delete_async(id).await
}
pub async fn add_component(
&self,
bom_id: Uuid,
component: CreateBomComponent,
) -> Result<BomComponent> {
self.db.bom().add_component_async(bom_id, component).await
}
pub async fn update_component(
&self,
component_id: Uuid,
component: CreateBomComponent,
) -> Result<BomComponent> {
self.db.bom().update_component_async(component_id, component).await
}
pub async fn remove_component(&self, component_id: Uuid) -> Result<()> {
self.db.bom().remove_component_async(component_id).await
}
pub async fn activate(&self, id: Uuid) -> Result<BillOfMaterials> {
self.db.bom().activate_async(id).await
}
pub async fn count(&self, filter: BomFilter) -> Result<u64> {
self.db.bom().count_async(filter).await
}
}
pub struct AsyncWorkOrders {
db: Arc<PostgresDatabase>,
}
impl AsyncWorkOrders {
pub(crate) const fn new(db: Arc<PostgresDatabase>) -> Self {
Self { db }
}
pub async fn create(&self, input: CreateWorkOrder) -> Result<WorkOrder> {
self.db.work_orders().create_async(input).await
}
pub async fn get(&self, id: Uuid) -> Result<Option<WorkOrder>> {
self.db.work_orders().get_async(id).await
}
pub async fn get_by_number(&self, work_order_number: &str) -> Result<Option<WorkOrder>> {
self.db.work_orders().get_by_number_async(work_order_number).await
}
pub async fn update(&self, id: Uuid, input: UpdateWorkOrder) -> Result<WorkOrder> {
self.db.work_orders().update_async(id, input).await
}
pub async fn list(&self, filter: WorkOrderFilter) -> Result<Vec<WorkOrder>> {
self.db.work_orders().list_async(filter).await
}
pub async fn delete(&self, id: Uuid) -> Result<()> {
self.db.work_orders().delete_async(id).await
}
pub async fn start(&self, id: Uuid) -> Result<WorkOrder> {
self.db.work_orders().start_async(id).await
}
pub async fn complete(&self, id: Uuid, quantity_completed: Decimal) -> Result<WorkOrder> {
self.db.work_orders().complete_async(id, quantity_completed).await
}
pub async fn hold(&self, id: Uuid) -> Result<WorkOrder> {
self.db.work_orders().hold_async(id).await
}
pub async fn resume(&self, id: Uuid) -> Result<WorkOrder> {
self.db.work_orders().resume_async(id).await
}
pub async fn cancel(&self, id: Uuid) -> Result<WorkOrder> {
self.db.work_orders().cancel_async(id).await
}
pub async fn add_task(
&self,
work_order_id: Uuid,
task: CreateWorkOrderTask,
) -> Result<WorkOrderTask> {
self.db.work_orders().add_task_async(work_order_id, task).await
}
pub async fn update_task(
&self,
task_id: Uuid,
task: UpdateWorkOrderTask,
) -> Result<WorkOrderTask> {
self.db.work_orders().update_task_async(task_id, task).await
}
pub async fn remove_task(&self, task_id: Uuid) -> Result<()> {
self.db.work_orders().remove_task_async(task_id).await
}
pub async fn start_task(&self, task_id: Uuid) -> Result<WorkOrderTask> {
self.db.work_orders().start_task_async(task_id).await
}
pub async fn complete_task(
&self,
task_id: Uuid,
actual_hours: Option<Decimal>,
) -> Result<WorkOrderTask> {
self.db.work_orders().complete_task_async(task_id, actual_hours).await
}
pub async fn add_material(
&self,
work_order_id: Uuid,
material: AddWorkOrderMaterial,
) -> Result<WorkOrderMaterial> {
self.db.work_orders().add_material_async(work_order_id, material).await
}
pub async fn consume_material(
&self,
material_id: Uuid,
quantity: Decimal,
) -> Result<WorkOrderMaterial> {
self.db.work_orders().consume_material_async(material_id, quantity).await
}
pub async fn count(&self, filter: WorkOrderFilter) -> Result<u64> {
self.db.work_orders().count_async(filter).await
}
}