sales_tables · table
ViewInvdtlTaxPer
Summary view of CGST, SGST, and IGST percentages applied at the invoice level.
Columns
7| Column | Type | Nullable | Meaning |
|---|---|---|---|
index | integer | No | Primary Key / Row identifier |
compcode | string | No | Company identifier |
invno | integer | No | Invoice number |
invyear | integer | No | Financial year of invoice |
cgst_per | string | Yes | Central GST rate percentage |
sgst_per | string | Yes | State GST rate percentage |
igst_per | string | Yes | Integrated GST rate percentage |
Full documentation
### 1. Overview
`ViewInvdtlTaxPer` is a summary view providing the applicable GST percentages (CGST, SGST, IGST) at the invoice level. It aggregates tax rates typically found in line-item details into a single row per invoice header.
### 2. Grain & Lifecycle
**Grain:** One row per Invoice (`compcode`, `invno`, `invyear`).
**Lifecycle:** Data is generated or updated when an invoice is finalized or tax calculations are performed on invoice line items.
### 3. Column Dictionary
| Column | Type | Nullable | Meaning | Allowed Values | SQL Usage |
| :--- | :--- | :--- | :--- | :--- | :--- |
| index | integer | No | Primary Key / Row identifier | | Internal reference |
| compcode | string | No | Company identifier | e.g., 'DAS' | Join key |
| invno | integer | No | Invoice number | | Join key |
| invyear | integer | No | Financial year of invoice | e.g., 2013 | Join key |
| cgst_per | string | Yes | Central GST rate percentage | e.g., '9.00' | Reporting/Display |
| sgst_per | string | Yes | State GST rate percentage | e.g., '9.00' | Reporting/Display |
| igst_per | string | Yes | Integrated GST rate percentage | e.g., '18.00' | Reporting/Display |
### 4. Relationships & Join Map
#### Confirmed Joins
- **invhdr**: Join on `(compcode, invno, invyear)` to access invoice dates, customer codes, and total amounts.
#### Likely Joins
- **oahdr**: (Likely) Join via `invhdr` on `(compcode, oa_no)` to link tax rates back to the original Order Advice.
### 5. Metadata Joins
| Metadata Table | JOIN ON | When to Use | Columns Added |
| :--- | :--- | :--- | :--- |
| `invhdr` | `compcode, invno, invyear` | To filter by date, customer, or cancellation status. | `invdate`, `custcode`, `cancel_flag` |
| `statemas` | `compcode, statecode` (via `invhdr`) | To validate tax rates against specific state GST compliance. | `statename`, `gst_state_code` |
### 6. Query Patterns & Performance Notes
- **Filtering:** Always filter by `compcode` and `invyear` first to leverage indexing on the underlying invoice tables.
- **Data Type Note:** Tax percentages are stored as strings. Cast to `DECIMAL` or `FLOAT` for arithmetic operations.
- **Null Handling:** `NULL` values in tax columns indicate that specific tax type was not applied to the invoice.
### 7. Example Queries
-- 1. Get GST rates for a specific invoice
SELECT cgst_per, sgst_per, igst_per
FROM ViewInvdtlTaxPer
WHERE compcode = 'DAS' AND invno = 2349 AND invyear = 2013;
-- 2. Identify invoices with IGST applied (Inter-state sales)
SELECT invno, invyear, igst_per
FROM ViewInvdtlTaxPer
WHERE igst_per IS NOT NULL AND igst_per <> '0';
-- 3. Join with Invoice Header to see tax rates for a specific customer
SELECT h.invno, h.invdate, t.cgst_per, t.sgst_per
FROM ViewInvdtlTaxPer t
JOIN invhdr h ON t.compcode = h.compcode AND t.invno = h.invno AND t.invyear = h.invyear
WHERE h.custcode = 'C001' AND h.cancel_flag = 'N';
-- 4. List distinct GST combinations used in a financial year
SELECT DISTINCT cgst_per, sgst_per, igst_per
FROM ViewInvdtlTaxPer
WHERE compcode = 'DAS' AND invyear = 2023;
### SUMMARY_START ### {"one_line_description": "Summary view of CGST, SGST, and IGST percentages applied at the invoice level.", "grain": "One row per invoice (compcode, invno, invyear).", "potential_joins": "invhdr, statemas", "key_columns": "compcode, invno, invyear, cgst_per, sgst_per, igst_per"} ### SUMMARY_END ###
Sample queries
-- Retrieve tax percentage details for a specific invoice (No. 2621) from the year 2013 SELECT t.compcode, t.invno, t.invyear, t.cgst_per, t.sgst_per, t.igst_per FROM ViewInvdtlTaxPer AS t WHERE t.compcode = 'DAS' AND t.invno = 2621 AND t.invyear = 2013; -- Join with invoice header to find tax percentages for active invoices belonging to customer 'HML(D)' SELECT h.invdate, h.custcode, h.pono, t.cgst_per, t.sgst_per, t.igst_per FROM ViewInvdtlTaxPer AS t INNER JOIN invhdr AS h ON t.compcode = h.compcode AND t.invno = h.invno AND t.invyear = h.invyear WHERE h.compcode = 'DAS' AND h.custcode = 'HML(D)' AND h.cancel_flag = 'N'; -- Aggregate count of tax records grouped by invoice year for company 'DAS' SELECT t.invyear, COUNT(t.invno) AS total_invoice_lines FROM ViewInvdtlTaxPer AS t WHERE t.compcode = 'DAS' GROUP BY t.invyear ORDER BY t.invyear DESC; -- Multiple join with invoice header and invoice type master to categorize taxes for specific invoice types SELECT h.invno, h.invyear, h.invdate, h.invtype, t.cgst_per, t.sgst_per, t.igst_per FROM ViewInvdtlTaxPer AS t INNER JOIN invhdr AS h ON t.compcode = h.compcode AND t.invno = h.invno AND t.invyear = h.invyear INNER JOIN invtype AS it ON h.compcode = it.compcode AND h.invtype = it.invtype WHERE t.compcode = 'DAS' AND h.invtype = 0 AND h.invyear = 2018;