import.rk
Turns the rows of an uploaded CSV or XLSX file into records of one model (contract 0012).
Lives in modules/<module>/imports/<name>.rk · Schema import.json (source) · first line: # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
Properties
| Property | Type | Meaning |
|---|---|---|
name required | string | pattern ^[a-z][a-z0-9_]*$ |
label | label | A label in Bahasa Indonesia (required) and optionally English. |
label.id required | string | |
label.en | string | |
model required | string | pattern ^[a-z][a-z0-9_]*$ |
source | csv · xlsx | The default file type the wizard offers; both readers accept either |
header_row | integer | 1-based row holding the column names; rows above it are ignored min 1 |
sheet | string | xlsx only; default the first sheet |
per | outlet · org | Scope of duplicate detection (default org) |
key | list of string | Columns that identify a row, for duplicate detection at least 1 |
group | list of string | Rows with equal values become one record at least 1 |
map required | map of string or object | Model field to column or expression |
lines | object | |
lines.field required | string | pattern ^[a-z][a-z0-9_]*$ |
lines.map required | map of string or object |
Example
From rangka-apps/modules/outlet_sales/imports/daily_form.rk (first 60 lines):
yaml
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
# The daily sales sheet an outlet fills in when it has no Moka export: one row per item sold, one file per day.
# No key on purpose: import keys are never released, so with [Tanggal, SKU] a corrected sheet for a day could not
# import again even after the old record was cancelled. The same file twice is still refused by its hash, and two
# submitted forms for one outlet and day are refused at submit (409 duplicate_sales).
name: daily_form
label: {id: Formulir penjualan harian, en: Daily sales form}
model: outlet_sales
source: csv
header_row: 1
per: outlet
group: [Tanggal]
map:
date: Tanggal
source: "='form'"
lines:
field: lines
map:
item: {value: SKU, match: sku}
qty: Jumlah
gross: Penjualan kotor
discount: DiskonGenerated from the schema by website/scripts/gen-reference.mjs. Edit the schema, not this page.