# claude · R2 · run 1
- Model requested: `claude-opus-5-5` · reported: `claude-opus-5-5`
- Started 2026-12-04T18:44:04+05:30 · finished 2026-12-04T18:45:48+05:30 · latency 103 s
- Tokens: {"in": 224817, "out": 10571, "cache_read": 0, "cache_write": 0} · cost estimate $1.111
- System prompt: none · effort: medium
## Prompt
```
Here's our data. Anything I should know?
```
Files attached: invoices.csv, credit_notes.csv, customers.csv, columns_note.txt
## Transcript
Thinking (summary)
I'm going to start by looking through the files to see what's there.
**Assistant:**
I'll start by looking at the files.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat columns_note.txt; echo; for f in *.csv; do echo "== $f"; wc -l $f; head -5 $f; done
```
**Output:**
```
Indigo Thread Co. - export from the ERP (sales ledger). Three tables, CSV, all history from April 2024 up to 31 Oct 2026.
Amounts are in Indian rupees (INR) unless a column says otherwise.
invoices.csv - one row per sales invoice
invoice_id internal id of the invoice
invoice_no invoice number as printed
invoice_date date of the invoice
customer_id links to customers.customer_id
currency currency the invoice was raised in (INR or EUR)
fx_rate rupees per unit of that currency, used to convert
amount_fc amount in the invoice currency (blank for INR invoices)
net_amount invoice value in INR, before GST
gst_amount GST charged, in INR
gross_amount net_amount + gst_amount
order_ref sales order the invoice was raised against
created_at when the row was entered in the ERP
credit_notes.csv - one row per credit note issued to a customer
cn_id internal id of the credit note
cn_no credit note number
cn_date date of the credit note
invoice_id the invoice it credits (links to invoices.invoice_id)
customer_id links to customers.customer_id
net_amount credit value in INR, before GST (a positive number that reduces revenue)
gst_amount GST reversed, in INR
reason reason recorded for the credit
created_at when the row was entered in the ERP
customers.csv - one row per customer account
customer_id internal id
customer_code customer code
name customer name
region sales region the account is managed under (South, West, East, North, Export)
city customer's city
segment account size band used by sales (key, mid, small)
currency usual invoicing currency
status account status in the ERP (active / inactive)
payment_terms_days agreed payment terms in days
credit_limit credit limit in INR
created_at when the account was created
Net revenue, as the company reports it from these tables: invoice net_amount minus credit note net_amount, by date.
== credit_notes.csv
861 credit_notes.csv
cn_id,cn_no,cn_date,invoice_id,customer_id,net_amount,gst_amount,reason,created_at
1,CN/000001,2024-04-08,5448,50,3874.57,193.73,Quality claim,2024-04-08 16:30:56
2,CN/000002,2024-04-10,5433,142,5507.46,275.37,Return,2024-04-10 15:27:01
3,CN/000003,2024-04-13,5489,6,18492.12,924.61,Rate difference,2024-04-13 14:00:56
4,CN/000004,2024-04-18,5441,143,5035.80,251.79,Quality claim,2024-04-18 16:26:02
== customers.csv
144 customers.csv
customer_id,customer_code,name,region,city,segment,currency,status,payment_terms_days,credit_limit,created_at
1,C0001,Ravira Exports,South,Tiruppur,key,INR,active,30,33600000.00,2023-08-05 17:08:04
2,C0002,Tessora EU,South,Rotterdam,key,EUR,active,45,43700000.00,2021-12-11 17:53:30
3,C0003,Skarfab,South,Aarhus,key,EUR,active,45,22800000.00,2022-05-07 16:51:47
4,C0004,Merai Apparels,West,Mumbai,key,INR,active,30,15600000.00,2022-03-02 17:53:33
== invoices.csv
8773 invoices.csv
invoice_id,invoice_no,invoice_date,customer_id,currency,fx_rate,amount_fc,net_amount,gst_amount,gross_amount,order_ref,created_at
5411,BI/2425/000001,2024-04-01,11,INR,1.0000,,117738.91,5886.95,123625.86,SO-24005358,2024-04-01 18:43:04
5412,BI/2425/000002,2024-04-01,21,EUR,100.6756,3671.50,369630.47,0.00,369630.47,SO-24005296,2024-04-01 17:59:42
5413,BI/2425/000003,2024-04-01,95,INR,1.0000,,67337.59,3366.88,70704.47,SO-24005494,2024-04-01 19:00:03
5414,BI/2425/000004,2024-04-01,99,INR,1.0000,,56480.17,2824.01,59304.18,SO-24005522,2024-04-01 19:02:32
```
Thinking (summary)
I'm checking customer 2, Tessora, in the EU region and South city Rotterdam, to see whether the EUR customers there belong in the South region rather than Export, and I'll profile them thoroughly.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; python3 -c "
import pandas as pd
i=pd.read_csv('invoices.csv');c=pd.read_csv('credit_notes.csv');cu=pd.read_csv('customers.csv')
for n,d in [('inv',i),('cn',c),('cu',cu)]:
print(n,d.shape);print(d.isna().sum()[d.isna().sum()>0]);print(d.describe(include='all').T.to_string());print()
print(cu.to_string())
"
```
**Output:**
```
inv (8772, 12)
amount_fc 7212
dtype: int64
count unique top freq mean std min 25% 50% 75% max
invoice_id 8772.0 NaN NaN NaN 9796.5 2532.402614 5411.0 7603.75 9796.5 11989.25 14182.0
invoice_no 8772 8772 BI/2627/001928 1 NaN NaN NaN NaN NaN NaN NaN
invoice_date 8772 811 2026-09-29 29 NaN NaN NaN NaN NaN NaN NaN
customer_id 8772.0 NaN NaN NaN 70.849407 44.754645 1.0 27.75 75.0 112.0 143.0
currency 8772 2 INR 7212 NaN NaN NaN NaN NaN NaN NaN
fx_rate 8772.0 NaN NaN NaN 18.562911 37.769525 1.0 1.0 1.0 1.0 102.8432
amount_fc 1560.0 NaN NaN NaN 3537.022244 2932.759183 759.83 2145.01 2721.405 3550.5275 30990.24
net_amount 8772.0 NaN NaN NaN 163185.277644 228008.669113 10049.34 43193.08 66352.17 229870.56 3041255.09
gst_amount 8772.0 NaN NaN NaN 5023.184226 8836.928822 0.0 1484.21 2415.685 4128.52 131677.08
gross_amount 8772.0 NaN NaN NaN 168208.46187 233579.752589 10551.81 45352.7325 69669.78 235524.3425 3041255.09
order_ref 8772 8772 SO-26014338 1 NaN NaN NaN NaN NaN NaN NaN
created_at 8772 8772 2026-10-31 13:46:24 1 NaN NaN NaN NaN NaN NaN NaN
cn (860, 9)
Series([], dtype: int64)
count unique top freq mean std min 25% 50% 75% max
cn_id 860.0 NaN NaN NaN 430.5 248.404911 1.0 215.75 430.5 645.25 860.0
cn_no 860 860 CN/000860 1 NaN NaN NaN NaN NaN NaN NaN
cn_date 860 505 2026-04-06 6 NaN NaN NaN NaN NaN NaN NaN
invoice_id 860.0 NaN NaN NaN 9648.75814 2453.008207 5433.0 7532.0 9547.0 11766.0 14126.0
customer_id 860.0 NaN NaN NaN 67.563953 45.238258 1.0 21.0 67.5 108.25 143.0
net_amount 860.0 NaN NaN NaN 26676.248547 48326.264573 893.05 5973.1825 11135.845 31480.3125 467435.69
gst_amount 860.0 NaN NaN NaN 861.06014 1993.280909 0.0 173.875 382.635 710.455 23371.78
reason 860 3 Return 432 NaN NaN NaN NaN NaN NaN NaN
created_at 860 860 2026-10-30 17:56:11 1 NaN NaN NaN NaN NaN NaN NaN
cu (143, 11)
Series([], dtype: int64)
count unique top freq mean std min 25% 50% 75% max
customer_id 143.0 NaN NaN NaN 72.0 41.42463 1.0 36.5 72.0 107.5 143.0
customer_code 143 143 C0001 1 NaN NaN NaN NaN NaN NaN NaN
name 143 143 Ravira Exports 1 NaN NaN NaN NaN NaN NaN NaN
region 143 5 South 72 NaN NaN NaN NaN NaN NaN NaN
city 143 31 Erode 17 NaN NaN NaN NaN NaN NaN NaN
segment 143 3 mid 72 NaN NaN NaN NaN NaN NaN NaN
currency 143 2 INR 115 NaN NaN NaN NaN NaN NaN NaN
status 143 2 active 140 NaN NaN NaN NaN NaN NaN NaN
payment_terms_days 143.0 NaN NaN NaN 32.937063 5.973199 30.0 30.0 30.0 30.0 45.0
credit_limit 143.0 NaN NaN NaN 5719580.41958 5565490.484203 1200000.0 1550000.0 6000000.0 8700000.0 43700000.0
created_at 143 142 2021-07-02 10:00:34 2 NaN NaN NaN NaN NaN NaN NaN
customer_id customer_code name region city segment currency status payment_terms_days credit_limit created_at
0 1 C0001 Ravira Exports South Tiruppur key INR active 30 33600000.0 2023-08-05 17:08:04
1 2 C0002 Tessora EU South Rotterdam key EUR active 45 43700000.0 2021-12-11 17:53:30
2 3 C0003 Skarfab South Aarhus key EUR active 45 22800000.0 2022-05-07 16:51:47
3 4 C0004 Merai Apparels West Mumbai key INR active 30 15600000.0 2022-03-02 17:53:33
4 5 C0005 Shree Varada Textiles South Tiruppur mid INR active 30 6000000.0 2022-02-01 14:58:43
5 6 C0006 Tidewell Garments South Coimbatore mid INR active 30 6000000.0 2023-03-05 18:54:32
6 7 C0007 Anvika Knit Works West Ahmedabad mid INR active 30 6000000.0 2022-04-05 14:44:19
7 8 C0008 Sanvi Weaves South Chennai mid INR active 30 6000000.0 2023-05-07 12:59:32
8 9 C0009 Kavira Knitwear South Kochi mid INR active 30 6000000.0 2022-06-07 13:55:42
9 10 C0010 Navika Fashions West Bhiwandi mid INR active 30 6000000.0 2023-07-09 18:27:26
10 11 C0011 Korana Clothing East Howrah mid INR active 30 6000000.0 2022-02-07 11:03:45
11 12 C0012 Devana Apparels South Tiruppur mid INR active 30 6000000.0 2023-03-11 16:57:48
12 13 C0013 Inara Creations North Noida mid INR active 30 6000000.0 2022-04-11 12:04:25
13 14 C0014 Maravi Linens South Bengaluru mid INR active 30 6000000.0 2023-05-13 14:28:48
14 15 C0015 Tarini Garments West Vapi mid INR active 30 6000000.0 2022-06-13 13:54:37
15 16 C0016 Nilavi Exports South Kochi mid INR active 30 6000000.0 2023-07-15 15:58:49
16 17 C0017 Vihana Textiles North Ludhiana mid INR active 30 6000000.0 2022-02-13 16:25:08
17 18 C0018 Charu Knit Fab South Madurai mid INR active 30 6000000.0 2023-03-17 09:59:58
18 19 C0019 Solvik Textil Export Hamburg mid EUR active 45 9900000.0 2021-03-02 15:41:56
19 20 C0020 Haus Brenner Stoffe Export Lyon mid EUR active 45 9000000.0 2022-04-01 16:27:17
20 21 C0021 Vela Moda Srl West Ahmedabad mid EUR active 45 9600000.0 2023-05-02 10:03:45
21 22 C0022 Atelier Saône Export Antwerp mid EUR active 45 8100000.0 2021-06-01 16:38:04
22 23 C0023 Van Rijt Stoffen West Mumbai mid EUR active 45 8600000.0 2022-07-02 16:34:18
23 24 C0024 Moda Castella North Delhi mid EUR active 45 8500000.0 2023-08-02 18:47:49
24 25 C0025 Kaskaro Textil Export Hamburg mid EUR active 45 8700000.0 2021-09-01 10:28:30
25 26 C0026 Avonmere Cloth Co West Pune mid EUR active 45 9200000.0 2022-10-02 12:53:06
26 27 C0027 Kurlan Weave North Ludhiana mid EUR active 45 8000000.0 2023-03-02 09:42:31
27 28 C0028 Dravia Fabrics Export Antwerp mid EUR active 45 8200000.0 2021-04-01 16:32:16
28 29 C0029 Mondelo Têxteis West Ahmedabad mid EUR active 45 9300000.0 2022-05-02 09:40:57
29 30 C0030 Skerry Apparel North Gurugram mid EUR active 45 7900000.0 2023-06-01 13:20:50
30 31 C0031 Kempen Linnen South Tiruppur mid EUR active 45 8600000.0 2021-07-02 10:00:34
31 32 C0032 Firnhang Tuch East Bhubaneswar mid EUR active 45 8900000.0 2022-08-02 12:35:06
32 33 C0033 Moselweber Export Milan mid EUR active 45 8900000.0 2023-09-01 10:47:18
33 34 C0034 Tessuti Ombra Export Antwerp mid EUR active 45 8500000.0 2021-10-02 11:24:15
34 35 C0035 Wattmeer Textil West Mumbai mid EUR active 45 10100000.0 2022-03-02 13:30:49
35 36 C0036 Maison Vallin Export Porto mid EUR active 45 8800000.0 2023-04-01 15:15:25
36 37 C0037 Castelino North Noida mid EUR active 45 8100000.0 2021-05-02 16:41:25
37 38 C0038 Tatrava Cloth Export Lyon mid EUR active 45 9100000.0 2022-06-01 10:34:18
38 39 C0039 Bernalp Stoff West Mumbai mid EUR active 45 9000000.0 2023-07-02 14:58:48
39 40 C0040 Dalmara Moda South Coimbatore mid EUR active 45 8000000.0 2021-08-02 09:43:03
40 41 C0041 Scheldra Weefsels Export Gothenburg mid EUR active 45 9500000.0 2022-09-01 10:46:10
41 42 C0042 Elbtal Garn North Gurugram mid EUR active 45 10100000.0 2023-10-02 09:03:49
42 43 C0043 Dordelle Tissus Export Hamburg mid EUR active 45 7800000.0 2021-03-02 17:33:00
43 44 C0044 Narvia Weave East Bhubaneswar mid EUR active 45 8400000.0 2022-04-01 18:05:41
44 45 C0045 Brahmavra Trading South Erode small INR active 30 1300000.0 2021-03-02 18:01:50
45 46 C0046 Mahanvi Trading South Erode small INR active 30 1300000.0 2021-03-02 10:36:33
46 47 C0047 Sabarvi Trading South Erode small INR active 30 1300000.0 2021-03-02 12:26:08
47 48 C0048 Tungavra Trading South Erode small INR active 30 1300000.0 2021-03-02 09:53:39
48 49 C0049 Kalvira Trading South Erode small INR active 30 1300000.0 2021-03-02 12:20:46
49 50 C0050 Avadra Trading South Erode small INR active 30 1300000.0 2021-03-02 14:47:54
50 51 C0051 Magvira Trading South Erode small INR active 30 1300000.0 2021-03-02 09:16:31
51 52 C0052 Vidarva Trading South Erode small INR active 30 1300000.0 2021-03-02 10:01:28
52 53 C0053 Konvira Trading South Erode small INR active 30 1300000.0 2021-03-02 14:34:25
53 54 C0054 Saurava Trading South Erode small INR active 30 1300000.0 2021-03-02 15:04:44
54 55 C0055 Doavra Trading South Erode small INR active 30 1300000.0 2021-03-02 17:42:58
55 56 C0056 Bundra Trading South Erode small INR active 30 1300000.0 2021-03-02 13:52:15
56 57 C0057 Sahvira Trading South Erode small INR active 30 1300000.0 2021-03-02 18:30:13
57 58 C0058 Gomavi Trading South Erode small INR active 30 1300000.0 2021-03-02 15:10:34
58 59 C0059 Aravika Trading South Erode small INR active 30 1300000.0 2021-03-02 17:09:33
59 60 C0060 Sahvira Garments West Mumbai mid INR active 30 9300000.0 2021-03-02 15:33:37
60 61 C0061 Gomavi Apparels South Coimbatore mid INR active 30 8900000.0 2021-04-01 09:45:00
61 62 C0062 Aravika Fashions North Noida mid INR active 30 9700000.0 2021-05-02 11:04:47
62 63 C0063 Kalvira Textiles East Guwahati mid INR active 30 9700000.0 2021-06-01 14:44:38
63 64 C0064 Saurava Fabrics West Mumbai mid INR active 30 9000000.0 2021-07-02 17:53:21
64 65 C0065 Perivra Knitwear South Coimbatore mid INR active 30 8600000.0 2021-08-02 12:59:43
65 66 C0066 Avadra Clothing North Noida mid INR active 30 9200000.0 2021-09-01 11:06:29
66 67 C0067 Konvira Overseas West Pune mid INR active 30 9900000.0 2021-10-02 09:12:48
67 68 C0068 Kanvira Creations South Tiruppur mid INR active 30 8300000.0 2021-11-01 16:15:58
68 69 C0069 Magvira Wear East Bhubaneswar mid INR active 30 9000000.0 2021-03-02 17:54:52
69 70 C0070 Hamvi Garments South Bengaluru mid INR active 30 9800000.0 2021-04-01 09:35:50
70 71 C0071 Doavra Textiles North Gurugram mid INR active 30 8400000.0 2021-05-02 11:18:48
71 72 C0072 Vaivra Textiles South Tiruppur mid INR active 30 9100000.0 2021-06-01 18:54:42
72 73 C0073 Palvra Garments South Coimbatore mid INR active 30 8600000.0 2021-07-02 13:09:07
73 74 C0074 Bhavira Fabrics South Bengaluru mid INR active 30 8100000.0 2021-08-02 12:18:55
74 75 C0075 Amaravira Apparels South Chennai mid INR active 30 8300000.0 2021-09-01 10:19:06
75 76 C0076 Noyvra Weaves South Tiruppur mid INR active 30 8700000.0 2021-10-02 16:03:22
76 77 C0077 Kollivra Knits South Coimbatore mid INR active 30 8700000.0 2021-11-01 11:00:26
77 78 C0078 Siruvra Textiles South Bengaluru mid INR active 30 8600000.0 2021-03-02 13:02:43
78 79 C0079 Moyvra Garments South Chennai mid INR active 30 9900000.0 2021-04-01 09:31:53
79 80 C0080 Pamvra Fabrics South Tiruppur mid INR active 30 9300000.0 2021-05-02 13:59:56
80 81 C0081 Chitvra Apparels South Coimbatore mid INR active 30 8500000.0 2021-06-01 12:09:55
81 82 C0082 Manivra Mills South Bengaluru mid INR active 30 8100000.0 2021-07-02 10:20:50
82 83 C0083 Thamivra Wear South Chennai mid INR active 30 9500000.0 2021-08-02 16:56:09
83 84 C0084 Kodavra Textiles South Tiruppur mid INR active 30 8400000.0 2021-09-01 16:25:22
84 85 C0085 Varavra Garments South Coimbatore mid INR active 30 9800000.0 2021-10-02 16:52:06
85 86 C0086 Gadivra Knits South Bengaluru mid INR active 30 8000000.0 2021-11-01 14:43:11
86 87 C0087 Ponnavra Fabrics South Chennai mid INR active 30 9300000.0 2021-03-02 09:45:37
87 88 C0088 Suruvra Apparels South Tiruppur mid INR active 30 9000000.0 2021-04-01 15:20:37
88 89 C0089 Agavra Weaves South Coimbatore mid INR active 30 9800000.0 2021-05-02 14:56:42
89 90 C0090 Kabvra Clothing South Bengaluru mid INR active 30 8600000.0 2021-06-01 16:17:35
90 91 C0091 Hemavra Mills South Chennai mid INR active 30 9000000.0 2021-07-02 10:00:34
91 92 C0092 Gomavi Overseas South Bengaluru small INR active 30 1200000.0 2023-01-30 13:43:15
92 93 C0093 Aravika Clothing South Chennai small INR active 30 1500000.0 2024-03-02 14:41:39
93 94 C0094 Kutra Knitwear South Kochi small INR active 30 1500000.0 2021-03-02 09:16:56
94 95 C0095
```
Thinking (summary)
I'm noticing that a lot of EUR customers have foreign cities set under domestic regions like South, West, North, and East, and some have Indian cities such as Ahmedabad or Mumbai. The Vela Moda Srl entry in Ahmedabad looks wrong, so I'm wondering whether the city field is actually tracking a sales office instead of the customer's city, and I'll flag it for review. I'm also starting on the 15 Erode "Trading" customers that were created on a given date.
I'm checking whether the 15 Erode "Trading" customers created on 2021-03-02 relate to any sales or invoice activity, including whether some were created after invoices were already being raised or have invoices while marked inactive. Then I'll move on to deeper checks.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/a.py <<'EOF'
import pandas as pd, numpy as np
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date','created_at']);c=pd.read_csv('credit_notes.csv',parse_dates=['cn_date','created_at']);cu=pd.read_csv('customers.csv',parse_dates=['created_at'])
print('date range',i.invoice_date.min(),i.invoice_date.max(),c.cn_date.min(),c.cn_date.max())
# arithmetic
print('gross!=net+gst',(abs(i.net_amount+i.gst_amount-i.gross_amount)>0.011).sum())
e=i[i.currency=='EUR']; print('EUR fc*fx mismatch',(abs(e.amount_fc*e.fx_rate-e.net_amount)>1).sum())
print('INR fx!=1',(i[i.currency=='INR'].fx_rate!=1).sum(), 'INR with fc', i[i.currency=='INR'].amount_fc.notna().sum())
print('GST rate dist'); i['gr']=(i.gst_amount/i.net_amount).round(3); print(i.groupby('currency').gr.value_counts().head(20))
# fx rates over time
e=e.assign(m=e.invoice_date.dt.to_period('M')); print(e.groupby('m').fx_rate.agg(['min','max','mean','count']).to_string())
# invoice currency vs customer currency
m=i.merge(cu[['customer_id','currency','status','created_at','region','segment']],on='customer_id',suffixes=('','_c'))
print('currency mismatch',(m.currency!=m.currency_c).sum()); print(m[m.currency!=m.currency_c].groupby(['customer_id','currency','currency_c']).size())
print('inv before cust created',(m.invoice_dateThinking (summary)
I'm checking the credit notes against their invoices: matching customers, dates, amounts, cumulative credits, and GST consistency, including the EUR invoices. I'm also looking at invoice numbering for gaps and duplicates, monthly trends, and whether the September 2026 spike in EUR invoices lines up with quarter-end.
I'm also checking the period-end pattern: whether credit notes issued after September 2026 are reversing those late-month invoices, and the last few days of that month, where the invoice date mode falls on 2026-09-29 with 29 invoices.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/b.py <<'EOF'
import pandas as pd, numpy as np
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date','created_at']);c=pd.read_csv('credit_notes.csv',parse_dates=['cn_date','created_at']);cu=pd.read_csv('customers.csv')
m=c.merge(i[['invoice_id','invoice_date','customer_id','net_amount','currency','gst_amount']],on='invoice_id',suffixes=('','_i'))
print('cn cust != inv cust',(m.customer_id!=m.customer_id_i).sum())
print(m[m.customer_id!=m.customer_id_i][['cn_id','cn_date','customer_id','customer_id_i','net_amount','reason']].head(20))
print('cn before inv',(m.cn_date inv',(m.net_amount>m.net_amount_i+0.01).sum())
tot=m.groupby('invoice_id').agg(cn=('net_amount','sum'),inv=('net_amount_i','first'),n=('cn_id','size'))
print('cum cn > inv',(tot.cn>tot.inv+0.01).sum(), 'multi-cn invoices',(tot.n>1).sum())
m['ratio']=m.net_amount/m.net_amount_i; print(m.groupby('reason').ratio.describe())
m['gr']=(m.gst_amount/m.net_amount).round(3); print(m.groupby(['currency','gr']).size())
m['lag']=(m.cn_date-m.invoice_date).dt.days; print(m.groupby('reason').lag.describe())
print('cn created lag',((m.created_at.dt.normalize()-m.cn_date).dt.days).value_counts())
# invoice number sequence vs date
i['fy']=i.invoice_no.str.split('/').str[1]; i['seq']=i.invoice_no.str.split('/').str[2].astype(int)
for fy,g in i.groupby('fy'):
g=g.sort_values('seq'); print(fy,g.seq.min(),g.seq.max(),len(g),'nonmono date',(g.invoice_date.diff().dt.days<0).sum(), g.invoice_date.min().date(), g.invoice_date.max().date())
# fy prefix consistent with date
def fy(d): y=d.year if d.month>=4 else d.year-1; return f"{y%100:02d}{(y+1)%100:02d}"
print('fy mismatch',(i.invoice_date.apply(fy)!=i.fy).sum())
# id order vs date
s=i.sort_values('invoice_id'); print('id nonmono date',(s.invoice_date.diff().dt.days<0).sum(), 'created nonmono',(s.created_at.diff().dt.total_seconds()<0).sum())
# order_ref
i['so']=i.order_ref.str[3:].astype(int); print('SO prefix', i.order_ref.str[3:5].value_counts().to_string())
# duplicates
d=i[i.duplicated(['customer_id','net_amount'],keep=False)]; print('dup cust+amt',len(d)); print(d.sort_values(['customer_id','net_amount']).head(20).to_string())
# weekday/time
print(i.invoice_date.dt.dayofweek.value_counts().sort_index()); print(i.created_at.dt.hour.value_counts().sort_index().to_string())
EOF
python3 /tmp/b.py
```
**Output:**
```
cn cust != inv cust 0
Empty DataFrame
Columns: [cn_id, cn_date, customer_id, customer_id_i, net_amount, reason]
Index: []
cn before inv 0
cn > inv 0
cum cn > inv 0 multi-cn invoices 0
count mean std ... 50% 75% max
reason ...
Quality claim 187.0 0.156447 0.063058 ... 0.158985 0.207958 0.263210
Rate difference 241.0 0.160908 0.074547 ... 0.158168 0.212695 0.829234
Return 432.0 0.161070 0.069232 ... 0.163755 0.212427 0.829234
[3 rows x 8 columns]
currency gr
EUR 0.00 142
INR 0.05 718
dtype: int64
count mean std min 25% 50% 75% max
reason
Quality claim 187.0 19.925134 8.994309 4.0 12.0 21.0 28.0 35.0
Rate difference 241.0 20.211618 9.029167 4.0 13.0 20.0 28.0 35.0
Return 432.0 18.796296 8.816257 4.0 11.0 18.5 26.0 35.0
cn created lag 0 858
8 2
Name: count, dtype: int64
2425 1 3298 3298 nonmono date 0 2024-04-01 2025-03-31
2526 1 3546 3546 nonmono date 0 2025-04-01 2026-03-31
2627 1 1928 1928 nonmono date 0 2026-04-01 2026-10-31
fy mismatch 0
id nonmono date 0 created nonmono 3995
SO prefix order_ref
25 3450
26 2673
24 2649
dup cust+amt 0
Empty DataFrame
Columns: [invoice_id, invoice_no, invoice_date, customer_id, currency, fx_rate, amount_fc, net_amount, gst_amount, gross_amount, order_ref, created_at, fy, seq, so]
Index: []
invoice_date
0 1414
1 1453
2 1300
3 1427
4 1496
5 1680
6 2
Name: count, dtype: int64
created_at
10 872
11 886
12 841
13 835
14 897
15 880
16 870
17 917
18 889
19 885
```
Thinking (summary)
I'm seeing an outlier in the credit note ratio, with a max of 0.829. Two credit notes were created eight days after their cn_date, so they look backdated, and two invoices fall on a Sunday. I want to look into those, and also check monthly trends around period-end.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/c.py <<'EOF'
import pandas as pd, numpy as np
pd.set_option('display.width',250)
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date','created_at']);c=pd.read_csv('credit_notes.csv',parse_dates=['cn_date','created_at']);cu=pd.read_csv('customers.csv')
m=c.merge(i[['invoice_id','invoice_no','invoice_date','net_amount','created_at']],on='invoice_id',suffixes=('','_i'))
m['ratio']=m.net_amount/m.net_amount_i
print(m.sort_values('ratio',ascending=False).head(12)[['cn_id','cn_no','cn_date','created_at','invoice_id','invoice_date','customer_id','net_amount','net_amount_i','ratio','reason']].to_string())
print(m[(m.created_at.dt.normalize()-m.cn_date).dt.days!=0][['cn_id','cn_date','created_at','invoice_id','invoice_date','customer_id','net_amount','ratio','reason']])
print(i[i.invoice_date.dt.dayofweek==6].to_string())
# monthly
i['m']=i.invoice_date.dt.to_period('M'); c['m']=c.cn_date.dt.to_period('M')
mo=pd.DataFrame({'inv':i.groupby('m').net_amount.sum()/1e6,'n':i.groupby('m').size(),'cn':c.groupby('m').net_amount.sum()/1e6,'ncn':c.groupby('m').size()}).fillna(0)
mo['net']=mo.inv-mo.cn; mo['cn%']=mo.cn/mo.inv*100; print(mo.round(2).to_string())
EOF
python3 /tmp/c.py
```
**Output:**
```
cn_id cn_no cn_date created_at invoice_id invoice_date customer_id net_amount net_amount_i ratio reason
851 852 CN/000852 2026-10-23 2026-10-31 18:55:16 13720 2026-09-19 87 390720.93 471183.08 0.829234 Return
852 853 CN/000853 2026-10-23 2026-10-31 14:34:04 13895 2026-10-03 87 190157.81 229317.49 0.829234 Rate difference
755 756 CN/000756 2026-07-03 2026-07-03 13:01:49 13009 2026-06-24 110 22185.91 84289.82 0.263210 Quality claim
546 547 CN/000547 2025-11-24 2025-11-24 12:10:04 10907 2025-11-19 44 69626.66 264921.21 0.262820 Rate difference
717 718 CN/000718 2026-05-22 2026-05-22 16:22:53 12538 2026-05-02 14 12575.85 47873.12 0.262691 Return
725 726 CN/000726 2026-05-28 2026-05-28 14:08:38 12585 2026-05-07 18 11244.86 42887.30 0.262196 Rate difference
221 222 CN/000222 2024-12-23 2024-12-23 14:50:47 7552 2024-11-25 100 11281.40 43065.69 0.261958 Return
628 629 CN/000629 2026-02-14 2026-02-14 18:16:44 11657 2026-02-03 8 21995.14 84016.41 0.261796 Return
669 670 CN/000670 2026-04-06 2026-04-06 18:05:23 12073 2026-03-19 33 58883.57 225938.88 0.260617 Quality claim
460 461 CN/000461 2025-08-22 2025-08-22 16:38:13 10011 2025-08-16 128 12407.51 47641.87 0.260433 Return
829 830 CN/000830 2026-09-29 2026-09-29 15:27:17 13657 2026-09-14 44 62981.31 242234.81 0.260001 Quality claim
251 252 CN/000252 2025-01-21 2025-01-21 10:25:25 8001 2025-01-11 14 14493.20 55758.06 0.259930 Rate difference
cn_id cn_date ... ratio reason
851 852 2026-10-23 ... 0.829234 Return
852 853 2026-10-23 ... 0.829234 Rate difference
[2 rows x 9 columns]
invoice_id invoice_no invoice_date customer_id currency fx_rate amount_fc net_amount gst_amount gross_amount order_ref created_at
7638 13049 BI/2627/000795 2026-06-28 7 INR 1.0 NaN 248728.08 12436.40 261164.48 SO-26013076 2026-06-28 11:36:51
7762 13173 BI/2627/000919 2026-07-12 5 INR 1.0 NaN 139027.59 6951.38 145978.97 SO-26013112 2026-07-12 12:39:39
inv n cn ncn net cn%
m
2024-04 42.26 271 0.12 6 42.14 0.27
2024-05 43.54 260 0.52 27 43.02 1.19
2024-06 45.15 241 0.81 20 44.34 1.80
2024-07 43.83 307 0.81 34 43.02 1.85
2024-08 41.08 260 0.67 23 40.41 1.64
2024-09 45.01 283 0.68 25 44.33 1.51
2024-10 44.17 292 0.72 33 43.45 1.64
2024-11 43.27 283 0.68 35 42.59 1.58
2024-12 44.75 294 0.44 29 44.31 0.97
2025-01 43.30 276 1.14 33 42.16 2.63
2025-02 43.00 217 0.41 26 42.59 0.96
2025-03 50.23 314 1.12 34 49.12 2.22
2025-04 45.79 266 0.80 33 44.99 1.74
2025-05 46.46 302 0.55 24 45.91 1.18
2025-06 48.24 289 0.93 25 47.31 1.92
2025-07 47.46 299 1.53 35 45.93 3.23
2025-08 43.60 268 0.45 26 43.15 1.02
2025-09 47.97 297 0.68 34 47.29 1.42
2025-10 47.15 324 0.75 33 46.40 1.59
2025-11 45.87 254 0.39 16 45.48 0.85
2025-12 48.11 326 0.80 36 47.31 1.67
2026-01 45.39 303 0.41 31 44.97 0.91
2026-02 45.99 272 0.53 21 45.46 1.16
2026-03 53.11 346 0.69 26 52.42 1.29
2026-04 47.73 274 1.01 32 46.72 2.12
2026-05 48.34 293 0.70 33 47.64 1.44
2026-06 50.17 267 1.06 25 49.10 2.12
2026-07 48.14 245 0.49 24 47.65 1.01
2026-08 45.43 237 0.69 25 44.74 1.52
2026-09 49.07 293 0.87 26 48.20 1.77
2026-10 47.84 319 1.49 30 46.35 3.12
```
Thinking (summary)
I'm looking at two credit notes for customer 87, Ponnavra Fabrics, that share the same ratio and were both backdated and entered late in October. Since the period is the end of the first half of the fiscal year, I'm wondering whether large invoices were pushed to them in late September and then credited, and I want to check their history and the late-September invoices.
I'm also going to check per-customer revenue patterns, the Export region mislabel, and customer concentration. The March period-end figures look high, so I'll see whether that is a seasonal pattern by checking the last days of each month and quarter.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/d.py <<'EOF'
import pandas as pd, numpy as np
pd.set_option('display.width',250)
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date','created_at']);c=pd.read_csv('credit_notes.csv',parse_dates=['cn_date','created_at']);cu=pd.read_csv('customers.csv')
print(c[c.cn_id.isin([852,853])].to_string())
g=i[i.customer_id==87]; g=g.assign(m=g.invoice_date.dt.to_period('M'))
print(g.groupby('m').net_amount.agg(['count','sum','max']).tail(12))
print(g[g.invoice_date>='2026-09-01'].to_string())
print(c[c.customer_id==87].to_string())
# largest invoices per customer relative to their median
i['med']=i.groupby('customer_id').net_amount.transform('median'); i['x']=i.net_amount/i.med
print(i.sort_values('x',ascending=False).head(15)[['invoice_id','invoice_no','invoice_date','customer_id','net_amount','med','x']].to_string())
EOF
python3 /tmp/d.py
```
**Output:**
```
cn_id cn_no cn_date invoice_id customer_id net_amount gst_amount reason created_at
851 852 CN/000852 2026-10-23 13720 87 390720.93 19536.05 Return 2026-10-31 18:55:16
852 853 CN/000853 2026-10-23 13895 87 190157.81 9507.89 Rate difference 2026-10-31 14:34:04
count sum max
m
2025-09 1 339115.91 339115.91
2025-10 1 327648.73 327648.73
2025-11 1 243437.61 243437.61
2025-12 2 397805.96 222311.50
2026-01 2 531337.42 327602.59
2026-02 2 672430.49 351225.81
2026-03 2 672850.46 396918.29
2026-06 2 567233.61 359325.12
2026-07 5 1717417.67 589245.37
2026-08 1 357345.38 357345.38
2026-09 2 640825.59 471183.08
2026-10 3 434727.97 229317.49
invoice_id invoice_no invoice_date customer_id currency fx_rate amount_fc net_amount gst_amount gross_amount order_ref created_at m
8266 13677 BI/2627/001423 2026-09-16 87 INR 1.0 NaN 169642.51 8482.13 178124.64 SO-26013729 2026-09-16 10:23:34 2026-09
8309 13720 BI/2627/001466 2026-09-19 87 INR 1.0 NaN 471183.08 23559.15 494742.23 SO-26013765 2026-09-19 16:12:08 2026-09
8484 13895 BI/2627/001641 2026-10-03 87 INR 1.0 NaN 229317.49 11465.87 240783.36 SO-26013876 2026-10-03 16:56:31 2026-10
8635 14046 BI/2627/001792 2026-10-21 87 INR 1.0 NaN 118645.35 5932.27 124577.62 SO-26014112 2026-10-21 12:53:06 2026-10
8659 14070 BI/2627/001816 2026-10-22 87 INR 1.0 NaN 86765.13 4338.26 91103.39 SO-26014097 2026-10-22 15:38:24 2026-10
cn_id cn_no cn_date invoice_id customer_id net_amount gst_amount reason created_at
69 70 CN/000070 2024-07-22 6178 87 54567.02 2728.35 Return 2024-07-22 16:03:17
199 200 CN/000200 2024-11-28 7439 87 63548.85 3177.44 Quality claim 2024-11-28 15:27:27
383 384 CN/000384 2025-06-02 9070 87 19075.19 953.76 Quality claim 2025-06-02 16:30:47
506 507 CN/000507 2025-10-06 10261 87 85965.23 4298.26 Return 2025-10-06 17:37:43
560 561 CN/000561 2025-12-11 10965 87 61502.76 3075.14 Rate difference 2025-12-11 16:02:06
686 687 CN/000687 2026-04-21 12156 87 38841.87 1942.09 Return 2026-04-21 13:15:09
775 776 CN/000776 2026-07-27 13138 87 60254.37 3012.72 Rate difference 2026-07-27 10:18:41
803 804 CN/000804 2026-08-31 13296 87 13962.35 698.12 Quality claim 2026-08-31 18:59:57
851 852 CN/000852 2026-10-23 13720 87 390720.93 19536.05 Return 2026-10-31 18:55:16
852 853 CN/000853 2026-10-23 13895 87 190157.81 9507.89 Rate difference 2026-10-31 14:34:04
invoice_id invoice_no invoice_date customer_id net_amount med x
8648 14059 BI/2627/001805 2026-10-22 4 2290465.44 494903.470 4.628105
3561 8972 BI/2526/000264 2025-04-30 103 179393.70 51326.390 3.495155
8625 14036 BI/2627/001782 2026-10-21 4 1591714.80 494903.470 3.216213
4914 10325 BI/2526/001617 2025-09-20 136 154929.50 51573.820 3.004034
7002 12413 BI/2627/000159 2026-04-20 51 110791.38 38043.930 2.912196
8624 14035 BI/2627/001781 2026-10-21 4 1411096.81 494903.470 2.851257
7008 12419 BI/2627/000165 2026-04-20 109 153118.44 53717.505 2.850438
2830 8241 BI/2425/002831 2025-02-08 98 164542.52 57789.690 2.847264
8614 14025 BI/2627/001771 2026-10-20 64 731366.82 260539.010 2.807130
6360 11771 BI/2526/003063 2026-02-14 103 143128.28 51326.390 2.788590
7688 13099 BI/2627/000845 2026-07-02 23 661871.21 238149.975 2.779220
4643 10054 BI/2526/001346 2025-08-22 99 124430.74 45277.670 2.748170
8702 14113 BI/2627/001859 2026-10-24 102 138877.87 50651.580 2.741827
7444 12855 BI/2627/000601 2026-06-04 71 691555.63 254833.140 2.713759
756 6167 BI/2425/000757 2024-06-28 142 138237.99 50994.765 2.710827
```
Thinking (summary)
Two credit notes show the same 0.829234 ratio, which is an odd coincidence, so I've flagged them. Next I'm looking at customer 4's large invoices from October 20 to 22, 2026, and pulling daily totals for late October plus that customer's history.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/e.py <<'EOF'
import pandas as pd, numpy as np
pd.set_option('display.width',250)
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date','created_at']);c=pd.read_csv('credit_notes.csv',parse_dates=['cn_date','created_at']);cu=pd.read_csv('customers.csv')
g=i[i.customer_id==4]; print(g.groupby(g.invoice_date.dt.to_period('M')).net_amount.agg(['count','sum']).to_string())
print(g[g.invoice_date>='2026-10-01'].to_string())
d=i[i.invoice_date>='2026-10-01'].groupby('invoice_date').net_amount.agg(['count','sum']); print(d)
# top customers share
t=i.groupby('customer_id').net_amount.sum().sort_values(ascending=False); print((t/t.sum()).head(8).round(3).to_string())
EOF
python3 /tmp/e.py
```
**Output:**
```
count sum
invoice_date
2024-05 3 1446521.31
2024-07 1 465977.07
2024-08 2 669710.60
2024-10 2 890058.31
2024-11 1 299828.58
2024-12 3 1073656.01
2025-01 1 402706.15
2025-03 1 603518.12
2025-04 1 443651.92
2025-06 1 559116.31
2025-07 4 2384888.36
2025-08 2 1055984.08
2025-10 3 1028546.05
2025-11 6 3571337.06
2025-12 4 1678429.12
2026-01 2 918594.87
2026-02 4 2205366.39
2026-03 4 1752684.96
2026-04 4 2427950.13
2026-05 1 505174.73
2026-06 2 1216382.28
2026-07 1 551286.90
2026-08 1 503701.88
2026-09 2 712846.46
2026-10 14 12504636.46
invoice_id invoice_no invoice_date customer_id currency fx_rate amount_fc net_amount gst_amount gross_amount order_ref created_at
8467 13878 BI/2627/001624 2026-10-02 4 INR 1.0 NaN 369431.50 18471.58 387903.08 SO-26013587 2026-10-02 13:05:47
8468 13879 BI/2627/001625 2026-10-02 4 INR 1.0 NaN 446119.76 22305.99 468425.75 SO-26013525 2026-10-02 14:44:58
8500 13911 BI/2627/001657 2026-10-06 4 INR 1.0 NaN 668560.31 33428.02 701988.33 SO-26013485 2026-10-06 11:29:57
8509 13920 BI/2627/001666 2026-10-07 4 INR 1.0 NaN 888233.02 44411.65 932644.67 SO-26013562 2026-10-07 11:59:58
8531 13942 BI/2627/001688 2026-10-09 4 INR 1.0 NaN 453525.98 22676.30 476202.28 SO-26013620 2026-10-09 11:01:56
8532 13943 BI/2627/001689 2026-10-09 4 INR 1.0 NaN 476277.08 23813.85 500090.93 SO-26013366 2026-10-09 14:58:00
8569 13980 BI/2627/001726 2026-10-15 4 INR 1.0 NaN 478857.80 23942.89 502800.69 SO-26013628 2026-10-15 16:55:44
8604 14015 BI/2627/001761 2026-10-20 4 INR 1.0 NaN 1177645.63 58882.28 1236527.91 SO-26013526 2026-10-20 19:56:25
8624 14035 BI/2627/001781 2026-10-21 4 INR 1.0 NaN 1411096.81 70554.84 1481651.65 SO-26013640 2026-10-21 10:16:31
8625 14036 BI/2627/001782 2026-10-21 4 INR 1.0 NaN 1591714.80 79585.74 1671300.54 SO-26013572 2026-10-21 13:08:11
8648 14059 BI/2627/001805 2026-10-22 4 INR 1.0 NaN 2290465.44 114523.27 2404988.71 SO-26013507 2026-10-22 18:12:49
8674 14085 BI/2627/001831 2026-10-23 4 INR 1.0 NaN 1163909.81 58195.49 1222105.30 SO-26013578 2026-10-23 17:32:21
8710 14121 BI/2627/001867 2026-10-26 4 INR 1.0 NaN 590138.38 29506.92 619645.30 SO-26013868 2026-10-26 12:03:20
8745 14156 BI/2627/001902 2026-10-30 4 INR 1.0 NaN 498660.14 24933.01 523593.15 SO-26013685 2026-10-30 11:30:06
count sum
invoice_date
2026-10-01 14 1515689.84
2026-10-02 15 2427910.18
2026-10-03 6 453853.39
2026-10-05 11 1015636.94
2026-10-06 10 2538980.56
2026-10-07 10 1872548.55
2026-10-08 11 1867361.68
2026-10-09 13 3251831.23
2026-10-10 6 437942.77
2026-10-12 9 1129482.18
2026-10-14 11 1072007.81
2026-10-15 6 766239.50
2026-10-16 7 763496.87
2026-10-17 8 1065010.97
2026-10-19 14 1853019.41
2026-10-20 20 3863410.13
2026-10-21 24 5398547.63
2026-10-22 26 5002445.45
2026-10-23 22 4073978.13
2026-10-24 14 1091034.76
2026-10-26 9 1635433.51
2026-10-27 14 1420663.63
2026-10-28 6 432654.11
2026-10-29 6 633651.80
2026-10-30 12 1130591.01
2026-10-31 15 1130314.65
customer_id
1 0.109
2 0.068
3 0.055
4 0.028
5 0.014
35 0.012
42 0.012
29 0.012
```
Thinking (summary)
I'm checking Merai Apparels' October 2026 billing: about ₹12.5M across 14 invoices, far above the usual ~₹1M a month and possibly over their ₹15.6M credit limit. The order references look older than the other October invoices, which suggests old orders were billed at once. I also want to see whether the October 20–23 spike includes other customers, so I'm checking those dates.
I'm also wondering whether Diwali, which falls around November 8 this year, might explain the October spike, so I'll compare against the same period in 2025, when Diwali was on October 20. I want to check the order reference lag too, and I'll set aside the credit limit question for now since there's no payments data to test it against.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/f.py <<'EOF'
import pandas as pd, numpy as np
pd.set_option('display.width',250)
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date','created_at']);c=pd.read_csv('credit_notes.csv',parse_dates=['cn_date','created_at']);cu=pd.read_csv('customers.csv')
w=i[(i.invoice_date>='2026-10-19')&(i.invoice_date<='2026-10-23')]
print(w.groupby('customer_id').net_amount.agg(['count','sum']).sort_values('sum',ascending=False).head(8))
print('without cust4 Oct2026', i[(i.invoice_date.dt.to_period('M')=='2026-10')&(i.customer_id!=4)].net_amount.sum()/1e6)
# SO number lag: SO number vs rolling typical
i=i.sort_values('invoice_id'); i['so']=i.order_ref.str[3:].astype(int)
i['so_med']=i.so.rolling(41,center=True,min_periods=1).median(); i['so_gap']=i.so-i.so_med
print(i.sort_values('so_gap').head(15)[['invoice_id','invoice_date','customer_id','order_ref','so_med','so_gap','net_amount']].to_string())
print((i.so_gap< -150).groupby(i.customer_id).sum().sort_values(ascending=False).head(5))
# region issue
e=cu[cu.currency=='EUR']; print(e.groupby('region').size())
i2=i.merge(cu[['customer_id','region','city','currency']],on='customer_id',suffixes=('','_c'))
print((i2.groupby('region').net_amount.sum()/1e6).round(1))
print((i2[i2.currency=='EUR'].groupby('region').net_amount.sum()/1e6).round(1))
EOF
python3 /tmp/f.py
```
**Output:**
```
count sum
customer_id
4 5 7634832.49
64 2 1126260.58
38 3 911524.42
60 2 716242.93
40 2 667751.08
39 1 553368.66
67 1 527820.23
63 2 496783.21
without cust4 Oct2026 35.33910023000001
invoice_id invoice_date customer_id order_ref so_med so_gap net_amount
6253 11664 2026-02-04 1 SO-25011044 26011716.0 -1000672.0 1096847.16
6309 11720 2026-02-10 3 SO-25011106 26011751.0 -1000645.0 686637.36
6521 11932 2026-03-05 3 SO-25011371 26011991.0 -1000620.0 661724.87
6670 12081 2026-03-20 3 SO-25011475 26012082.0 -1000607.0 639193.64
2816 8227 2025-02-07 1 SO-24007679 25008249.0 -1000570.0 1238125.27
2767 8178 2025-02-01 1 SO-24007660 25008225.0 -1000565.0 1215184.47
6447 11858 2026-02-25 4 SO-25011313 26011877.0 -1000564.0 431271.67
2954 8365 2025-02-25 1 SO-24007817 25008372.0 -1000555.0 1237598.57
2984 8395 2025-03-01 3 SO-24007896 25008443.0 -1000547.0 419983.38
6520 11931 2026-03-05 1 SO-25011434 26011977.0 -1000543.0 995389.10
2684 8095 2025-01-23 4 SO-24007545 25008079.0 -1000534.0 402706.15
2900 8311 2025-02-19 1 SO-24007832 25008348.0 -1000516.0 1672449.28
6131 11542 2026-01-23 4 SO-25011083 26011594.0 -1000511.0 491146.80
6329 11740 2026-02-12 2 SO-25011263 26011770.0 -1000507.0 1679030.28
6446 11857 2026-02-25 4 SO-25011372 26011877.0 -1000505.0 414561.76
customer_id
1 137
3 109
4 70
2 67
37 35
Name: so_gap, dtype: int64
region
East 2
Export 11
North 5
South 4
West 6
dtype: int64
region
East 91.1
Export 147.6
North 147.9
South 811.9
West 233.0
Name: net_amount, dtype: float64
region
East 30.6
Export 147.6
North 73.0
South 204.2
West 94.9
Name: net_amount, dtype: float64
```
Thinking (summary)
Sales order numbers carry a year prefix, so I'm comparing them by their numeric suffix. Customer 4's October orders seem to run a few hundred behind the order references, which would put the lag at roughly one to two months.
The region split is the part I'm still weighing: 17 of the 28 EUR customers sit in domestic regions despite foreign names, so "Export" looks understated, though it may just reflect accounts being managed by the South team. Customer 4's October billing of about 13.1M gross puts it close to its 15.6M credit limit once September's 30-day terms are counted, so I'll note that exposure. I also need to check whether the October credit notes are being dated by when they were issued, since that would pull them out of the October figures.
I'm checking whether the October credit notes are dated by their own issue date, which would pull them out of the October figures, and I'm noting that the 0.829234 ratio repeats across two invoices with different reasons, so it may be computed rather than a real claim. I'm also wondering whether the EUR credit notes were converted at the invoice exchange rate, which I can't confirm from what's here. Finally, I'm comparing the inactive customers with similarly named active ones to see whether they're duplicates, and I'll need to calculate their historic revenue to see what filtering on active status would drop.
I'm checking the 15 small Erode trading customers, all created on the same day with the same credit limit, to see whether that points to a bulk migration and whether their revenue looks odd. The bigger concern is that October 2026 drops to about 35.3 once customer 4 is removed, against 47.15 for October 2025, so I'm comparing the rest of the business month by month to see whether it really fell around 25%.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/g.py <<'EOF'
import pandas as pd, numpy as np
pd.set_option('display.width',250)
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date']);c=pd.read_csv('credit_notes.csv',parse_dates=['cn_date']);cu=pd.read_csv('customers.csv')
i=i.merge(cu[['customer_id','segment','region']],on='customer_id')
i['m']=i.invoice_date.dt.to_period('M')
p=i.pivot_table(index='m',columns='segment',values='net_amount',aggfunc='sum')/1e6
p['c4']=i[i.customer_id==4].groupby('m').net_amount.sum()/1e6; p['ex4']=i[i.customer_id!=4].groupby('m').net_amount.sum()/1e6
print(p.round(2).tail(16).to_string())
print(i[i.m>='2026-06'].pivot_table(index='m',columns='region',values='net_amount',aggfunc='sum').div(1e6).round(2))
a=i[i.m>='2026-06'].pivot_table(index='customer_id',columns='m',values='net_amount',aggfunc='sum').fillna(0)/1e6
a['chg']=a[pd.Period('2026-10','M')]-a[[pd.Period(x,'M') for x in ['2026-07','2026-08','2026-09']]].mean(axis=1)
print(a.sort_values('chg').head(10).round(2)); print(a.sort_values('chg').tail(5).round(2))
print('inactive rev',i[i.customer_id>=141].net_amount.sum()/1e6)
EOF
python3 /tmp/g.py
```
**Output:**
```
segment key mid small c4 ex4
m
2025-07 12.49 27.81 7.17 2.38 45.08
2025-08 11.59 25.33 6.67 1.06 42.54
2025-09 12.28 28.20 7.50 NaN 47.97
2025-10 9.06 30.83 7.26 1.03 46.12
2025-11 14.39 25.31 6.17 3.57 42.30
2025-12 13.95 26.93 7.24 1.68 46.44
2026-01 10.53 28.41 6.45 0.92 44.47
2026-02 11.91 27.16 6.92 2.21 43.78
2026-03 11.70 33.12 8.28 1.75 51.35
2026-04 15.35 23.95 8.43 2.43 45.30
2026-05 10.96 31.38 6.01 0.51 47.84
2026-06 11.00 31.33 7.84 1.22 48.95
2026-07 12.62 28.13 7.38 0.55 47.58
2026-08 12.60 23.83 9.01 0.50 44.93
2026-09 14.99 27.29 6.78 0.71 48.35
2026-10 16.52 22.88 8.45 12.50 35.34
region East Export North South West
m
2026-06 3.91 4.14 7.10 28.89 6.13
2026-07 2.98 3.39 5.47 28.24 8.05
2026-08 3.13 7.25 4.40 25.36 5.29
2026-09 3.52 5.28 4.28 28.93 7.05
2026-10 3.40 5.38 4.24 15.38 19.44
m 2026-06 2026-07 2026-08 2026-09 2026-10 chg
customer_id
1 4.39 5.98 6.50 4.55 2.12 -3.56
2 3.04 2.63 3.10 5.87 1.13 -2.74
3 2.35 3.45 2.50 3.86 0.77 -2.50
29 0.50 0.92 0.76 0.73 0.21 -0.59
28 0.00 0.55 0.48 0.66 0.00 -0.56
44 1.33 0.86 0.41 0.82 0.13 -0.56
90 0.26 0.95 0.69 0.29 0.10 -0.54
27 0.14 0.63 0.98 0.00 0.00 -0.53
86 0.44 0.28 0.98 0.75 0.15 -0.52
70 1.00 0.37 1.15 0.00 0.00 -0.51
m 2026-06 2026-07 2026-08 2026-09 2026-10 chg
customer_id
36 0.00 0.00 1.70 0.42 1.24 0.53
64 0.47 1.20 0.00 0.15 1.24 0.79
38 0.28 0.15 0.58 0.66 1.31 0.84
60 0.26 0.00 0.00 0.29 1.10 1.01
4 1.22 0.55 0.50 0.71 12.50 11.92
inactive rev 5.58155527
```
Thinking (summary)
I'm noticing that October's total looks flat, but the mix underneath has shifted a lot: customer 4 climbed from about 0.6M a month to 12.5M, while customers 1, 2 and 3 fell sharply. I'm also seeing the South region roughly halve and the West triple, and I'm wondering whether the drop in those three key accounts could be tied to that.
I'm checking whether customers 1, 2 and 3 stopped invoicing around the same time customer 4 surged, and whether the rest of the business outside those four accounts also fell. The currency and GST pattern matters here too, since the EUR accounts were billed in INR to customer 4 would leave a trace. I'll pull the daily October invoices for 1, 2 and 3 to see their timing.
**Code (bash_code_execution):**
```
cd $INPUT_DIR; cat > /tmp/h.py <<'EOF'
import pandas as pd
pd.set_option('display.width',250)
i=pd.read_csv('invoices.csv',parse_dates=['invoice_date']);cu=pd.read_csv('customers.csv')
o=i[(i.invoice_date>='2026-09-15')&i.customer_id.isin([1,2,3,4])]
print(o.pivot_table(index='invoice_date',columns='customer_id',values='net_amount',aggfunc='sum').div(1e3).round(0).fillna('').to_string())
r=i[~i.customer_id.isin([1,2,3,4])]; r=r.assign(m=r.invoice_date.dt.to_period('M'))
print(r.groupby('m').net_amount.agg(['count','sum']).tail(8))
EOF
python3 /tmp/h.py
```
**Output:**
```
customer_id 1 2 3 4
invoice_date
2026-09-15 315.0
2026-09-16 952.0
2026-09-19 1306.0
2026-09-24 1364.0
2026-09-26 3041.0 398.0
2026-09-28 986.0
2026-10-01 815.0
2026-10-02 816.0
2026-10-06 770.0 669.0
2026-10-07 888.0
2026-10-08 1127.0
2026-10-09 1301.0 930.0
2026-10-15 479.0
2026-10-20 1178.0
2026-10-21 3003.0
2026-10-22 2290.0
2026-10-23 1164.0
2026-10-26 590.0
2026-10-30 499.0
count sum
m
2026-03 332 41400868.37
2026-04 260 32383033.88
2026-05 281 37382145.23
2026-06 256 39166920.60
2026-07 233 35516856.82
2026-08 227 32834296.29
2026-09 280 34074899.62
2026-10 301 31326405.33
```
Thinking (summary)
Customers 1, 2 and 3 stop invoicing after October 9, while customer 4 surges after October 15. That pattern could mean the customer mapping is off, with key accounts merged or invoices posted to the wrong customer_id, or it could be a real shift in the business. Customers 2 and 3 are billed in EUR with no GST, and customer 4 is billed in INR at 5% GST, though I can't confirm any of this. The simpler explanation might be that customers 1 to 3 just ordered less.
The October 31.3M total is the lowest in the window but still inside the 32.4 to 41.4M range, so it's only a mild dip. Sunday invoices are a minor note. The data stops at 31 October, so FY 2026-27 is only seven months in and I shouldn't compare its totals against full years. I'll write this up concisely.
**Assistant:**
Overall the data is in good shape: it ties together and the calculations hold up. But a few things in the latest months would mislead anyone reporting from it as-is. Most important first:
**1. October 2026 looks normal in total, but it isn't.**
Net invoicing was ₹47.8M, in line with earlier months. Underneath that:
- **Merai Apparels (customer 4)** was billed **₹12.5M in 14 invoices**. It usually bills about ₹0.5–2M a month, and its biggest month before this was ₹3.6M. ₹8.2M of that came on 20–23 Oct alone, including the largest invoice relative to normal in the whole dataset (₹2.29M on 22 Oct). That's close to its ₹15.6M credit limit.
- At the same time, the **other three key accounts went quiet**. Ravira Exports, Tessora EU and Skarfab issued no invoices after 9 Oct. Their October total was ₹4.0M, against about ₹13M in an average month.
- Leaving out customer 4, October was ₹35.3M. That's the lowest month in the full history, against ₹45–51M over the previous six months.
This could be a real shift in business. But the timing (other key accounts stop, customer 4 jumps) is also what you'd see if invoices were posted to the wrong customer, or if billing was pulled forward. Check customer 4's October invoices against delivery notes before trusting the October figures or the regional split. South roughly halved and West nearly tripled that month.
**2. Two credit notes were backdated, both for one customer.**
CN/000852 and CN/000853 (Ponnavra Fabrics, customer 87) are dated 23 Oct 2026 but were entered on 31 Oct. These are the only two of 860 credit notes not entered on their own date.
- They cancel **83% of the invoice** (₹391K and ₹190K). Every other credit note is under 27%.
- Both cancel *exactly* the same share (0.829234) even though the recorded reasons differ ("Return" and "Rate difference"). That looks calculated, not like two real claims.
- One reverses a large invoice dated 19 Sep, close to the end of the first half of the financial year. Because revenue is netted by credit note date, the September revenue stays and October takes the hit.
Ask who posted these and why.
**3. The "Export" region doesn't mean export.**
Only 11 of the 28 EUR-billed customers are in the Export region. The other 17 sit under South, West, North or East, including the two big EUR key accounts (Tessora EU and Skarfab, listed as South). The note says region is the sales team managing the account, so this may be intended. Even so:
- **Export region revenue is ₹148M, but total EUR-billed revenue is about ₹550M.** For export vs domestic, use `currency`, not `region`.
- Several EUR customers have Indian cities (e.g. Vela Moda Srl in Ahmedabad), so `city` isn't reliable for them either.
**4. Other things to watch for in reporting:**
- **FY 2026-27 is a partial year** (Apr–Oct, 7 months). Don't compare its totals with full years.
- **3 inactive customers** have ₹5.6M of past revenue. Filtering on `status = active` will quietly drop it.
- March is seasonally high (₹50–53M, matching the financial year-end in March). That pattern repeats each year and isn't an anomaly.
- 2 invoices are dated on a Sunday (28 Jun and 12 Jul 2026), the only ones of 8,772. Minor.
- Concentration is high: customer 1 alone is 11% of all revenue, and the four key accounts together about 26%.
**What checked out clean:**
- No missing customer or invoice links, and no duplicate invoices or order numbers.
- Gross equals net plus GST on every invoice. GST is 5% on all INR invoices and 0% on all EUR invoices.
- EUR amount × exchange rate equals the INR value on every EUR invoice, and the rates look plausible.
- Invoice numbers run in order with no gaps within each financial year, and every prefix matches its date.
- No credit note is larger than its invoice, dated before it, or for a different customer, and no invoice has more than one credit note.
- No invoice is dated before its customer's account was created.
I'd sort out items 1 and 2 before October 2026 numbers go to anyone. I can produce a monthly net revenue view using the company's own definition, with October shown with and without customer 4, if that would help.
## Final answer (scored)
Overall the data is in good shape: it ties together and the calculations hold up. But a few things in the latest months would mislead anyone reporting from it as-is. Most important first:
**1. October 2026 looks normal in total, but it isn't.**
Net invoicing was ₹47.8M, in line with earlier months. Underneath that:
- **Merai Apparels (customer 4)** was billed **₹12.5M in 14 invoices**. It usually bills about ₹0.5–2M a month, and its biggest month before this was ₹3.6M. ₹8.2M of that came on 20–23 Oct alone, including the largest invoice relative to normal in the whole dataset (₹2.29M on 22 Oct). That's close to its ₹15.6M credit limit.
- At the same time, the **other three key accounts went quiet**. Ravira Exports, Tessora EU and Skarfab issued no invoices after 9 Oct. Their October total was ₹4.0M, against about ₹13M in an average month.
- Leaving out customer 4, October was ₹35.3M. That's the lowest month in the full history, against ₹45–51M over the previous six months.
This could be a real shift in business. But the timing (other key accounts stop, customer 4 jumps) is also what you'd see if invoices were posted to the wrong customer, or if billing was pulled forward. Check customer 4's October invoices against delivery notes before trusting the October figures or the regional split. South roughly halved and West nearly tripled that month.
**2. Two credit notes were backdated, both for one customer.**
CN/000852 and CN/000853 (Ponnavra Fabrics, customer 87) are dated 23 Oct 2026 but were entered on 31 Oct. These are the only two of 860 credit notes not entered on their own date.
- They cancel **83% of the invoice** (₹391K and ₹190K). Every other credit note is under 27%.
- Both cancel *exactly* the same share (0.829234) even though the recorded reasons differ ("Return" and "Rate difference"). That looks calculated, not like two real claims.
- One reverses a large invoice dated 19 Sep, close to the end of the first half of the financial year. Because revenue is netted by credit note date, the September revenue stays and October takes the hit.
Ask who posted these and why.
**3. The "Export" region doesn't mean export.**
Only 11 of the 28 EUR-billed customers are in the Export region. The other 17 sit under South, West, North or East, including the two big EUR key accounts (Tessora EU and Skarfab, listed as South). The note says region is the sales team managing the account, so this may be intended. Even so:
- **Export region revenue is ₹148M, but total EUR-billed revenue is about ₹550M.** For export vs domestic, use `currency`, not `region`.
- Several EUR customers have Indian cities (e.g. Vela Moda Srl in Ahmedabad), so `city` isn't reliable for them either.
**4. Other things to watch for in reporting:**
- **FY 2026-27 is a partial year** (Apr–Oct, 7 months). Don't compare its totals with full years.
- **3 inactive customers** have ₹5.6M of past revenue. Filtering on `status = active` will quietly drop it.
- March is seasonally high (₹50–53M, matching the financial year-end in March). That pattern repeats each year and isn't an anomaly.
- 2 invoices are dated on a Sunday (28 Jun and 12 Jul 2026), the only ones of 8,772. Minor.
- Concentration is high: customer 1 alone is 11% of all revenue, and the four key accounts together about 26%.
**What checked out clean:**
- No missing customer or invoice links, and no duplicate invoices or order numbers.
- Gross equals net plus GST on every invoice. GST is 5% on all INR invoices and 0% on all EUR invoices.
- EUR amount × exchange rate equals the INR value on every EUR invoice, and the rates look plausible.
- Invoice numbers run in order with no gaps within each financial year, and every prefix matches its date.
- No credit note is larger than its invoice, dated before it, or for a different customer, and no invoice has more than one credit note.
- No invoice is dated before its customer's account was created.
I'd sort out items 1 and 2 before October 2026 numbers go to anyone. I can produce a monthly net revenue view using the company's own definition, with October shown with and without customer 4, if that would help.