Skip to content

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 ​

PropertyTypeMeaning
name requiredstring
pattern ^[a-z][a-z0-9_]*$
labellabelA label in Bahasa Indonesia (required) and optionally English.
label.id requiredstring
label.enstring
model requiredstring
pattern ^[a-z][a-z0-9_]*$
sourcecsv · xlsxThe default file type the wizard offers; both readers accept either
header_rowinteger1-based row holding the column names; rows above it are ignored
min 1
sheetstringxlsx only; default the first sheet
peroutlet · orgScope of duplicate detection (default org)
keylist of stringColumns that identify a row, for duplicate detection
at least 1
grouplist of stringRows with equal values become one record
at least 1
map requiredmap of string or objectModel field to column or expression
linesobject
lines.field requiredstring
pattern ^[a-z][a-z0-9_]*$
lines.map requiredmap 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: Diskon

Generated from the schema by website/scripts/gen-reference.mjs. Edit the schema, not this page.

Rangka OS is source-available under the Elastic License 2.0 (ELv2). Free to self-host.