-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct_demand_knowledge.json
More file actions
89 lines (89 loc) · 6.17 KB
/
product_demand_knowledge.json
File metadata and controls
89 lines (89 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
"product_demand_sales": {
"table_structure": {
"key_fields": {
"ProductId": "Unique identifier for products",
"ProductErpId": "ERP system product identifier",
"DistributorId": "Unique identifier for distributors",
"WarehouseErpId": "ERP system warehouse identifier",
"SuperStockistId": "Identifier for super stockists",
"OrderDateKey": "Integer date key in YYYYMMDD format (e.g., 20240224). ALWAYS use this for order-based analysis. DO NOT use OrderDate.",
"InvoiceDateKey": "Integer date key in YYYYMMDD format (e.g., 20240224). ALWAYS use this for invoice-based analysis. DO NOT use InvoiceDate.",
"CompanyId": "Identifier for the company",
"FAOrderId": "Unique identifier for orders. Use this for counting unique orders."
},
"value_fields": {
"OrderTotalValue": "Total value of the order including all charges (use this for order value queries)",
"InvoiceTotalValue": "Total value of the invoice including taxes and charges (for invoice-specific analysis)",
"OrderGrossValue": "Gross value of the order before adjustments",
"SchemeQtyInvoiced": "Quantity of items invoiced under schemes",
"SchemeQtyOrdered": "Quantity of items ordered under schemes",
"PrimarySchemeDiscountInInvoice": "Primary scheme discount amount in invoice",
"PrimarySchemeDiscountInOrder": "Primary scheme discount amount in order",
"TotalSchemeDiscountInInvoice": "Total scheme discount amount in invoice",
"SecondarySchemeDiscountInInvoice": "Secondary scheme discount amount in invoice",
"SecondarySchemeDiscountInOrder": "Secondary scheme discount amount in order",
"InvoiceCGST": "Central GST amount in invoice",
"InvoiceIGST": "Integrated GST amount in invoice",
"InvoiceSGST": "State GST amount in invoice",
"InvoiceUTGST": "Union Territory GST amount in invoice",
"ProductCGST": "Central GST amount at product level",
"ProductIGST": "Integrated GST amount at product level",
"ProductSGST": "State GST amount at product level",
"ProductUTGST": "Union Territory GST amount at product level"
}
},
"business_rules": {
"date_handling": {
"use_datekeys": "ALWAYS use OrderDateKey and InvoiceDateKey in YYYYMMDD format",
"avoid_date_columns": "NEVER use OrderDate or InvoiceDate columns",
"date_format": "All dates must be in integer YYYYMMDD format (e.g., 20240225)"
},
"value_calculation_rules": {
"order_value": "Always use OrderTotalValue for total order value including all charges",
"invoice_value": "Use InvoiceTotalValue for total invoice value including taxes",
"gross_value": "OrderGrossValue represents value before adjustments",
"gst_calculation": "Sum of CGST, SGST, IGST, and UTGST gives total GST",
"scheme_discounts": "TotalSchemeDiscountInInvoice includes both primary and secondary discounts",
"order_counting": "Use COUNT(DISTINCT FAOrderId) for counting unique orders"
}
},
"analysis_patterns": {
"time_based": {
"daily_trends": "ALWAYS use OrderDateKey for order analysis and InvoiceDateKey for invoice analysis in YYYYMMDD format",
"monthly_comparison": "Use integer datekey ranges (e.g., OrderDateKey BETWEEN 20240101 AND 20240131)",
"seasonal_patterns": "Group by OrderDateKey or InvoiceDateKey using integer YYYYMMDD format"
},
"value_based": {
"total_value": "Use appropriate total value field based on context (OrderTotalValue vs InvoiceTotalValue)",
"discount_analysis": "Consider both primary and secondary scheme discounts",
"tax_analysis": "Analyze GST components separately (CGST, SGST, IGST, UTGST)",
"order_counts": "For unique order counts, always use COUNT(DISTINCT FAOrderId)"
}
},
"query_examples": {
"date_based_queries": {
"order_analysis": [
"SELECT COUNT(DISTINCT FAOrderId) as UniqueOrderCount FROM ProductWiseDemandSales WHERE OrderDateKey BETWEEN 20241101 AND 20241130 AND CompanyId = 10830",
"SELECT OrderDateKey, COUNT(DISTINCT FAOrderId) as UniqueOrderCount FROM ProductWiseDemandSales WHERE OrderDateKey BETWEEN 20241101 AND 20241130 GROUP BY OrderDateKey"
],
"invoice_analysis": [
"SELECT ProductId, SUM(InvoiceTotalValue) as TotalInvoiceValue FROM ProductWiseDemandSales WHERE InvoiceDateKey = 20240225 GROUP BY ProductId",
"SELECT ProductId, SUM(InvoiceTotalValue) as TotalInvoiceValue FROM ProductWiseDemandSales WHERE InvoiceDateKey BETWEEN 20240101 AND 20240131 GROUP BY ProductId"
]
},
"scheme_analysis": {
"discount_queries": [
"SELECT ProductId, SUM(PrimarySchemeDiscountInInvoice) as PrimaryDiscount, SUM(SecondarySchemeDiscountInInvoice) as SecondaryDiscount FROM ProductWiseDemandSales WHERE InvoiceDateKey = 20240225 GROUP BY ProductId",
"SELECT ProductId, SUM(TotalSchemeDiscountInInvoice) as TotalDiscount FROM ProductWiseDemandSales WHERE InvoiceDateKey BETWEEN 20240101 AND 20240131 GROUP BY ProductId"
]
},
"tax_analysis": {
"gst_queries": [
"SELECT ProductId, SUM(InvoiceCGST) as TotalCGST, SUM(InvoiceSGST) as TotalSGST FROM ProductWiseDemandSales WHERE InvoiceDateKey = 20240225 GROUP BY ProductId",
"SELECT ProductId, SUM(InvoiceCGST + InvoiceSGST + InvoiceIGST + InvoiceUTGST) as TotalGST FROM ProductWiseDemandSales WHERE InvoiceDateKey BETWEEN 20240101 AND 20240131 GROUP BY ProductId"
]
}
}
}
}