Add first mapping attempt

AfoHT
Jul 12, 2021, 9:38 PM
4BWPI66VMCGJSBGGIZMAFEKJGFMBS7HSV5H2GUC6QUF32XR6ZSCAC

Dependencies

Change contents

  • edit in src/main.rs at line 2
    [2.72][2.72:85]()
    use std::io;
  • replacement in src/main.rs at line 38
    [2.1095][2.1095:1127]()
    amount_num: Option<String>,
    [2.1095]
    [2.1127]
    amount_num: Option<f32>,
  • edit in src/main.rs at line 49
    [2.1404][2.1404:1463]()
    let mut wtr = csv::Writer::from_writer(io::stdout());
  • replacement in src/main.rs at line 50
    [2.1464][2.1464:1528]()
    //let mut wtr = csv::WriterBuilder::from_writer(&self, wtr)
    [2.1464]
    [2.1528]
    let mut wtr = csv::Writer::from_path("foo.csv")?; //
  • replacement in src/main.rs at line 75
    [2.2132][2.2132:2166]()
    println!("{:?}", record);
    [2.2132]
    [2.2166]
    //println!("{:?}", record);
    // Match based on action which account
    let account_name = match record.typ.as_str() {
    "Insättning" => "Tillgångar:Likvida Medel:Brukskonto",
    "Uttag" => "Utgifter:AttSortera:Swish",
    "Reserverat Belopp" => "Utgifter:AttSortera:Kreditkort:Reserverade",
    "Korttransaktion" => "Utgifter:AttSortera:Kreditkort",
    _ => "INVALID",
    };
    wtr.write_record(&[
    // Date
    record.datum,
    // Transaction ID, let GnuCash generate
    "".into(),
    // Number, let GnuCash generate
    "".into(),
    // Description
    record.text,
    // Notes
    "".into(),
    // Currency
    "CURRENCY::SEK".into(),
    // Void Reason
    "".into(),
    // Action
    record.typ,
    // Memo
    "".into(),
    // Full Account Name",
    account_name.into(),
    // Account Name",
    "".into(),
    // Amount With Sym.",
    "".into(),
    // Amount Num",
    record
    .belopp
    .replace(" kr", "")
    .replace(",", ".")
    .chars()
    .filter(|c| c.is_ascii())
    .filter(|c| !c.is_whitespace())
    .collect::<String>()
    .parse::<f32>()
    .unwrap()
    .to_string(),
    // Reconcile",
    "n".into(),
    // Reconcile Date",
    "".into(),
    // Rate/Price",
    "1".into(),
    ])?;