33 #include <glib/gi18n.h>
55 static gboolean reduce_biggest_split (
Split *splitA,
Split *splitB)
81 scrub_other_link (
GNCLot *from_lot,
Split *ll_from_split,
84 Split *real_from_split;
86 gboolean modified = FALSE;
93 modified = reduce_biggest_split (ll_from_split, ll_to_split);
105 modified = reduce_biggest_split (real_from_split, ll_from_split);
109 modified = reduce_biggest_split (ll_from_split, ll_to_split);
119 PWARN(
"real_from_val and to_val differ. "
120 "This is unexpected! Skip scrubbing of real_from_split %p against ll_to_split %p.", real_from_split, ll_to_split);
141 gncScrubLotLinks (
GNCLot *scrub_lot)
143 gboolean modified = FALSE, restart_needed = FALSE;
147 restart_needed = FALSE;
152 Split *sl_split = sls_iter->data;
166 PWARN(
"Encountered a split in a business lot that's not part of any transaction. "
167 "This is unexpected! Skipping split %p.", sl_split);
177 Split *ll_txn_split = lts_iter->data;
178 GNCLot *remote_lot = NULL;
179 gboolean sl_is_doc_lot, rl_is_doc_lot;
185 if (sl_split == ll_txn_split)
198 PWARN(
"Encountered a Lot Link transaction with a split that's not in any lot. "
199 "This is unexpected! Skipping split %p from transaction %p.", ll_txn_split, ll_txn);
218 if (sl_is_doc_lot && rl_is_doc_lot)
220 else if (!sl_is_doc_lot && !rl_is_doc_lot)
225 restart_needed = scrub_other_link (scrub_lot, sl_split, remote_lot, ll_txn_split);
227 restart_needed = scrub_other_link (remote_lot, ll_txn_split, scrub_lot, sl_split);
231 GNCLot *doc_lot = sl_is_doc_lot ? scrub_lot : remote_lot;
232 GNCLot *pay_lot = sl_is_doc_lot ? remote_lot : scrub_lot;
233 Split *ll_doc_split = sl_is_doc_lot ? sl_split : ll_txn_split;
234 Split *ll_pay_split = sl_is_doc_lot ? ll_txn_split : sl_split;
236 restart_needed = scrub_other_link (pay_lot, ll_pay_split, doc_lot, ll_doc_split);
258 gboolean splits_deleted = FALSE;
262 if (!lot)
return FALSE;
264 ENTER (
"(lot=%p) %s", lot, lotname ? lotname :
"(no lotname)");
273 splits_deleted = gncScrubLotLinks (lot);
276 if (0 == gnc_lot_count_splits (lot))
278 PINFO(
"All splits were removed from lot, deleting");
279 gnc_lot_destroy (lot);
285 LEAVE (
"(lot=%s, deleted=%d)", lotname ? lotname :
"(no lotname)", splits_deleted);
288 return splits_deleted;
304 for (node = lots; node; node = node->next)
318 lot_scrub_cb (
Account *acc, gpointer data)
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
gboolean xaccScrubMergeLotSubSplits(GNCLot *lot, gboolean strict)
char xaccTransGetTxnType(const Transaction *trans)
void gnc_account_foreach_descendant(const Account *acc, AccountCb thunk, gpointer user_data)
#define PINFO(format, args...)
GNCAccountType xaccAccountGetType(const Account *acc)
gboolean xaccSplitDestroy(Split *split)
Utilities to Convert Stock Accounts to use Lots.
void gncScrubBusinessAccountLots(Account *acc)
gnc_numeric gnc_numeric_neg(gnc_numeric a)
void gnc_lot_add_split(GNCLot *lot, Split *split)
Transaction * xaccSplitGetParent(const Split *split)
gint gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
#define ENTER(format, args...)
Cleanup functions for business objects.
const char * gnc_lot_get_title(const GNCLot *lot)
#define PWARN(format, args...)
Account handling public routines.
gboolean gncOwnerReduceSplitTo(Split *split, gnc_numeric target_value)
Implement Accounting Policy Private header File.
SplitList * gnc_lot_get_split_list(const GNCLot *lot)
LotList * xaccAccountGetLotList(const Account *acc)
gboolean xaccAccountIsAPARType(GNCAccountType t)
gnc_numeric gnc_numeric_abs(gnc_numeric a)
void xaccTransCommitEdit(Transaction *trans)
void xaccTransBeginEdit(Transaction *trans)
All type declarations for the whole Gnucash engine.
gboolean gnc_numeric_positive_p(gnc_numeric a)
GncInvoice * gncInvoiceGetInvoiceFromLot(GNCLot *lot)
Business Invoice Interface.
gnc_numeric xaccSplitGetValue(const Split *split)
gboolean gncScrubBusinessLot(GNCLot *lot)
void xaccAccountBeginEdit(Account *acc)
#define LEAVE(format, args...)
Split * gncOwnerFindOffsettingSplit(GNCLot *lot, gnc_numeric target_value)
void gncOwnerSetLotLinkMemo(Transaction *ll_txn)
Account * gnc_lot_get_account(const GNCLot *lot)
void gncScrubBusinessAccountTreeLots(Account *acc)
const char * xaccAccountGetName(const Account *acc)
API for Transactions and Splits (journal entries)
void xaccAccountCommitEdit(Account *acc)
SplitList * xaccTransGetSplitList(const Transaction *trans)
GNCLot * xaccSplitGetLot(const Split *split)
const gchar * QofLogModule