From ab4e5956701888a8c2e74fb5d15c7d3186f5534d Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Tue, 27 Jun 2023 19:07:27 +0100 Subject: [PATCH 1/2] Add failuref() test function that allows the use of format strings --- common/test-core/test-stuff.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/test-core/test-stuff.h b/common/test-core/test-stuff.h index 6c51e136f1..c14cf6fed1 100644 --- a/common/test-core/test-stuff.h +++ b/common/test-core/test-stuff.h @@ -133,6 +133,8 @@ void failure_args( #define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ ) #define success( title ) success_call( title, __FILE__, __LINE__ ); #define failure( title ) failure_call( title, __FILE__, __LINE__ ); +#define failuref( title, format, ... ) failure_args( title, __FILE__, __LINE__, format, ## __VA_ARGS__ ); + /** This one doesn't work because macros can't take a variable number of arguments. * well, apparently gcc can, but it's non-standard. From 35bee1382da6d4fb108c564384259fbd91ad8538 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Tue, 27 Jun 2023 19:08:13 +0100 Subject: [PATCH 2/2] Test loading and saving XML files with and without compression Add new test files that are written with the latest version of GnuCash. Test loading them, saving to compressed files, loading those compressed files and writing to an uncompressed file. At every stage check it matches the canonical version. --- libgnucash/backend/xml/test/CMakeLists.txt | 37 +- libgnucash/backend/xml/test/README | 2 +- .../xml/test/gtest-load-save-files.cpp | 318 ++++ .../xml/test/test-files/CMakeLists.txt | 4 +- .../test/test-files/load-save/CMakeLists.txt | 4 + .../xml/test/test-files/load-save/README | 6 + .../bug-746937-sx-split-order.gnucash | 406 +++++ .../test/test-files/load-save/sample1.gnucash | 1563 +++++++++++++++++ 8 files changed, 2330 insertions(+), 10 deletions(-) create mode 100644 libgnucash/backend/xml/test/gtest-load-save-files.cpp create mode 100644 libgnucash/backend/xml/test/test-files/load-save/CMakeLists.txt create mode 100644 libgnucash/backend/xml/test/test-files/load-save/README create mode 100644 libgnucash/backend/xml/test/test-files/load-save/bug-746937-sx-split-order.gnucash create mode 100644 libgnucash/backend/xml/test/test-files/load-save/sample1.gnucash diff --git a/libgnucash/backend/xml/test/CMakeLists.txt b/libgnucash/backend/xml/test/CMakeLists.txt index 125fdf1dba..84bc00b2ef 100644 --- a/libgnucash/backend/xml/test/CMakeLists.txt +++ b/libgnucash/backend/xml/test/CMakeLists.txt @@ -14,12 +14,17 @@ set(XML_TEST_INCLUDE_DIRS set(XML_TEST_LIBS gnc-engine gnc-test-engine test-core ${LIBXML2_LDFLAGS} -lz) +set(XML_GTEST_LIBS ${XML_TEST_LIBS} gtest) function(add_xml_test _TARGET _SOURCE_FILES) gnc_add_test(${_TARGET} "${_SOURCE_FILES}" XML_TEST_INCLUDE_DIRS XML_TEST_LIBS ${ARGN}) target_compile_options(${_TARGET} PRIVATE -DU_SHOW_CPLUSPLUS_API=0 -DG_LOG_DOMAIN=\"gnc.backend.xml\") endfunction() +function(add_xml_gtest _TARGET _SOURCE_FILES) + gnc_add_test(${_TARGET} "${_SOURCE_FILES}" XML_TEST_INCLUDE_DIRS XML_GTEST_LIBS ${ARGN}) + target_compile_options(${_TARGET} PRIVATE -DU_SHOW_CPLUSPLUS_API=0 -DG_LOG_DOMAIN=\"gnc.backend.xml\") +endfunction() ################################ @@ -55,13 +60,28 @@ set(test_backend_xml_module_SOURCES ${CMAKE_SOURCE_DIR}/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp ) -set_local_dist(test_backend_xml_DIST_local CMakeLists.txt grab-types.pl - README test-dom-converters1.cpp - test-dom-parser1.cpp test-file-stuff.cpp test-file-stuff.h test-kvp-frames.cpp - test-load-backend.cpp test-load-example-account.cpp test-load-xml2.cpp - test-save-in-lang.cpp test-string-converters.cpp test-xml2-is-file.cpp - test-xml-account.cpp test-real-data.sh test-xml-commodity.cpp - test-xml-pricedb.cpp test-xml-transaction.cpp) +set_local_dist(test_backend_xml_DIST_local + CMakeLists.txt + grab-types.pl + README + test-dom-converters1.cpp + test-dom-parser1.cpp + test-file-stuff.cpp + test-file-stuff.h + test-kvp-frames.cpp + test-load-backend.cpp + test-load-example-account.cpp + test-load-save-files.cpp + test-load-xml2.cpp + test-real-data.sh + test-save-in-lang.cpp + test-string-converters.cpp + test-xml2-is-file.cpp + test-xml-account.cpp + test-xml-commodity.cpp + test-xml-pricedb.cpp + test-xml-transaction.cpp +) set(test_backend_xml_DIST ${test_backend_xml_DIST_local} ${test_backend_xml_test_files_DIST} PARENT_SCOPE) add_xml_test(test-dom-converters1 "${test_backend_xml_base_SOURCES};test-dom-converters1.cpp") @@ -80,6 +100,9 @@ add_xml_test(test-load-example-account GNC_ACCOUNT_PATH=${CMAKE_SOURCE_DIR}/data/accounts/C ) target_compile_options(test-load-example-account PRIVATE -DU_SHOW_CPLUSPLUS_API=0) +add_xml_gtest(test-load-save-files gtest-load-save-files.cpp + GNC_TEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/test-files/load-save +) add_xml_test(test-string-converters "${test_backend_xml_base_SOURCES};test-string-converters.cpp") add_xml_test(test-xml-account "${test_backend_xml_module_SOURCES};test-xml-account.cpp;test-file-stuff.cpp") add_xml_test(test-xml-commodity "${test_backend_xml_module_SOURCES};test-xml-commodity.cpp;test-file-stuff.cpp") diff --git a/libgnucash/backend/xml/test/README b/libgnucash/backend/xml/test/README index 483b13183d..83fd282ba6 100644 --- a/libgnucash/backend/xml/test/README +++ b/libgnucash/backend/xml/test/README @@ -6,6 +6,7 @@ TESTS: test-dom-converters1.c: test each simple dom converter test-dom-parser1.c: unused now test-kvp-frames.c: test the kvp frame dom generators and parsers +test-load-save-files.c: test loading and saving compressed and uncompressed files test-load-xml2.c: test the larger xml loading test-save-in-lang.c: incomplete test to test saving in different LANGs test-string-converters.c: test some string converters @@ -15,4 +16,3 @@ test-xml-transaction.c: ditto Transaction's test-xml2-is-file.c: test the is_file function test-real-data.sh: run the test-xml-{account,commodity,transaction} programs on real data rather than random data - diff --git a/libgnucash/backend/xml/test/gtest-load-save-files.cpp b/libgnucash/backend/xml/test/gtest-load-save-files.cpp new file mode 100644 index 0000000000..d978d54f11 --- /dev/null +++ b/libgnucash/backend/xml/test/gtest-load-save-files.cpp @@ -0,0 +1,318 @@ +/********************************************************************\ + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * + * Boston, MA 02110-1301, USA gnu@gnu.org * + * * +\********************************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "../gnc-backend-xml.h" +#include "../io-gncxml-v2.h" + +#define GNC_LIB_NAME "gncmod-backend-xml" +#define GNC_LIB_REL_PATH "xml" + +static std::vector read_file (std::string filename) +{ + gchar *contents; + gsize length = 0; + + if (g_file_get_contents (filename.c_str (), &contents, &length, nullptr)) + { + std::vector data(length); + + memcpy (data.data (), contents, length); + g_free (contents); + return data; + } + else + { + return {}; + } +} + +static bool +compare_files (std::string filename1, std::string filename2) +{ + auto contents1 = read_file (filename1); + auto contents2 = read_file (filename2); + + if (contents1.size () > 0 && contents1.size () == contents2.size () + && !memcmp(contents1.data (), contents2.data (), contents1.size ())) { + return true; + } else { + ADD_FAILURE() << "compare_files: " << filename1 << " and " << filename2 << " are different"; + return false; + } +} + +static bool +decompress_file (std::string filename, const std::vector &in, std::vector &out) +{ + /* 037 0213 are the header id bytes for a gzipped file. */ + if (in.size () < 2 || in[0] != 037 || in[1] != 0213) + { + ADD_FAILURE() << "decompress_file: " << filename << " is not compressed"; + return false; + } + + z_stream stream{}; + stream.next_in = const_cast(in.data ()); + stream.avail_in = in.size (); + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; + stream.opaque = Z_NULL; + stream.next_out = out.data (); + stream.avail_out = out.size (); + + /* "add 16 to decode only the gzip format" */ + int ret = inflateInit2 (&stream, 16 + MAX_WBITS); + if (ret != Z_OK) + { + ADD_FAILURE() << "decompress_file: " << filename << " could not be uncompressed (inflateInit): " << ret; + return false; + } + + ret = inflate (&stream, Z_NO_FLUSH); + if (ret != Z_STREAM_END) + { + ADD_FAILURE() << "decompress_file: " << filename << " could not be uncompressed (inflate " + << in.size () << " into " << out.size() << "): " << ret << " " << stream.msg + << " (avail_in " << stream.avail_in << " avail_out " << stream.avail_out << ")"; + inflateEnd (&stream); + return false; + } + + ret = inflateEnd (&stream); + if (ret != Z_OK) + { + ADD_FAILURE() << "decompress_file: " << filename << " could not be uncompressed (inflateEnd): " << ret; + return false; + } + + if (stream.avail_in) + { + ADD_FAILURE() << "decompress_file: " << filename << " has unused compressed data: " << stream.avail_in; + return false; + } + + out.resize (stream.avail_out); + + return true; +} + +static bool +compare_compressed_files (std::string uncompressed_filename1, std::string compressed_filename2) +{ + auto uncompressed_contents1 = read_file (uncompressed_filename1); + auto compressed_contents2 = read_file (compressed_filename2); + /* Allow some space to grow beyond the expected size */ + std::vector uncompressed_contents2(uncompressed_contents1.size () * 2); + + if (!decompress_file (compressed_filename2, compressed_contents2, uncompressed_contents2)) + return false; + + if (uncompressed_contents1.size () > 0 + && uncompressed_contents1.size () != uncompressed_contents2.size ()) + { + ADD_FAILURE() << "compare_compressed_files: " << uncompressed_filename1 + << " and " << compressed_filename2 << " are different sizes or empty (" + << uncompressed_contents1.size () << " and " + << uncompressed_contents2.size () << ")"; + return false; + } + + if (!memcmp(uncompressed_contents1.data (), uncompressed_contents2.data (), uncompressed_contents1.size ())) { + return true; + } else { + ADD_FAILURE() << "compare_compressed_files: " << uncompressed_filename1 + << " and " << compressed_filename2 << " are different"; + return false; + } +} + +/* The original file is used for comparisons. The file will be different when + * there are future changes in the GnuCash output and needs to be updated if + * that happens. + * + * Using the same file each time also checks that nothing in the file will swap + * between two stable states (bug 746937). + */ +class LoadSaveFiles : public testing::TestWithParam +{ +public: + static void SetUpTestSuite () + { + g_setenv ("GNC_UNINSTALLED", "1", TRUE); + qof_init (); + cashobjects_register (); + ASSERT_TRUE(qof_load_backend_library (GNC_LIB_REL_PATH, GNC_LIB_NAME)) << "loading gnc-backend-xml GModule failed"; + xaccLogDisable (); + } + + static void TearDownTestSuite () + { + qof_close (); + } +}; + +#define QOF_SESSION_CHECKED_CALL(_function, _session, ...) \ + do { \ + _function (_session.get (), ## __VA_ARGS__); \ + ASSERT_EQ (qof_session_get_error (_session.get ()), 0) << #_function \ + << " (" << #_session << ".get (), " << #__VA_ARGS__ << "): " << qof_session_get_error (_session.get ()) \ + << " \"" << qof_session_get_error_message (_session.get ()) << "\""; \ + } while (0) + +TEST_P(LoadSaveFiles, test_file) +{ + auto filename = GetParam(); + /* Verify that we can write a compressed version of the original file that + * has the original content when uncompressed. + */ + auto new_compressed_file = filename + "-test-compressed~"; + /* Verify that we can read a compressed file and write an uncompressed file + * that has the original content. + */ + auto new_uncompressed_file = filename + "-test-uncompressed~"; + const char *logdomain = "backend.xml"; + GLogLevelFlags loglevel = static_cast + (G_LOG_LEVEL_WARNING); + TestErrorStruct check = { loglevel, const_cast (logdomain), nullptr }; + g_log_set_handler (logdomain, loglevel, + (GLogFunc)test_checked_handler, &check); + + { + auto load_uncompressed_session = std::shared_ptr{qof_session_new (qof_book_new ()), qof_session_destroy}; + + QOF_SESSION_CHECKED_CALL(qof_session_begin, load_uncompressed_session, filename.c_str (), SESSION_READ_ONLY); + QOF_SESSION_CHECKED_CALL(qof_session_load, load_uncompressed_session, nullptr); + + auto save_compressed_session = std::shared_ptr{qof_session_new (nullptr), qof_session_destroy}; + + g_unlink (new_compressed_file.c_str ()); + g_unlink ((new_compressed_file + ".LCK").c_str ()); + QOF_SESSION_CHECKED_CALL(qof_session_begin, save_compressed_session, new_compressed_file.c_str (), SESSION_NEW_OVERWRITE); + + qof_event_suspend (); + qof_session_swap_data (load_uncompressed_session.get (), save_compressed_session.get ()); + qof_book_mark_session_dirty (qof_session_get_book (save_compressed_session.get ())); + qof_event_resume (); + + qof_session_end (load_uncompressed_session.get ()); + + gnc_prefs_set_file_save_compressed (TRUE); + QOF_SESSION_CHECKED_CALL(qof_session_save, save_compressed_session, nullptr); + + qof_session_end (save_compressed_session.get ()); + } + + if (!compare_compressed_files (filename, new_compressed_file)) + return; + + { + auto load_compressed_session = std::shared_ptr{qof_session_new (qof_book_new ()), qof_session_destroy}; + + QOF_SESSION_CHECKED_CALL(qof_session_begin, load_compressed_session, new_compressed_file.c_str (), SESSION_READ_ONLY); + QOF_SESSION_CHECKED_CALL(qof_session_load, load_compressed_session, nullptr); + + auto save_uncompressed_session = std::shared_ptr{qof_session_new (nullptr), qof_session_destroy}; + + g_unlink (new_uncompressed_file.c_str ()); + g_unlink ((new_uncompressed_file + ".LCK").c_str ()); + QOF_SESSION_CHECKED_CALL(qof_session_begin, save_uncompressed_session, new_uncompressed_file.c_str (), SESSION_NEW_OVERWRITE); + + qof_event_suspend (); + qof_session_swap_data (load_compressed_session.get (), save_uncompressed_session.get ()); + qof_book_mark_session_dirty (qof_session_get_book (save_uncompressed_session.get ())); + qof_event_resume (); + + qof_session_end (load_compressed_session.get ()); + + gnc_prefs_set_file_save_compressed (FALSE); + QOF_SESSION_CHECKED_CALL(qof_session_save, save_uncompressed_session, nullptr); + + qof_session_end (save_uncompressed_session.get ()); + } + + if (!compare_files (filename, new_uncompressed_file)) + return; +} + +std::vector ListTestCases (); + +INSTANTIATE_TEST_SUITE_P( + LoadSaveFilesDir, + LoadSaveFiles, + testing::ValuesIn (ListTestCases ())); + +std::vector ListTestCases () +{ + std::vector files; + const char *location = g_getenv ("GNC_TEST_FILES"); + + if (!location) + location = "test-files/load-save"; + + std::shared_ptr dir{g_dir_open (location, 0, nullptr), g_dir_close}; + if (dir) + { + const gchar *entry; + + while ((entry = g_dir_read_name (dir.get ())) != nullptr) + { + if (g_str_has_suffix (entry, ".gnucash")) + { + std::shared_ptr to_open{g_build_filename (location, entry, (gchar*)nullptr), g_free}; + + if (!g_file_test (to_open.get (), G_FILE_TEST_IS_DIR)) + files.push_back (to_open.get()); + } + } + } + else + { + ADD_FAILURE() << "unable to open directory " << location; + } + + EXPECT_FALSE(files.empty()) << "no files found in " << location; + return files; +} diff --git a/libgnucash/backend/xml/test/test-files/CMakeLists.txt b/libgnucash/backend/xml/test/test-files/CMakeLists.txt index 6f517814ea..126fc36391 100644 --- a/libgnucash/backend/xml/test/test-files/CMakeLists.txt +++ b/libgnucash/backend/xml/test/test-files/CMakeLists.txt @@ -1,6 +1,6 @@ +add_subdirectory(load-save) add_subdirectory(xml2) set_local_dist(test_backend_xml_test_files_DIST_local CMakeLists.txt ) -set(test_backend_xml_test_files_DIST ${test_backend_xml_test_files_DIST_local} ${xml2_DIST} PARENT_SCOPE) - +set(test_backend_xml_test_files_DIST ${test_backend_xml_test_files_DIST_local} ${load_save_DIST} ${xml2_DIST} PARENT_SCOPE) diff --git a/libgnucash/backend/xml/test/test-files/load-save/CMakeLists.txt b/libgnucash/backend/xml/test/test-files/load-save/CMakeLists.txt new file mode 100644 index 0000000000..aebb105997 --- /dev/null +++ b/libgnucash/backend/xml/test/test-files/load-save/CMakeLists.txt @@ -0,0 +1,4 @@ +set_dist_list(load_save_DIST + bug-746937-sx-split-order.gnucash + sample1.gnucash +) diff --git a/libgnucash/backend/xml/test/test-files/load-save/README b/libgnucash/backend/xml/test/test-files/load-save/README new file mode 100644 index 0000000000..cbf193f3dc --- /dev/null +++ b/libgnucash/backend/xml/test/test-files/load-save/README @@ -0,0 +1,6 @@ +These files are used for testing loading and saving + +If the "load-save-files" test fails because the written XML file is now +different, zcat *.gnucash-compressed~ to *.gnucash, check that the changes +are appropriate, expected and have the right backward/forward compatibility +then commit the new versions of the files. diff --git a/libgnucash/backend/xml/test/test-files/load-save/bug-746937-sx-split-order.gnucash b/libgnucash/backend/xml/test/test-files/load-save/bug-746937-sx-split-order.gnucash new file mode 100644 index 0000000000..f48f318462 --- /dev/null +++ b/libgnucash/backend/xml/test/test-files/load-save/bug-746937-sx-split-order.gnucash @@ -0,0 +1,406 @@ + + +1 + +78552b4ebbba9bf429f6a1f4b861b538 +1 +9 +1 + + CURRENCY + GBP + + currency + + + + template + template + template + template + 1 + + + Root Account + 22067e5b3cf257e20070e0d2307ac0b0 + ROOT + + + Assets + 1244bef69b14889a06271df59645c35d + ASSET + + CURRENCY + GBP + + 100 + Assets + + + placeholder + true + + + 22067e5b3cf257e20070e0d2307ac0b0 + + + Current Assets + be6deddf8a970ff14cb8be91a958a3eb + ASSET + + CURRENCY + GBP + + 100 + Current Assets + + + placeholder + true + + + 1244bef69b14889a06271df59645c35d + + + Bank + 9b0050507226d570c754f688caf3e577 + BANK + + CURRENCY + GBP + + 100 + + + placeholder + true + + + be6deddf8a970ff14cb8be91a958a3eb + + + Current Account + f0d5a52f1fd957b8a414aedf3f55c626 + BANK + + CURRENCY + GBP + + 100 + 9b0050507226d570c754f688caf3e577 + + + Liabilities + 1f5a3d5c6157c5e78d9961bbd3afc85f + LIABILITY + + CURRENCY + GBP + + 100 + Liabilities + + + placeholder + true + + + 22067e5b3cf257e20070e0d2307ac0b0 + + + Company + 59b2fcdab565c906362f5a24f4a909f7 + LIABILITY + + CURRENCY + GBP + + 100 + 1f5a3d5c6157c5e78d9961bbd3afc85f + + + Account 1 + b5c34f61b594d4e6c8ce18591a9813ad + LIABILITY + + CURRENCY + GBP + + 100 + 59b2fcdab565c906362f5a24f4a909f7 + + + Account 2 + bce28fe18ad558edb87c8282369ed373 + LIABILITY + + CURRENCY + GBP + + 100 + + + color + Not Set + + + 59b2fcdab565c906362f5a24f4a909f7 + + + + Template Root + 4586cdb4267a59437526549e14b0e74b + ROOT + + template + template + + 1 + + + + 52f96837087e9670c933f9421b0ac626 + 22f2905cbcfa0b910c0dbc348cfc1161 + BANK + + template + template + + 1 + + 4586cdb4267a59437526549e14b0e74b + + + 68bf5e7740392eb15a079ee99f18a357 + + CURRENCY + GBP + + + 2010-08-01 08:40:17 +0000 + + + 2010-08-01 08:40:17 +0000 + + Description 2 + + + 676a518eb1cf05ca552434533288a5cd + n + 0/100 + 0/1 + 22f2905cbcfa0b910c0dbc348cfc1161 + + + sched-xaction + + + account + bce28fe18ad558edb87c8282369ed373 + + + credit-formula + + + + credit-numeric + 0/1 + + + debit-formula + 456 + + + debit-numeric + 456/1 + + + + + + + 1b779b05012759adbac315f1f50af621 + n + 0/100 + 0/1 + 22f2905cbcfa0b910c0dbc348cfc1161 + + + sched-xaction + + + account + f0d5a52f1fd957b8a414aedf3f55c626 + + + credit-formula + 456 + + + credit-numeric + 456/1 + + + debit-formula + + + + debit-numeric + 0/1 + + + + + + + + + 2fbcf6cc8224673bc93501399d4ca7be + + CURRENCY + GBP + + + 2010-09-11 23:00:00 +0000 + + + 2010-09-12 08:51:53 +0000 + + Description 1 + + + notes + + + + + + 378dd92bd1819a52e491b6d8c123f662 + n + 0/100 + 0/1 + 22f2905cbcfa0b910c0dbc348cfc1161 + + + sched-xaction + + + account + b5c34f61b594d4e6c8ce18591a9813ad + + + credit-formula + + + + credit-numeric + 0/1 + + + debit-formula + 123 + + + debit-numeric + 123/1 + + + + + + + 75e005248499f7dfb46a80c9778e2e13 + n + 0/100 + 0/1 + 22f2905cbcfa0b910c0dbc348cfc1161 + + + sched-xaction + + + account + f0d5a52f1fd957b8a414aedf3f55c626 + + + credit-formula + 123 + + + credit-numeric + 123/1 + + + debit-formula + + + + debit-numeric + 0/1 + + + + + + + + + + 52f96837087e9670c933f9421b0ac626 + Scheduled Transaction + n + y + n + 90 + 0 + 5 + + 2010-10-05 + + + 2011-11-07 + + 22f2905cbcfa0b910c0dbc348cfc1161 + + + 1 + month + + 2010-10-05 + + forward + + + + + + diff --git a/libgnucash/backend/xml/test/test-files/load-save/sample1.gnucash b/libgnucash/backend/xml/test/test-files/load-save/sample1.gnucash new file mode 100644 index 0000000000..99228ce533 --- /dev/null +++ b/libgnucash/backend/xml/test/test-files/load-save/sample1.gnucash @@ -0,0 +1,1563 @@ + + +1 + +ec608cfecd73462ebeba062ec5f9c4b4 + + + counters + + + gncVendor + 1 + + + + + options + + + Budgeting + + + + + +1 +105 +2 +1 +1 +1 + + CURRENCY + USD + + currency + + + + template + template + template + template + 1 + + + Root Account + 3e8c57e826724328a2438b654dadb594 + ROOT + + CURRENCY + USD + + 100 + + + Assets + 63448b8608404281b9b89de25a2447a7 + ASSET + + CURRENCY + USD + + 100 + Assets + + + placeholder + true + + + 3e8c57e826724328a2438b654dadb594 + + + Current Assets + e45d737f375745b7bf2ad678d8d29226 + ASSET + + CURRENCY + USD + + 100 + Current Assets + + + placeholder + true + + + 63448b8608404281b9b89de25a2447a7 + + + Checking Account + 547d8ff75f4347e3b3607c40b40a3fef + BANK + + CURRENCY + USD + + 100 + Checking Account + e45d737f375745b7bf2ad678d8d29226 + + + Savings Account + dd3f5b6a496148ba945ea6d6e1bcf3c4 + BANK + + CURRENCY + USD + + 100 + Savings Account + e45d737f375745b7bf2ad678d8d29226 + + + Cash in Wallet + 2e10b191529f4e41a9b269cea72932c2 + CASH + + CURRENCY + USD + + 100 + Cash in Wallet + e45d737f375745b7bf2ad678d8d29226 + + + Petty Cash + 4260ecb71d9443fdb983046e1f1b3221 + CASH + + CURRENCY + USD + + 100 + Petty Cash + e45d737f375745b7bf2ad678d8d29226 + + + Accounts Receivable + f74cd14ec90842ab9bb8c196b6942089 + RECEIVABLE + + CURRENCY + USD + + 100 + Accounts Receivable + 63448b8608404281b9b89de25a2447a7 + + + Liabilities + fc61ce59f30740398f79251db8145e79 + LIABILITY + + CURRENCY + USD + + 100 + Liabilities + + + placeholder + true + + + 3e8c57e826724328a2438b654dadb594 + + + Credit Card + 142e19ca2f6346229817f40fa119bfa8 + CREDIT + + CURRENCY + USD + + 100 + Credit Card + fc61ce59f30740398f79251db8145e79 + + + Accounts Payable + 81438d8393264c71bb965baa171c5ffe + PAYABLE + + CURRENCY + USD + + 100 + Accounts Payable + fc61ce59f30740398f79251db8145e79 + + + c35d998d200a4fed97c0a4b61c285d49 + + + gncInvoice + + + invoice-guid + 8786e1cf6e534cde9c227373b505ef62 + + + + + title + Bill yoyo1 + + + + + + + Income + 4a16f6e753fb4562845df25d2dd3fc4e + INCOME + + CURRENCY + USD + + 100 + Income + + + placeholder + true + + + 3e8c57e826724328a2438b654dadb594 + + + Bonus + 3e886a032b2d4a28a3ae85846ad161aa + INCOME + + CURRENCY + USD + + 100 + Bonus + 4a16f6e753fb4562845df25d2dd3fc4e + + + Gifts Received + 3dc73385f0e8436ab28bee085baf9e5c + INCOME + + CURRENCY + USD + + 100 + Gifts Received + 4a16f6e753fb4562845df25d2dd3fc4e + + + Interest Income + ec4b2003ed464343a2fc04d6d5b2e9c2 + INCOME + + CURRENCY + USD + + 100 + Interest Income + 4a16f6e753fb4562845df25d2dd3fc4e + + + Checking Interest + 0a6afd4e8dca4d809e58e211aa38a2a8 + INCOME + + CURRENCY + USD + + 100 + Checking Interest + ec4b2003ed464343a2fc04d6d5b2e9c2 + + + Other Interest + 8e17053df6cd4437abbd60390ddc4d08 + INCOME + + CURRENCY + USD + + 100 + Other Interest + ec4b2003ed464343a2fc04d6d5b2e9c2 + + + Savings Interest + c02c9a7cdb184a15ad13b3a25b6289c8 + INCOME + + CURRENCY + USD + + 100 + Savings Interest + ec4b2003ed464343a2fc04d6d5b2e9c2 + + + Other Income + 28fea126891047f68e157ba82c62f782 + INCOME + + CURRENCY + USD + + 100 + Other Income + 4a16f6e753fb4562845df25d2dd3fc4e + + + Salary + 926aae38873c463e833aeb66cc4d69e5 + INCOME + + CURRENCY + USD + + 100 + Salary + 4a16f6e753fb4562845df25d2dd3fc4e + + + Reimbursed Expenses + 5076a53c0e694a359011b7cb95d07888 + INCOME + + CURRENCY + USD + + 100 + Reimbursed Expenses + 4a16f6e753fb4562845df25d2dd3fc4e + + + Sales + 0752201142ef4d7eafd4dd38f7a73a5a + INCOME + + CURRENCY + USD + + 100 + Sales + 4a16f6e753fb4562845df25d2dd3fc4e + + + Expenses + f7272eab95d34caf92889017e022a9ae + EXPENSE + + CURRENCY + USD + + 100 + Expenses + + + placeholder + true + + + 3e8c57e826724328a2438b654dadb594 + + + Adjustment + f982b3f6f8f24934a29d1de5960065db + EXPENSE + + CURRENCY + USD + + 100 + Adjustment + f7272eab95d34caf92889017e022a9ae + + + Auto + 15ca372927bd4ce59ff67ab7395fe46f + EXPENSE + + CURRENCY + USD + + 100 + Auto + f7272eab95d34caf92889017e022a9ae + + + Fees + 0f1599f7ddd64a05bc2a8e0634125d4d + EXPENSE + + CURRENCY + USD + + 100 + Fees + 15ca372927bd4ce59ff67ab7395fe46f + + + Gas + 230475084c2644fe83a8c3e08236c3be + EXPENSE + + CURRENCY + USD + + 100 + Gas + 15ca372927bd4ce59ff67ab7395fe46f + + + Parking + d55298bde0fc4179984e427ede06e9d8 + EXPENSE + + CURRENCY + USD + + 100 + Parking + 15ca372927bd4ce59ff67ab7395fe46f + + + Repair and Maintenance + 137fc2f6c5d5479e88d463b11c15db96 + EXPENSE + + CURRENCY + USD + + 100 + Repair and Maintenance + 15ca372927bd4ce59ff67ab7395fe46f + + + Bank Service Charge + a6dfc99152504f2985402f0c297e39cf + EXPENSE + + CURRENCY + USD + + 100 + Bank Service Charge + f7272eab95d34caf92889017e022a9ae + + + Books + 244d9d7ae3be453998b5ed831b91bd13 + EXPENSE + + CURRENCY + USD + + 100 + Books + f7272eab95d34caf92889017e022a9ae + + + Cable + 7534f33ee5c9415db75f7bec66dfe045 + EXPENSE + + CURRENCY + USD + + 100 + Cable + f7272eab95d34caf92889017e022a9ae + + + Charity + 6365420696404a169c5bc982395ede40 + EXPENSE + + CURRENCY + USD + + 100 + Charity + f7272eab95d34caf92889017e022a9ae + + + Clothes + 3d0489205bfe433da15d29a4ca062aae + EXPENSE + + CURRENCY + USD + + 100 + Clothes + f7272eab95d34caf92889017e022a9ae + + + Computer + 1f9893f5d2254f73a45b1687d5c6c562 + EXPENSE + + CURRENCY + USD + + 100 + Computer + f7272eab95d34caf92889017e022a9ae + + + Dining + 838b9ddd7cdb4594ab1680f5a3c0677d + EXPENSE + + CURRENCY + USD + + 100 + Dining + f7272eab95d34caf92889017e022a9ae + + + Education + 53ba4bf5217f41eda3da8c7f9fc0ab90 + EXPENSE + + CURRENCY + USD + + 100 + Education + f7272eab95d34caf92889017e022a9ae + + + Entertainment + 9cde1ef6f1c14793a4402c32a3b6e259 + EXPENSE + + CURRENCY + USD + + 100 + Entertainment + f7272eab95d34caf92889017e022a9ae + + + Music/Movies + 5f4618c4e0524e3ebfe3f97a942e2963 + EXPENSE + + CURRENCY + USD + + 100 + Music/Movies + 9cde1ef6f1c14793a4402c32a3b6e259 + + + Recreation + 4788e8cdb0f449f8a0ff9c52dc60b932 + EXPENSE + + CURRENCY + USD + + 100 + Recreation + 9cde1ef6f1c14793a4402c32a3b6e259 + + + Travel + 36b7f25b7a4741c49d64ccc0cda5e4d2 + EXPENSE + + CURRENCY + USD + + 100 + Travel + 9cde1ef6f1c14793a4402c32a3b6e259 + + + Gifts + 72e9642cf7614baba5cfd0e3e3be6e0a + EXPENSE + + CURRENCY + USD + + 100 + Gifts + f7272eab95d34caf92889017e022a9ae + + + Groceries + d38bfa7d4e7e4b8b9829d965c6d9d39d + EXPENSE + + CURRENCY + USD + + 100 + Groceries + f7272eab95d34caf92889017e022a9ae + + + Hobbies + b69732077c624daeb8340d30e977593f + EXPENSE + + CURRENCY + USD + + 100 + Hobbies + f7272eab95d34caf92889017e022a9ae + + + Insurance + 3f6a0bf52ffa4c4989475bff495dd80e + EXPENSE + + CURRENCY + USD + + 100 + Insurance + f7272eab95d34caf92889017e022a9ae + + + Auto Insurance + 1710fa62f4d54952bfd5a1b5c027d969 + EXPENSE + + CURRENCY + USD + + 100 + Auto Insurance + 3f6a0bf52ffa4c4989475bff495dd80e + + + Health Insurance + 16c48d49e2244622980bfed9b50c64ac + EXPENSE + + CURRENCY + USD + + 100 + Health Insurance + 3f6a0bf52ffa4c4989475bff495dd80e + + + Life Insurance + 23bb2250a5904083ad670831fe926038 + EXPENSE + + CURRENCY + USD + + 100 + Life Insurance + 3f6a0bf52ffa4c4989475bff495dd80e + + + Disability Insurance + 49493494497d423aa2e9be344481632d + EXPENSE + + CURRENCY + USD + + 100 + Disability Insurance + 3f6a0bf52ffa4c4989475bff495dd80e + + + Liability Insurance + 6f7e3b4827b94754bd5a2f2c78353b98 + EXPENSE + + CURRENCY + USD + + 100 + Liability Insurance + 3f6a0bf52ffa4c4989475bff495dd80e + + + Workers Comp + dd8c05a8e9954e0786e56d6889030c7a + EXPENSE + + CURRENCY + USD + + 100 + Workers Comp + 3f6a0bf52ffa4c4989475bff495dd80e + + + Laundry/Dry Cleaning + a4c968d4663447cbb63db8eea7c828a7 + EXPENSE + + CURRENCY + USD + + 100 + Laundry/Dry Cleaning + f7272eab95d34caf92889017e022a9ae + + + Medical Expenses + 01d0068463464eed835b5c59864bba96 + EXPENSE + + CURRENCY + USD + + 100 + Medical Expenses + f7272eab95d34caf92889017e022a9ae + + + Miscellaneous + eb59c82aef304e24abd1b93912df45d3 + EXPENSE + + CURRENCY + USD + + 100 + Miscellaneous + f7272eab95d34caf92889017e022a9ae + + + Online Services + 3976761209174a52bf873df9e4fccd59 + EXPENSE + + CURRENCY + USD + + 100 + Online Services + f7272eab95d34caf92889017e022a9ae + + + Phone + 7b3995f1953b4881b99e4ee2baa21011 + EXPENSE + + CURRENCY + USD + + 100 + Phone + f7272eab95d34caf92889017e022a9ae + + + Public Transportation + 487483ba68a34753b6896801a221722d + EXPENSE + + CURRENCY + USD + + 100 + Public Transportation + f7272eab95d34caf92889017e022a9ae + + + Subscriptions + a12b6d326e08474a8116817c4494cb42 + EXPENSE + + CURRENCY + USD + + 100 + Subscriptions + f7272eab95d34caf92889017e022a9ae + + + Supplies + b0db68d7aad04acba8d266a6ad2bc116 + EXPENSE + + CURRENCY + USD + + 100 + Supplies + f7272eab95d34caf92889017e022a9ae + + + Taxes + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + EXPENSE + + CURRENCY + USD + + 100 + Taxes + f7272eab95d34caf92889017e022a9ae + + + Federal + de87b359e7ce4690898f1cb861430a78 + EXPENSE + + CURRENCY + USD + + 100 + Federal + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + Medicare + 342a68753f7e4bea9c33a818a6c44766 + EXPENSE + + CURRENCY + USD + + 100 + Medicare + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + Other Tax + 80f588c4f31c43579bb90f4d5e609e0c + EXPENSE + + CURRENCY + USD + + 100 + Other Tax + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + Social Security + 28a46ebba32048e9839e4efb549d3ee2 + EXPENSE + + CURRENCY + USD + + 100 + Social Security + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + State/Province + 6a5f8523ab354aaaa3630b51f6028687 + EXPENSE + + CURRENCY + USD + + 100 + State/Province + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + Emp-FICA + 0d21bc3e6a264364ab8c1499de2680e4 + EXPENSE + + CURRENCY + USD + + 100 + Employer SS/Med + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + FICA + f1d5c3063f2b46efbbacd6cdf332a1a5 + EXPENSE + + CURRENCY + USD + + 100 + SS/Med + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + FUTA + 2845608bd13941fc9cb5be777bd15f04 + EXPENSE + + CURRENCY + USD + + 100 + FUTA + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + Local + 2efbcefdc543469fb3281b31a2893ad7 + EXPENSE + + CURRENCY + USD + + 100 + Local + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + Property + 950a65eabaaa49c78364dc924d9eb384 + EXPENSE + + CURRENCY + USD + + 100 + Property + 2c0a7aabdcaa4a5e9254ceb87d3c09d2 + + + Utilities + 7bbabca9279f490bbaaa3da21b59a7cf + EXPENSE + + CURRENCY + USD + + 100 + Utilities + f7272eab95d34caf92889017e022a9ae + + + Electric + 54dc897a4503435a9c2391f67845b2c4 + EXPENSE + + CURRENCY + USD + + 100 + Electric + 7bbabca9279f490bbaaa3da21b59a7cf + + + Garbage collection + c0acee2af64d4245a50cf53f221d0639 + EXPENSE + + CURRENCY + USD + + 100 + Garbage collection + 7bbabca9279f490bbaaa3da21b59a7cf + + + Gas + 51d66ffe6da848898769e5342cfd9d57 + EXPENSE + + CURRENCY + USD + + 100 + Gas + 7bbabca9279f490bbaaa3da21b59a7cf + + + Water + 63663216ed3e4a469bfb72e58adfa7b4 + EXPENSE + + CURRENCY + USD + + 100 + Water + 7bbabca9279f490bbaaa3da21b59a7cf + + + Cable + 3e06c49869fe407799785a574eefae1e + EXPENSE + + CURRENCY + USD + + 100 + Cable + 7bbabca9279f490bbaaa3da21b59a7cf + + + Cell Phone + 69bd12ebf9e4406b8779a014ba17fa54 + EXPENSE + + CURRENCY + USD + + 100 + Cell Phone + 7bbabca9279f490bbaaa3da21b59a7cf + + + Internet + 0f3cc274202542b8b2e86c22b3b5c1d9 + EXPENSE + + CURRENCY + USD + + 100 + Internet + 7bbabca9279f490bbaaa3da21b59a7cf + + + Phone + 3383b9e88fa44dd7b7549267aa4a4713 + EXPENSE + + CURRENCY + USD + + 100 + Phone + 7bbabca9279f490bbaaa3da21b59a7cf + + + Cash Discounts + e3ffbde0fcb341509ee941e46d0c811e + EXPENSE + + CURRENCY + USD + + 100 + Cash Discounts + f7272eab95d34caf92889017e022a9ae + + + Depreciation + 191afc571b1b46f5a2bcf4a3ad0afef9 + EXPENSE + + CURRENCY + USD + + 100 + Depreciation + f7272eab95d34caf92889017e022a9ae + + + Dues and Subscriptions + f2fec74304bd4363a40e2e11ede60218 + EXPENSE + + CURRENCY + USD + + 100 + Dues and Subscriptions + f7272eab95d34caf92889017e022a9ae + + + Equipment Rental + 94ee8084d90a4c6285c412a41d74a8fa + EXPENSE + + CURRENCY + USD + + 100 + Equipment Rental + f7272eab95d34caf92889017e022a9ae + + + Licenses and Permits + 6cc6e7ed7e9e454bb70773b0cf1aa5bb + EXPENSE + + CURRENCY + USD + + 100 + Licenses and Permits + f7272eab95d34caf92889017e022a9ae + + + Office Supplies + d667e8254fca42a5a0d8445b157f1ead + EXPENSE + + CURRENCY + USD + + 100 + Office Supplies + f7272eab95d34caf92889017e022a9ae + + + Outside Services + d9a9a262b20840958bddf122acaefdb0 + EXPENSE + + CURRENCY + USD + + 100 + Outside Services + f7272eab95d34caf92889017e022a9ae + + + Payroll Expenses + 70da238d20ec4dcb979ceb77d1408b2c + EXPENSE + + CURRENCY + USD + + 100 + Payroll Expenses + f7272eab95d34caf92889017e022a9ae + + + Postage and Delivery + 3b83fcdc8b0b461b9303c8ba444c0a40 + EXPENSE + + CURRENCY + USD + + 100 + Postage and Delivery + f7272eab95d34caf92889017e022a9ae + + + Printing and Reproduction + fa44c0628385429181483c6877467058 + EXPENSE + + CURRENCY + USD + + 100 + Printing and Reproduction + f7272eab95d34caf92889017e022a9ae + + + Professional Fees + d45a07d1ca8e4811bae8855a7fc32bdb + EXPENSE + + CURRENCY + USD + + 100 + Professional Fees + f7272eab95d34caf92889017e022a9ae + + + Accounting + 1791f2bcc03b40d4a10cb4e208f25b0b + EXPENSE + + CURRENCY + USD + + 100 + Accounting + d45a07d1ca8e4811bae8855a7fc32bdb + + + Legal Fees + 241042e126a9479faa6de28e2da1cb72 + EXPENSE + + CURRENCY + USD + + 100 + Legal Fees + d45a07d1ca8e4811bae8855a7fc32bdb + + + Rent + 5fd6d83125f04a598163ccf1981a3390 + EXPENSE + + CURRENCY + USD + + 100 + Rent + f7272eab95d34caf92889017e022a9ae + + + Repairs + b26eca64c5324a0dbf21177ae9892fb9 + EXPENSE + + CURRENCY + USD + + 100 + Repairs + f7272eab95d34caf92889017e022a9ae + + + Building Repairs + 88af782bb5b04556a02c8231e3171bf8 + EXPENSE + + CURRENCY + USD + + 100 + Building Repairs + b26eca64c5324a0dbf21177ae9892fb9 + + + Computer Repairs + eed8f49d3260484c876fdd355be3d632 + EXPENSE + + CURRENCY + USD + + 100 + Computer Repairs + b26eca64c5324a0dbf21177ae9892fb9 + + + Equipment Repairs + aefdf3812a3f4f8a86ea008dfd097b29 + EXPENSE + + CURRENCY + USD + + 100 + Equipment Repairs + b26eca64c5324a0dbf21177ae9892fb9 + + + Janitorial Expenses + 31814364403d409489c4f50d21832ae9 + EXPENSE + + CURRENCY + USD + + 100 + Janitorial Expenses + b26eca64c5324a0dbf21177ae9892fb9 + + + Travel and Entertainment + df08e533003b440d9813a4937414f20d + EXPENSE + + CURRENCY + USD + + 100 + Travel and Entertainment + f7272eab95d34caf92889017e022a9ae + + + Entertainment + 5cb45cedd52e474cbf038b2e5fa0c136 + EXPENSE + + CURRENCY + USD + + 100 + Entertainment + df08e533003b440d9813a4937414f20d + + + Meals + 1520050ae83845daaf499584d927eea4 + EXPENSE + + CURRENCY + USD + + 100 + Meals + df08e533003b440d9813a4937414f20d + + + Travel + b53efe029d144e429b580c9fb11214cd + EXPENSE + + CURRENCY + USD + + 100 + Travel + df08e533003b440d9813a4937414f20d + + + Equity + 9570d426dee34682a9b2304ce3c38c6f + EQUITY + + CURRENCY + USD + + 100 + Equity + + + placeholder + true + + + 3e8c57e826724328a2438b654dadb594 + + + Opening Balances + b9ed26eaf02b4656b378bd60d809bcb4 + EQUITY + + CURRENCY + USD + + 100 + Opening Balances + 9570d426dee34682a9b2304ce3c38c6f + + + Retained Earnings + f62b8783b93f435498ab249ec8e523b1 + EQUITY + + CURRENCY + USD + + 100 + Retained Earnings + 9570d426dee34682a9b2304ce3c38c6f + + + f18fa0198b104215b1a7365d1eaaf1ed + + CURRENCY + USD + + + 2018-02-23 10:59:00 +0000 + + + 2018-02-23 20:33:58 +0000 + + Opening Balance + + + date-posted + + 2018-02-23 + + + + + + bf69b191406448e3b52a6956d0df5b98 + n + 1000000/100 + 1000000/100 + 547d8ff75f4347e3b3607c40b40a3fef + + + d6493e7650ac4c50b9b2496b29c72c11 + n + -1000000/100 + -1000000/100 + b9ed26eaf02b4656b378bd60d809bcb4 + + + + + c300ddab09df4e9aa0af929ffc38f550 + + CURRENCY + USD + + yoyo1 + + 2018-02-23 10:59:00 +0000 + + + 2018-02-23 20:39:41 +0000 + + Yoyodyne, Inc. + + + gncInvoice + + + invoice-guid + 8786e1cf6e534cde9c227373b505ef62 + + + + + trans-date-due + + 2018-02-23 08:00:00 +0000 + + + + trans-read-only + Generated from an invoice. Try unposting the invoice. + + + trans-txn-type + I + + + + + 641fcd0ace1249228212e4ea68225c1c + Fuzzy Dice + Bill + n + 58500/100 + 58500/100 + d667e8254fca42a5a0d8445b157f1ead + + + a1c11ef10e6343d3949dcc38a9e68f11 + Fuzzy Dice + Bill + n + -58500/100 + -58500/100 + 81438d8393264c71bb965baa171c5ffe + c35d998d200a4fed97c0a4b61c285d49 + + + + + b3ee32323fe145828ccde43f36dd4225 + + 2010-12-07 08:00:00 +0000 + + + 2010-12-08 01:10:43 +0000 + + Fuzzy Dice + Material + 300000000/1000000 + d667e8254fca42a5a0d8445b157f1ead + 1950000/1000000 + 8786e1cf6e534cde9c227373b505ef62 + 0 + 0 + 0 + CASH + + + 8786e1cf6e534cde9c227373b505ef62 + yoyo1 + + gncVendor + c48cb82168c44c179316d8befe6634e2 + + + 2010-12-07 08:00:00 +0000 + + + 2010-12-07 08:00:00 +0000 + + Zax4379 + 1 + c300ddab09df4e9aa0af929ffc38f550 + c35d998d200a4fed97c0a4b61c285d49 + 81438d8393264c71bb965baa171c5ffe + + CURRENCY + USD + + + + credit-note + 0 + + + + + c48cb82168c44c179316d8befe6634e2 + Yoyodyne, Inc. + 000001 + + Yoyodyne, Inc. + 236 Hansen Way + Palo Alto, CA 94301 + (650)555-1212 + sales@yoyodyne.com + + USEGLOBAL + 1 + + CURRENCY + USD + + 0 + + + last-posted-to-acct + 81438d8393264c71bb965baa171c5ffe + + + + + +