mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[auto-clear] Fix model
This commit is contained in:
parent
51715e454c
commit
a1806a2f94
@ -31,11 +31,11 @@ extern "C" {
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
const int DENOM = 100; //< Denomerator is always 100 for simplicity.
|
||||
const gint64 DENOM = 100; //< Denomerator is always 100 for simplicity.
|
||||
|
||||
struct SplitDatum {
|
||||
const char *memo;
|
||||
int amount; //< Numerator of amount.
|
||||
gint64 amount; //< Numerator of amount.
|
||||
bool cleared;
|
||||
};
|
||||
|
||||
@ -73,7 +73,7 @@ SplitDatum splitData[] = {
|
||||
};
|
||||
|
||||
struct TestCase {
|
||||
int amount;
|
||||
gint64 amount;
|
||||
const char *expectedErr;
|
||||
};
|
||||
|
||||
@ -88,14 +88,15 @@ TestCase testCases[] = {
|
||||
TEST(AutoClear, AutoClearAll) {
|
||||
QofBook *book = qof_book_new ();
|
||||
Account *account = xaccMallocAccount(book);
|
||||
xaccAccountSetName(account, "Test Account");
|
||||
|
||||
for (auto &d : splitData) {
|
||||
Split *split = xaccMallocSplit(book);
|
||||
xaccSplitSetMemo(split, d.memo);
|
||||
xaccSplitSetAmount(split, gnc_numeric_create(d.amount, DENOM));
|
||||
xaccSplitSetReconcile(split, d.cleared ? CREC : NREC);
|
||||
xaccSplitSetAccount(split, account);
|
||||
|
||||
// This way of inserting a split, seems to actualy work best. :D
|
||||
gnc_account_insert_split(account, split);
|
||||
}
|
||||
xaccAccountRecomputeBalance(account);
|
||||
|
Loading…
Reference in New Issue
Block a user