{
    "table": "sales_receipts",
    "primary_key": "sales_receipt_id",
    "columns": [
      "sales_receipt_id",
      "org_id",
      "type",
      "invoiceNumber",
      "requestedBy",
      "sdcDateTime",
      "invoiceCounter",
      "invoiceCounterExtension",
      "taxItems",
      "verificationUrl",
      "verificationQRCode",
      "journal",
      "messages",
      "signedBy",
      "encryptedInternalData",
      "signature",
      "totalCounter",
      "transactionTypeCounter",
      "totalAmount",
      "taxGroupRevision",
      "businessName",
      "tin",
      "locationName",
      "address",
      "district",
      "mrc",
      "transactiontype",
      "createdAt"
    ],
    "required_columns": ["invoiceNumber", "type", "totalAmount", "org_id"],
    "unique_fields": ["invoiceNumber", "org_id"],
    "joins": [
      {
        "type": "left",
        "table": "lineitems_payments",
        "first": "sales_receipts.sales_receipt_id",
        "second": "lineitems_payments.sales_receipt_id",
        "operator": "="
      }
    ],
    "additional_columns": [
      {
        "name": "line_items",
        "source": "lineitems_payments.line_items",
        "type": "jsonb"
      },
      {
        "name": "payments",
        "source": "lineitems_payments.payments",
        "type": "jsonb"
      }
    ],
    "export_transforms": {
      "sdcDateTime": {
        "type": "date",
        "format": "Y-m-d H:i:s"
      },
      "createdAt": {
        "type": "date",
        "format": "Y-m-d H:i:s"
      },
      "line_items": {
        "type": "json_decode",
        "pretty_print": true
      },
      "payments": {
        "type": "json_decode",
        "pretty_print": true
      },
      "taxItems": {
        "type": "json_decode",
        "pretty_print": true
      }
    },
    "import_transforms": {
      "sdcDateTime": {
        "type": "datetime",
        "format": "Y-m-d H:i:s",
        "allow_null": true
      },
      "createdAt": {
        "type": "datetime",
        "format": "Y-m-d H:i:s",
        "allow_null": true
      },
      "line_items": {
        "type": "json",
        "validate_structure": {
          "required_fields": ["product_id", "quantity", "unit_price"],
          "array_structure": true
        }
      },
      "payments": {
        "type": "json",
        "validate_structure": {
          "required_fields": ["method", "amount"],
          "array_structure": true
        }
      },
      "taxItems": {
        "type": "json",
        "allow_null": true
      },
      "totalAmount": {
        "type": "decimal"
      },
      "totalCounter": {
        "type": "integer",
        "allow_null": true
      },
      "transactionTypeCounter": {
        "type": "integer",
        "allow_null": true
      },
      "taxGroupRevision": {
        "type": "integer",
        "allow_null": true
      }
    },
    "field_labels": {
      "sales_receipt_id": "Receipt ID",
      "org_id": "Organization ID",
      "type": "Type",
      "invoiceNumber": "Invoice Number",
      "requestedBy": "Requested By",
      "sdcDateTime": "SDC Date/Time",
      "invoiceCounter": "Invoice Counter",
      "invoiceCounterExtension": "Invoice Counter Extension",
      "taxItems": "Tax Items (JSON)",
      "verificationUrl": "Verification URL",
      "verificationQRCode": "Verification QR Code",
      "journal": "Journal",
      "messages": "Messages",
      "signedBy": "Signed By",
      "encryptedInternalData": "Encrypted Internal Data",
      "signature": "Signature",
      "totalCounter": "Total Counter",
      "transactionTypeCounter": "Transaction Type Counter",
      "totalAmount": "Total Amount",
      "taxGroupRevision": "Tax Group Revision",
      "businessName": "Business Name",
      "tin": "TIN",
      "locationName": "Location Name",
      "address": "Address",
      "district": "District",
      "mrc": "MRC",
      "transactiontype": "Transaction Type",
      "createdAt": "Created At",
      "line_items": "Line Items (JSON)",
      "payments": "Payments (JSON)"
    },
    "export_options": {
      "include_json_fields": true,
      "pretty_print_json": true,
      "include_verification_data": true
    },
    "import_options": {
      "parse_json_fields": true,
      "create_lineitems_record": true,
      "validate_product_references": true,
      "update_existing": true
    },
    "validation_rules": {
      "totalAmount": {
        "type": "numeric",
        "min": 0,
        "required": true
      },
      "invoiceNumber": {
        "type": "string",
        "required": true,
        "max_length": 255
      },
      "type": {
        "type": "string",
        "required": true
      },
      "line_items": {
        "type": "json_array",
        "min_items": 1,
        "item_validation": {
          "product_id": {
            "type": "uuid",
            "required": true
          },
          "quantity": {
            "type": "numeric",
            "min": 0,
            "required": true
          },
          "unit_price": {
            "type": "numeric",
            "min": 0,
            "required": true
          }
        }
      }
    }
  }