Nature Green — Tally Connector

Document purpose: Developer handover for the Nature Green Tally Connector. This guide explains the project structure, key components, data flows, APIs, Tally XML contract, setup & deployment steps, testing & troubleshooting, known issues, and recommended next work for incoming developers.


1. Project Summary

Nature Green Tally Connector is a middleware/web UI that connects the Nature Green ERP and Tally for two-way data sync: products/stock, suppliers, purchases, and ledger/payment related data. It provides an admin UI for configuration, mapping, and manual synchronization plus automated sync jobs.

Primary goals:

  • Allow users to configure Tally connection and sync master data (items, suppliers), transactions (purchase invoices, receipts), and inventory.

  • Generate and parse Tally-compatible XML for the Tally SOAP-like interface.

  • Provide logging, retry, and reconciliation features so operations are auditable and recoverable.


2. Repositories & Key Paths

This section lists the file structure you provided and highlights where to find important code.

Frontend (React / Vite or similar)

  • Main UI components: /components/screens/app/ — core screens and feature pages.

    • Authentication: /components/screens/app/Authentication/

      • Login.jsx, LoginWithCompanyDetails.jsx

    • Dashboard: /components/screens/app/Dashboard/

      • Dashboard.jsx, CustomData.jsx, SystemSetting.jsx

    • ERP module: /components/screens/app/ERP/

      • ErpSettingPage.jsx, Purchases.jsx, StockItem.jsx, Suppliers.jsx

    • Tally integration UI: /components/screens/app/tally/

      • TallySettings.jsx

    • Logs & Error UI: /components/screens/app/LogsFolder/Logs.jsx, ErrorPage.jsx

  • UI primitives & reusable components: /components/ui/

Services & Utilities

  • Authentication Service: /utils/services/server/authentication.service.js

  • ERP Service: /utils/services/server/erp.service.js

  • Tally Service: /utils/services/server/tally.service.js

    • Tally XML generation & parsing logic lives under this service.

Other

  • System logging UI: /components/screens/app/LogsFolder/ — displays logs from sync jobs.

  • Entry scripts for sync/cron jobs (if present) — search for files named sync, tally_sync, cron in repo root or scripts/.


3. High-level Architecture & Data Flow

  1. User Interface: Admin config and manual sync triggers are on the React UI. Users may configure ERP API endpoints, label mapping, Tally connection (host/port/company), schedule jobs, and run manual syncs.

  2. Service Layer: The frontend calls internal server endpoints (ERP service / Tally service). These services perform mapping, fetch data from ERP API, transform to Tally XML, and call Tally endpoints or accept Tally responses.

  3. Tally Communication: Tally integration uses HTTP POST requests with XML payloads conforming to Tally’s Import/Export format. The Tally service creates XML envelopes for masters (stock items, ledgers) and vouchers (purchases), posts to the Tally server, and parses responses for success/failure.

  4. Persistence & Logging: Operation status, request/response payloads, errors, and reconciliation data are stored in the app database or logs for audit and troubleshooting. The UI shows logs in the Logs page.

  5. Scheduling: Cron or scheduled jobs periodically sync configured entities. Jobs can be retried on failure and tracked in logs.


4. Data Mapping Rules

The connector maps data between Nature Green ERP and Tally. Mapping lives in config or code (check erp.service.js and tally.service.js). Key mapping points:

  • Item (Stock Item)

    • ERP: item_code, item_name, hsn, uom, price, stock_levels

    • Tally: STOCKITEM NAME, PARENT, UQC, ISGSTABLE, RATE

  • Supplier / Ledger

    • ERP supplier maps to Tally Ledger with group (e.g., Sundry Creditors).

    • Banking details may become Ledger + Bank A/c.

  • Purchase Vouchers / Invoices

    • ERP purchase invoice maps to Tally VOUCHER (Purchase) with VOUCHERTYPENAME = Purchase / Purchase Invoice.

    • Line items must include STOCKITEM block for each item, quantity and rate.

  • Stock / Serial No

    • If serial number tracking exists, ensure Tally XML carries BATCHALLOCATIONS or ALLINVENTORYENTRIES.LIST sub-blocks as per Tally schema.

Important: Always use canonical field names expected by Tally. Use the Tally service to generate correct XML wrappers.


5. Tally XML Contract (how to generate & parse)

Generation (Outbound to Tally)

  1. Build a ENVELOPE root with HEADER and BODYIMPORTDATAREQUESTDATATALLYMESSAGE nodes.

  2. For masters (Stock Items, Ledgers), use MASTER tags structured as Tally expects (example: STOCKITEM entries inside TALLYMESSAGE).

  3. For transactions, build VOUCHER entries with fields: DATE, VOUCHERTYPENAME, PARTYLEDGERNAME, ALLINVENTORYENTRIES.LIST containing STOCKITEM blocks.

  4. Include COMPANY name in the envelope if Tally is running multiple companies.

Parsing (Inbound from Tally)

  • Tally returns an XML response with IMPORTSUCCESS/IMPORTERROR or RESPONSE nodes. Parse to extract OLDDOCNUMBER, LINESTATUS or error messages. Log request & response.

Edge cases:

  • Tally may respond with partial errors (some vouchers succeed, some fail in the same payload). Handle partial success and reconcile which records to retry.

  • When sending masters, ensure dependencies exist (e.g., Ledger group) before inserting child objects.


6. Key Functions & Where to Find Them

Search for these functions/keywords in the repo to locate logic quickly:

  • generateTallyXML / buildEnvelope / createVoucherXML

  • postToTally / tallyRequest / sendToTally

  • mapErpToTally / mapFields / fieldMapping

  • parseTallyResponse / handleTallyResponse

  • syncItems / syncSuppliers / syncPurchases

  • getAuthToken / validateSession (auth handling)

Files likely containing logic:

  • /utils/services/server/tally.service.js

  • /utils/services/server/erp.service.js

  • Any scripts/ or jobs/ folder for scheduled syncs


7. Authentication & Security

  • User sessions: Handled by authentication.service.js. It should manage login, token set, and refresh flow.

  • API keys to ERP / Tally: Store in .env and do not commit. For production use a secrets manager.

  • Tally security: Tally usually listens on HTTP; it expects correctly formed XML. Ensure network access is restricted between app server and Tally host (VPC / firewall / IP allowlist).

  • Permissions: Ensure only admin-level users can run manual syncs and change mappings. Implement role-based UI restrictions.


On this page