# Station Admin

Yeh aapke station ke liye independent admin app hai. Iska interface naya petrol-station theme use karta hai. Yeh reference portal ka source code ya uske customer, employee, vendor ya financial records copy nahi karta.

## Abhi kya kaam karta hai

- Portal ke visible master, invoice, day-business, stock, reconciliation, loyalty, report aur help-desk sections ke liye forms aur navigation. Swipe Modes master bhi hai aur Swipe/Bowser Swipe forms se linked hai.
- Expense Types master mein source portal ka `Type` alag **Source Type** field mein rehta hai; `Effect Employee` aur `Effect Profit` alag se set kiye ja sakte hain.
- Add, edit, activate/deactivate, delete, user log, search, filters, page size, CSV/PDF print aur CSV/Excel import.
- Linked master dropdowns, cascading pump/tank/nozzle selection, aur form ke andar `+` se missing master record banana.
- Swipe Machines master optional JPEG/JPG/TIF/GIF/PNG logo upload (2 MB tak), Bank/Vendor attachment, CSV/PDF list, edit, activate/deactivate, delete aur user log rakhta hai.
- **Masters → Tank Calibration Chart** mein tank ke dip-mm/litre points save hote hain. Effective date optional hai. **Day Business → Daily Tank Dip** mein Manual dip aur ATG dip centimeter (cm) mein darj hote hain; app unhe mm mein badal kar chart se litres nikalta hai. Water dip, temperature aur operator bhi darj hote hain. Direct ATG litre reading bharne par app uski manual stock se tulna karta hai. Chart ki range se bahar litres blank rahenge.
- Calibration chart import files are in `data/kalera_ms_tank1_calibration_import.csv` (Tank No. 1 / T-1 Petrol-MS, 240 points) and `data/kalera_hsd_tank2_calibration_import.csv` (Tank No. 2 / T-2 Diesel-HSD, 250 points). Import each file from **Masters → Tank Calibration Chart → Import CSV / Excel** after the matching Tanks records exist. Source photos do not show an effective date; per user confirmation, both CSVs use 2026-07-09. Fractional-mm readings use the photo's `Diff. 1 mm` value at the lower centimeter point; old chart records without that value retain linear interpolation fallback. See `data/kalera_tank_calibration_import_guide.md` for the capacity check.
- **Day Business → Daily Density Entry** mein har tank/shift ke liye 1st aur 2nd sample alag save kar sakte hain: observed density, sample temperature aur 15°C density. Temperature correction apne aap apply nahi hoti; 15°C wali value sample sheet se bharni hai.
- **Day Business → DSM Nozzle Assignment** mein har date aur shift ke liye DSM chun kar P1/P2 jaise pump-station groups mein chal rahe nozzles checkbox se mark karein. Ek hi DU chalu ho to dono DSM ko us DU ke nozzles de sakte hain. Agar date/shift/DSM assignment maujood hai, Sale Entry aur Nozzle Shift Readings us DSM ke marked nozzles hi dikhate hain; assignment na ho to poori pump setting list available rehti hai.
- Home par aaj ke DSM/nozzle assignments dikhte hain. Purane fixed DU roster records cloud mein safe rehte hain; nayi daily assignment flow un par depend nahi karta.
- Meter sale, purchase tax, stock, credit balance/limit, recovery, payroll, bowser aur loyalty point ke common calculations.
- Sale records se invoice banana aur print/PDF save karna. E-way bill ka draft record banana aur maintain karna.
- Local browser mode, Supabase sign-in/cloud storage, staff roles, module permissions, linked station switching (**My Bunks**), password change aur workspace backup/restore. Cashier/Accountant ko apne allowed kaam ke dropdown chalane ke liye linked master aur report-source records ka read access diya jata hai; master edit access role rules se alag hai.

Calculations form ke andar live dikhte hain. Manual/ATG tank dip cm ko mm mein convert karke calibration chart se litres interpolate hote hain; direct ATG litre reading ho to woh comparison mein use hoti hai. Density at 15°C manually darj hoti hai; automatic correction factor configure nahi hai. Product tax rates, meter tolerance/rollover, stock variation, payroll month days aur currency precision Super Admin settings mein set hote hain. BRS/VRS report date, account, type aur amount se match karti hai. Aapke actual station ke hisaab se rules ko pehle sample entries se milayein.

Reports inactive (deactivated) entries ko totals mein nahi jodte. Day Cash Report mein pump meter sale se Swipe aur Credit entries ghata kar expected cash nikala jata hai; yeh flow model ka working assumption hai. Real data shuru karne se pehle ise apne station ke daily settlement se milayein.

## Local preview

`index.html` browser mein khol kar local preview dekhein. Local mode ka data usi browser/device mein rahega; doosre device se nahi dikhega.

## Kalera cloud data

Kalera ka Supabase project is app ke liye set hai, database schema install hai, aur diye gaye CSV / July workbook records cloud mein load ho chuke hain. App kholte hi **Admin login** screen aati hai. Apne Supabase admin email aur password se sign in karein; sign-in ke baad imported records dashboard par dikhenge. Project URL ya publishable key badalni ho to login screen se **Cloud settings** kholein. Is project par schema dobara chalane ki zaroorat nahi hai.

Naya alag Supabase project use karna ho to us project ke SQL Editor mein `supabase_schema.sql` chalayein, phir **Cloud & account** mein uska Project URL aur sirf publishable key save karke sign in karein. `service_role` ya secret key browser app mein kabhi na daalein.

Staff ko unke email ke saath Super Admin Settings mein role dein. Staff ko usi email se apna sign-in account banana hoga.

Sirf publishable key use karein. `service_role` ya secret key browser app mein kabhi na daalein.

## Portal se data lana

Pehle portal se official CSV ya `.xlsx` export lein. App mein sambandhit module khol kar **Import CSV / Excel** dabayein. Ek Excel file ki pehli sheet padhi jaati hai. Pehle master files import karein; phir un par nirbhar entries import karein. Har file ka preview aur error list import se pehle dikhai jaati hai. Purani `.xls` file ko `.xlsx` ya CSV mein save karein.

CSV export Excel mein Hindi/₹ text sahi dikhane ke liye UTF-8 BOM ke saath banta hai. CSV import se pehle apne cloud workspace ka backup rakhein.

## Live website par laane se pehle

Yeh folder abhi local preview hai; hosted URL ya custom domain publish nahi hua. Cloud account, hosting, domain, real customer data aur SMS/WhatsApp/email providers aapke apne accounts se configure karne honge. Invoice app ke andar print hota hai. E-way bill screen preparation record rakhti hai, government/provider par submit nahi karti. Tally integration ko baad ke liye rakha gaya hai.

### Baahari references

- [Supabase Data API](https://supabase.com/docs/guides/api)
- [Supabase password sign-in](https://supabase.com/docs/reference/javascript/auth-signinwithpassword)
- [Supabase Row Level Security](https://supabase.com/docs/guides/database/postgres/row-level-security)
# Local and LAN access

`Start Kalera Local.cmd` serves the site on `127.0.0.1:8767` by default. To allow another device on the same private network, start `serve-local.js` with `HOST=0.0.0.0` and optionally set `PORT`. The server prints the local and LAN addresses. Windows Firewall must allow the selected port. Keep the computer and browser session secured; this does not publish the site to the internet.

