Initial commit: Voiced invoice desktop app
Offline-first invoicing app for Test Vendor, built by Bongbetic. - Tauri v2 (Rust) + React/TypeScript + IBM Carbon Design System UI - SQLite (rusqlite) storage with a persistent invoice-number series - Guided first-run setup, pre-filled vendor/bank details - Fixed-amount or rate x quantity line items (per sec/min/hour/session/unit) - GST as CGST+SGST or IGST, Indian amount-in-words - Optional signature, with a computer-generated note as fallback - Print-ready PDF export via @react-pdf/renderer - Windows cross-compile via cargo-xwin (NSIS installer) Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Settings {
|
||||
pub vendor_name: String,
|
||||
pub vendor_address: String,
|
||||
pub vendor_email: String,
|
||||
pub vendor_phone: String,
|
||||
pub vendor_pan: String,
|
||||
pub vendor_gstin: String,
|
||||
pub vendor_state_code: String,
|
||||
pub logo_path: Option<String>,
|
||||
pub signature_path: Option<String>,
|
||||
pub default_bank_id: Option<i64>,
|
||||
pub default_tax_rate: f64,
|
||||
pub default_tax_type: String,
|
||||
pub payment_terms_days: i64,
|
||||
pub currency: String,
|
||||
pub onboarded: bool,
|
||||
pub theme: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BankAccount {
|
||||
pub id: Option<i64>,
|
||||
#[serde(default)]
|
||||
pub label: String,
|
||||
#[serde(default)]
|
||||
pub bank_name: String,
|
||||
#[serde(default)]
|
||||
pub account_name: String,
|
||||
#[serde(default)]
|
||||
pub account_no: String,
|
||||
#[serde(default)]
|
||||
pub branch: String,
|
||||
#[serde(default)]
|
||||
pub ifsc: String,
|
||||
#[serde(default)]
|
||||
pub is_default: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InvoiceSeries {
|
||||
pub id: i64,
|
||||
pub prefix: String,
|
||||
pub padding: i64,
|
||||
pub next_number: i64,
|
||||
pub is_active: bool,
|
||||
pub created_at: String,
|
||||
/// The number the next invoice created under this series would receive.
|
||||
pub next_invoice_number: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Client {
|
||||
pub id: Option<i64>,
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub address: String,
|
||||
#[serde(default)]
|
||||
pub gstin: String,
|
||||
#[serde(default)]
|
||||
pub state_code: String,
|
||||
#[serde(default)]
|
||||
pub po_number: String,
|
||||
#[serde(default)]
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InvoiceItem {
|
||||
#[serde(default)]
|
||||
pub id: Option<i64>,
|
||||
#[serde(default)]
|
||||
pub description: String,
|
||||
/// "fixed" = a single amount; "rate" = rate x quantity.
|
||||
#[serde(default = "default_mode")]
|
||||
pub mode: String,
|
||||
#[serde(default)]
|
||||
pub rate: f64,
|
||||
/// second | minute | hour | session | unit
|
||||
#[serde(default = "default_unit")]
|
||||
pub unit: String,
|
||||
#[serde(default)]
|
||||
pub quantity: f64,
|
||||
#[serde(default)]
|
||||
pub amount: f64,
|
||||
#[serde(default)]
|
||||
pub sort_order: i64,
|
||||
}
|
||||
|
||||
fn default_mode() -> String {
|
||||
"fixed".to_string()
|
||||
}
|
||||
|
||||
fn default_unit() -> String {
|
||||
"unit".to_string()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InvoiceInput {
|
||||
pub invoice_date: String,
|
||||
#[serde(default)]
|
||||
pub due_date: String,
|
||||
#[serde(default)]
|
||||
pub client_id: Option<i64>,
|
||||
#[serde(default)]
|
||||
pub client_name: String,
|
||||
#[serde(default)]
|
||||
pub client_address: String,
|
||||
#[serde(default)]
|
||||
pub client_gstin: String,
|
||||
#[serde(default)]
|
||||
pub po_number: String,
|
||||
#[serde(default)]
|
||||
pub place_of_supply_state_code: String,
|
||||
#[serde(default)]
|
||||
pub subtotal: f64,
|
||||
#[serde(default)]
|
||||
pub discount: f64,
|
||||
#[serde(default = "default_tax_type")]
|
||||
pub tax_type: String,
|
||||
#[serde(default)]
|
||||
pub tax_rate: f64,
|
||||
#[serde(default)]
|
||||
pub cgst_amount: f64,
|
||||
#[serde(default)]
|
||||
pub sgst_amount: f64,
|
||||
#[serde(default)]
|
||||
pub igst_amount: f64,
|
||||
#[serde(default)]
|
||||
pub total: f64,
|
||||
#[serde(default)]
|
||||
pub amount_in_words: String,
|
||||
#[serde(default)]
|
||||
pub bank_account_id: Option<i64>,
|
||||
#[serde(default)]
|
||||
pub bank_snapshot: String,
|
||||
#[serde(default)]
|
||||
pub signature_path: Option<String>,
|
||||
#[serde(default)]
|
||||
pub notes: String,
|
||||
#[serde(default)]
|
||||
pub save_client: bool,
|
||||
#[serde(default)]
|
||||
pub items: Vec<InvoiceItem>,
|
||||
}
|
||||
|
||||
fn default_tax_type() -> String {
|
||||
"none".to_string()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Invoice {
|
||||
pub id: i64,
|
||||
pub number: String,
|
||||
pub series_id: Option<i64>,
|
||||
pub invoice_date: String,
|
||||
pub due_date: String,
|
||||
pub client_id: Option<i64>,
|
||||
pub client_name: String,
|
||||
pub client_address: String,
|
||||
pub client_gstin: String,
|
||||
pub po_number: String,
|
||||
pub place_of_supply_state_code: String,
|
||||
pub subtotal: f64,
|
||||
pub discount: f64,
|
||||
pub tax_type: String,
|
||||
pub tax_rate: f64,
|
||||
pub cgst_amount: f64,
|
||||
pub sgst_amount: f64,
|
||||
pub igst_amount: f64,
|
||||
pub total: f64,
|
||||
pub amount_in_words: String,
|
||||
pub bank_account_id: Option<i64>,
|
||||
pub bank_snapshot: String,
|
||||
pub signature_path: Option<String>,
|
||||
pub notes: String,
|
||||
pub status: String,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
pub items: Vec<InvoiceItem>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InvoiceSummary {
|
||||
pub id: i64,
|
||||
pub number: String,
|
||||
pub invoice_date: String,
|
||||
pub due_date: String,
|
||||
pub client_name: String,
|
||||
pub total: f64,
|
||||
pub status: String,
|
||||
pub created_at: String,
|
||||
}
|
||||
Reference in New Issue
Block a user