Commit Graph

17791 Commits

Author SHA1 Message Date
Geert Janssens
a0320d3a21 Allow user to only select column_types that make sense in the current context
The context being either multi-split or two-split. There's no use
in selecting a Transaction ID column in two-split mode for example.
Similarly none of the 'Transfer xzy' types will be used in
multi-split mode.
2017-02-20 17:55:00 +01:00
Geert Janssens
0b345d471e Drop balance column from csv importer
In its current state it will only work for a very restricted context.
However there's no code to validate this context so the importer will
happily produce wrong results in all other contexts.
A query on the mailing list didn't return any interest in this feature
so instead of fixing it I'd rather drop it to keep the code clean.
2017-02-20 17:54:57 +01:00
Geert Janssens
847b140b34 Adapt csv export format to new csv importer capabilities 2017-02-20 17:54:54 +01:00
Geert Janssens
35ba4ec92f Extend csv importer to be able to import multi-currency and stock transactions 2017-02-20 17:54:52 +01:00
Geert Janssens
49bbbca1d5 Extend csv importer to be able to import voided transactions 2017-02-20 17:54:46 +01:00
Geert Janssens
95d7e17c7b Extend csv importer to be able to import reconcile states
A detail worth noting: contrary to most other date fields
an empty value for a reconcile date is allowed if the reconcile
field is not set to 'y' (reconciled).
2017-02-20 17:54:43 +01:00
Geert Janssens
2492931094 Add additional check before creating splits or transactions
This allows the code following the check to make certain assumptions about the state
of the prop objects.
2017-02-20 17:54:40 +01:00
Geert Janssens
d2597ef1e2 Defer testing boost:optionals until really needed
Similarly only lookup book when really needed
2017-02-20 17:54:38 +01:00
Geert Janssens
848c7b8f8e Create trans/split props only when needed and have them keep their own value of date/currency format 2017-02-20 17:54:35 +01:00
Geert Janssens
443237f2b9 Extend csv importer to be able to import split action fields
At the same time drop the exception handling for the num for action setting.
The importer can't possibly get this right automatically in all cases. It's
now up to the user to assign the right columns to the correct properties
based on how he/she wants gnucash to store it internally.
2017-02-20 17:54:33 +01:00
Geert Janssens
5950b902a4 Avoid assigning empty or null char*'s to a std::string
Apparently this can cause segfaults
2017-02-20 17:54:30 +01:00
Geert Janssens
6d304d3c3e csv import prefs - store coltypes as strings
Additionally use g_key_file_[gs]_<type>_list to store and retrieve coltypes and colwidths
instead of storing/retrieving a raw string to parse afterwards
2017-02-20 17:54:26 +01:00
Geert Janssens
1fc4b3cd9b Convert column_widths to a vector 2017-02-20 17:54:24 +01:00
Geert Janssens
9e70166b8e Drop superfluous code that sets the default in case of an error.
The returned values in case of an error from the g_key_file_get* are
the correct defaults in most cases already.
In addition:
- Reduce number of temporary variables
- Fix a memory leak while testing the saved data
2017-02-20 17:54:21 +01:00
Geert Janssens
e8d24e193b Use std::vector to store column types, and a few other data type changes 2017-02-20 17:54:14 +01:00
Geert Janssens
7a69d552bd Convert CsvTransSettings into a c++ class 2017-02-20 17:54:12 +01:00
Geert Janssens
dcce2d79cd Remove final dependencies on GOFFICE
This was still pulled in via the now removed gnc-csv-model.
In order to remove this, the fixed format csv importer
has been tweaked to get the required features from
the c++ csv importer code instead.
2017-02-20 17:54:09 +01:00
Geert Janssens
861bff3f3b Fix error handling in the multi-split case (and probaly in the other case as well)
Dereferencing an iterator and then assigning it to another variable
apparently copies the object the iterator points at, instead
of making a reference to it. C++ beginner mistakes...
Also do the multi-split parent dance before handling errors. Otherwise
child lines would be mistakenly added to the first working parent split
instead of also being skipped until the parent is fixed.
2017-02-20 17:54:06 +01:00
Geert Janssens
8e20c6404e Introduce multi-split imports in the csv importer
This should be the start for round-trip export-import.
Full roundtrip is not supported yet though. Missing
is multi-currency/commodity imports.
2017-02-20 17:54:03 +01:00
Geert Janssens
4f2980ef42 Rework csv import preview with additional cleanups
- The preview part should be less chaotic now. It already has an option for future multi-split
  import functionality, but that's not used yet
- rename a few variables
- change semantics on start/end lines; this is now communicated in number of lines to skip
- avoid a couple of double value storing (once in the assistant object and onece in the import object)
2017-02-20 17:54:00 +01:00
Geert Janssens
056d20c1f7 Fix memory leaks in the draft transactions object 2017-02-20 17:53:57 +01:00
Geert Janssens
854ee31989 Cleanup commit
- improve comments
- improve variable and function names (to be more concise and to the point
- use 'Transfer Account' instead of 'Other Account' as that's the term used in the rest of gnucash
2017-02-20 17:53:55 +01:00
Geert Janssens
90e5e96f8f Rework the intermediate properties storage
The overly complex templated class hierarchy is replaced
with two simple classes. One to keep the discovered transaction
properties and one for the discovered split properties. Make
both classes responsible for verifying it's state and creating
the necessary objects.
2017-02-20 17:53:52 +01:00
Geert Janssens
d642d0804b Refactor parse_to_trans into smaller functions 2017-02-20 17:53:49 +01:00
Geert Janssens
ab6dc0f590 Add property structs for transaction vs split properties 2017-02-20 17:52:17 +01:00
Geert Janssens
91df5edaa5 Refactor pair into a tuple in preparation of extending it 2017-02-20 17:51:51 +01:00
Geert Janssens
ffa68c6b84 Factor out balance calculating function 2017-02-20 17:51:46 +01:00
Geert Janssens
0d4d92fbb4 Drop unused parameter 2017-02-20 17:51:43 +01:00
Geert Janssens
f64d217ed3 Drop remaining GError boilerplate from the c++ importer 2017-02-20 17:51:40 +01:00
Geert Janssens
430875772b Replace GError usage in parse function with proper try catch blocks
In addition fix a crash while loading importer settings that would reduce
the number of columns found in the import file.
2017-02-20 17:51:38 +01:00
Geert Janssens
d64c66e68d Replace GError usage in file_format and load_file with proper try catch blocks 2017-02-20 17:51:35 +01:00
Geert Janssens
b9e73d923e Throw in case date can't be parsed instead of returning -1 as date 2017-02-20 17:51:33 +01:00
Geert Janssens
bbac6aa1c5 Various small C++ and other cleanups
- Use CamelCase for type definitions and _ for function names
- m_ for member variables
- avoid typedef (not needed for structs, replace by using for aliases)
- use std::string for composing strings
- fix condition part in for loop (can't use , need &&)
- markup comment for doxygen inclusion
2017-02-20 17:51:31 +01:00
Geert Janssens
2638056203 Use gnc-date functions while parsing date strings for consistent timezone handling 2017-02-20 17:51:28 +01:00
Geert Janssens
c0d518e870 Migrate the glib based test case for GncTxImport to google-test 2017-02-20 17:51:25 +01:00
Geert Janssens
9525d9b84b Use consistent name for importer class and its filename
The class was still called after the original struct in c and the file
had an almost ok name from when I started the conversion.
Add some usage information to the class as well.
2017-02-20 17:51:22 +01:00
Geert Janssens
a6aa76fc76 Fix column sizing for fixed width data
It was written to work with absolute column positions (from stf)
but boost::tokenizer uses column widths instead.
2017-02-20 17:51:19 +01:00
Geert Janssens
bce5eaaa1d Prevent crash when switching to fixed with in assistant
The problem was initially the user doesn't have any column offsets
defined which the tokenize function wasn't handling properly
2017-02-20 17:42:49 +01:00
Geert Janssens
da0120d533 Readd a column for the error messages when reviewing parse errors 2017-02-20 17:42:46 +01:00
Geert Janssens
c1d798d0b0 Return nullptr in case of invalid numeric field to allow proper error handling 2017-02-20 17:42:45 +01:00
Geert Janssens
e0caec0e22 Rearrange statements in gnc_csv_preview_update_assist
- Use a more logical grouping for setting up liststores and columns
- Use one common store for all the header line's combo box entries
- Store column number in each combo box entry for later retrieval
2017-02-20 17:42:44 +01:00
Geert Janssens
6adbab1d38 Use one common liststore for all the combocells in the preview header treeview
They all show the same list anyway and this simplifies the code
2017-02-20 17:42:42 +01:00
Geert Janssens
bbeb351aa8 Some changes to adhere better to the gnucash coding guidelines
- use m_ prefix on member variables
- prefer passing by reference over copying
2017-02-20 17:42:41 +01:00
Geert Janssens
737cbfb35b Drop fake test in fw tokenizer 2017-02-20 17:42:39 +01:00
Geert Janssens
f47d12c373 Add test cases for tokenizer classes 2017-02-20 17:42:38 +01:00
Geert Janssens
b425a5e7dd Trim whitespace in case of fixed width input 2017-02-20 17:42:37 +01:00
Geert Janssens
1b44310b04 Replace transactions GList with a std::multimap 2017-02-20 17:42:32 +01:00
Geert Janssens
d557c01c88 Another round of small c to c++(11) conversions
- prefer c++ data types (auto, bool, int, std::string)
- iterate over vectors instead of accessing via the [] operator
- use boost::{u32}regex instead of directly manipulating a c-string
2017-02-20 17:42:30 +01:00
Geert Janssens
05c187960a Delay the test for a default account until it's needed 2017-02-20 17:42:29 +01:00
Geert Janssens
11ff8273e5 Fix memory management for the temporary trans properties
This is done by wrapping each property in a minimal template class hierarchy
and keep track of each using a std::shared_pointer
2017-02-20 17:42:28 +01:00