Add pass flushing for move money

This commit is contained in:
piv
2023-03-08 10:35:47 +10:30
parent 4c2b9f6915
commit d9f994195e
5 changed files with 128 additions and 32 deletions

View File

@@ -14,10 +14,14 @@ pub use self::overhead_allocation::*;
mod create_products;
pub use self::create_products::*;
mod shared_models;
pub use self::shared_models::*;
#[no_mangle]
pub extern "C" fn move_money_from_text(
rules: *const c_char,
lines: *const c_char,
accounts: *const c_char,
use_numeric_accounts: bool,
) -> *mut c_char {
let mut output_writer = csv::Writer::from_writer(vec![]);
@@ -29,11 +33,17 @@ pub extern "C" fn move_money_from_text(
assert!(!lines.is_null());
CStr::from_ptr(lines)
};
let safe_accounts = unsafe {
assert!(!lines.is_null());
CStr::from_ptr(accounts)
};
move_money(
csv::Reader::from_reader(safe_rules.to_bytes()),
csv::Reader::from_reader(safe_lines.to_bytes()),
csv::Reader::from_reader(safe_accounts.to_bytes()),
&mut output_writer,
use_numeric_accounts,
true,
);
// TODO: Replace all these unwraps with something more elegant
let inner = output_writer.into_inner().unwrap();