put method

Konto put(
  1. String ktoName,
  2. Konto kto
)

set at ktoName (Treewise) the data if kto (kto will be discarded afterwards) create the account if needed .

Implementation

Konto put(String ktoName, Konto kto) {
  if (ktoName.length < 1)
    print("Error, KPL, don't know how to add $kto @ $ktoName");
  else if (ktoName.length == 1)
    konten[ktoName] = kto;
  else {
    String key = ktoName[0];
    String rest = ktoName.substring(1, ktoName.length);
    if (!konten.containsKey(key))
      konten[key] = Konto(number: key, plan: this);

    //fetch the account, creating it on the way
    var locK = konten[key]!.get(rest, orgName: ktoName);
    locK.name = kto.name;
    locK.plan = this;
    locK.desc = kto.desc;
    locK.cur = kto.cur;
    locK.budget = kto.budget;
    locK.valuta = kto.valuta;
    kto = locK;
  }
  return kto;
}