Add extra mode for utdrags-CSV-files

AfoHT
Aug 29, 2024, 12:34 AM
3BJOTZ6PL56ILFOL46DYJ7HKUJXSIG3PVCNM6WES2USI5HY2LKSAC

Dependencies

  • [2] PPY4AJBO split ica and gnucash
  • [3] 5USC3DZ3 Split out CSV into a module
  • [4] GFBOF5P6 Tune amount/value
  • [5] 5OTWTEPS Implement GCTransaction and GCTransactionBuffer
  • [*] QDZOD3MN Able to parse CSV
  • [*] YFZX4FSZ Generate transaction numbers

Change contents

  • edit in src/main.rs at line 31
    [8.1936]
    [8.1936]
    println!("Extra arguments: {}", args[3]);
    if !args[3].is_empty() {
    println!("Importing using 'Utdrag' ordering")
    }
  • edit in src/ica_csv.rs at line 21
    [3.2068]
    [3.2068]
    // If we get an argument, this is the special case when creating
    // CSV based on Utdrag PDF files.
    // There the order is sequential, with first entry first
    let utdrag_entry_order = !&args[3].is_empty();
  • replacement in src/ica_csv.rs at line 110
    [3.5592][3.5592:5651]()
    write_csv(&mut wtr, &mut transaction_buffer)?;
    [3.5592]
    [3.5651]
    write_csv(&mut wtr, &mut transaction_buffer, utdrag_entry_order)?;
  • replacement in src/ica_csv.rs at line 159
    [3.7153][3.7153:7204]()
    write_csv(&mut wtr, &mut transaction_buffer)?;
    [3.7153]
    [3.7204]
    write_csv(&mut wtr, &mut transaction_buffer, utdrag_entry_order)?;
  • edit in src/ica_csv.rs at line 167
    [3.3889]
    [3.7313]
    utdrag_entry_order: bool,
  • replacement in src/ica_csv.rs at line 170
    [3.7416][3.7416:7477](),[3.7477][2.97:148]()
    for (counter, row) in buf.iter_mut().rev().enumerate() {
    row.set_number((counter + 1).to_string());
    [3.7416]
    [3.7572]
    if utdrag_entry_order {
    for (counter, row) in buf.iter_mut().enumerate() {
    row.set_number((counter + 1).to_string());
    }
    // Write CSV in original order, most recent first
    while let Some(row) = buf.pop_front() {
    wtr.write_record(row.output())?;
    }
    } else {
    for (counter, row) in buf.iter_mut().rev().enumerate() {
    row.set_number((counter + 1).to_string());
    }
    // Write CSV in original order, most recent first
    while let Some(row) = buf.pop_front() {
    wtr.write_record(row.output())?;
    }
  • edit in src/ica_csv.rs at line 187
    [3.7578][3.7578:7676](),[3.7676][3.3939:3980](),[3.3980][3.7708:7714](),[3.7708][3.7708:7714]()
    // Write CSV in original order, most recent first
    while let Some(row) = buf.pop_front() {
    wtr.write_record(row.output())?;
    }