Enterprise Cookbook Real-World Recipes

Production recipes for reshaping complex Tally ERP, accounting vouchers, and XML exports.

Recipe 1: Tally Stock Items & Batch Allocations

When fetching stock items with inventory allocations from TallyPrime, the raw payload contains XML attributes (@_TYPE), text objects (#text), and verbose list keys (BATCHALLOCATIONS.LIST).

Source JSON (The Food)

{
  "STOCKITEM": [
    {
      "BASEUNITS": {
        "#text": "kgs",
        "@_TYPE": "String"
      },
      "@_NAME": "0.09/30mm",
      "@_RESERVEDNAME": "",
      "BATCHALLOCATIONS.LIST": {
        "GODOWNNAME": "Main Location",
        "BATCHNAME": "Navratan-Rs.1210/-",
        "OPENINGBALANCE": "-9.250 kgs",
        "OPENINGVALUE": 11100,
        "OPENINGRATE": "1200.00/kgs"
      }
    }
  ]
}

Recipe JSON (The Recipe)

{
  "transform": {
    "STOCKITEM": {
      "alterKey": "StockItems",
      "transform": {
        "BASEUNITS": {
          "alterKey": "Units",
          "valueKey": "#text"
        },
        "@_NAME": { "alterKey": "Name" },
        "@_RESERVEDNAME": { "alterKey": "ReserveName" },
        "BATCHALLOCATIONS.LIST": {
          "alterKey": "Batches",
          "valueType": "array",
          "transform": {
            "GODOWNNAME": { "alterKey": "godownName" }
          }
        }
      }
    }
  }
}

Transformed Output JSON (Consumption)

{
  "StockItems": [
    {
      "Units": "kgs",
      "Name": "0.09/30mm",
      "ReserveName": "",
      "Batches": [
        {
          "godownName": "Main Location"
        }
      ]
    }
  ]
}

Recipe 2: Accounting Ledgers & Balance Normalization

Extracting closing balances and currency codes from multi-currency ledger dumps:

Source JSON

{
  "LEDGER": [
    {
      "NAME": { "#text": "HDFC Bank Account", "@_TYPE": "String" },
      "PARENT": "Bank Accounts",
      "CURRENCY": { "#text": "INR", "@_TYPE": "Currency" },
      "CLOSINGBALANCE": { "#text": "145000.00", "@_TYPE": "Amount" }
    }
  ]
}

Recipe JSON

{
  "transform": {
    "LEDGER": {
      "alterKey": "accounts",
      "transform": {
        "NAME": { "alterKey": "bankName", "valueKey": "#text" },
        "PARENT": { "alterKey": "group" },
        "CURRENCY": { "alterKey": "currency", "valueKey": "#text" },
        "CLOSINGBALANCE": { "alterKey": "balance", "valueKey": "#text" }
      }
    }
  }
}