Changes between Version 8 and Version 9 of App


Ignore:
Timestamp:
09/08/25 19:00:35 (11 hours ago)
Author:
163080
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • App

    v8 v9  
    1 **SQL Views**
     1= SQL Views =
    22
    3 The application uses SQL VIEWs to simplify common queries and improve maintainability:
     3The application uses SQL VIEWs to simplify common queries and improve maintainability.
    44
    5 `invoice_summary`
     5== v_invoice_analytics ==
    66
    7 - **Purpose**: Shows invoice info with client and company names
    8 - **What it does**: Joins Invoice, Client, and Tenant tables to display invoice details with client name and company name
    9 - **Usage**: Makes it easier to see which client each invoice belongs to without writing complex JOINs
     7'''Purpose''': Shows invoice info with client and company names plus business calculations
     8
     9'''What it does''': Joins Invoice, Client, and Tenant tables and calculates days overdue, payment status, and value categories
     10
     11'''Usage''': Makes it easier to see which client each invoice belongs to and get business insights without writing complex queries
    1012
    1113{{{
    12 SELECT * FROM invoice_summary WHERE invoice_status = 'PENDING';
     14SELECT * FROM v_invoice_analytics WHERE invoice_status = 'PENDING';
    1315}}}
    1416
    15 `client_totals`
     17== v_client_financial_summary ==
    1618
    17 - **Purpose**: Shows total amounts for each client
    18 - **What it does**: Groups invoices by client and calculates total paid, pending, overdue amounts
    19 - **Usage**: Provides a quick overview of each client's financial status
     19'''Purpose''': Shows total amounts for each client with risk analysis
     20
     21'''What it does''': Groups invoices by client and calculates total paid, pending, overdue amounts plus payment behavior and risk levels
     22
     23'''Usage''': Provides a complete overview of each client's financial status and payment history
    2024
    2125{{{
    22 SELECT * FROM client_totals ORDER BY total_invoiced DESC;
     26SELECT * FROM v_client_financial_summary ORDER BY total_invoiced DESC;
    2327}}}
    2428
    25 API Integration
     29= API Integration =
    2630
    2731The views are used in API endpoints to provide simplified data access:
    2832
    29 - `src/app/api/clients/summary/route.ts`: Uses `client_totals` view for client financial summaries
    30 - `src/app/api/invoices/totals/route.ts`: Uses `invoice_summary` view for invoice analytics
     33src/app/api/clients/summary/route.ts: Uses v_client_financial_summary view for detailed client analytics
    3134
    32 Benefits
     35src/app/api/invoices/totals/route.ts: Uses v_invoice_analytics view for invoice analytics
    3336
    34 - **Simpler queries**: No need to write complex JOINs every time
    35 - **Consistent data**: Same calculation logic everywhere
    36 - **Easier to maintain**: Change the view, all queries get updated
    37 - **Better performance**: Database can optimize the view
     37= Benefits =
    3838
    39 The views are implemented in `sql/03_business_views.sql`.
     39'''Simpler queries''': No need to write complex JOINs every time
    4040
     41'''Consistent data''': Same calculation logic everywhere
    4142
     43'''Easier to maintain''': Change the view, all queries get updated
     44
     45'''Better performance''': Database can optimize the view
     46
     47The views are implemented in:
     48sql/03_business_views.sql
    4249**Transactions**
    4350