use crate::controllers::Entity;
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Report {
pub slug: String,
pub description: String,
}
impl Entity for Report {
fn endpoint() -> String {
String::from("reports/")
}
fn child_endpoint(parent_id: i32) -> String {
let _ = parent_id;
String::new()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SaleReport {
pub total_sales: String,
pub net_sales: String,
pub average_sales: String,
pub total_orders: i32,
pub total_items: i32,
pub total_tax: String,
pub total_shipping: String,
pub total_refunds: i32,
pub total_discount: String,
pub totals_grouped_by: String,
pub totals: std::collections::HashMap<NaiveDate, Total>,
pub total_customers: i32,
}
impl Entity for SaleReport {
fn endpoint() -> String {
String::from("reports/sales/")
}
fn child_endpoint(parent_id: i32) -> String {
let _ = parent_id;
String::new()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Total {
pub sales: String,
pub orders: i32,
pub items: i32,
pub tax: String,
pub shipping: String,
pub discount: String,
pub customers: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TopSellersReport {
pub name: String,
pub product_id: i32,
pub quantity: i32,
}
impl Entity for TopSellersReport {
fn endpoint() -> String {
String::from("reports/top_sellers/")
}
fn child_endpoint(parent_id: i32) -> String {
let _ = parent_id;
String::new()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReportOrdersTotals {
pub slug: String,
pub name: String,
pub total: i32,
}
impl Entity for ReportOrdersTotals {
fn endpoint() -> String {
String::from("reports/orders/totals/")
}
fn child_endpoint(parent_id: i32) -> String {
let _ = parent_id;
String::new()
}
}