mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 796054 - unposting and reposting invoice doubles amounts
Add scrub function to unblock the double post transaction
This commit is contained in:
parent
1239876b5b
commit
baf933acf2
@ -518,7 +518,6 @@ gncScrubBusinessLot (GNCLot *lot)
|
||||
gboolean
|
||||
gncScrubBusinessSplit (Split *split)
|
||||
{
|
||||
const gchar *memo = _("Please delete this transaction. Explanation at https://wiki.gnucash.org/wiki/Business_Features_Issues#Double_posting");
|
||||
Transaction *txn;
|
||||
gboolean deleted_split = FALSE;
|
||||
|
||||
@ -532,6 +531,8 @@ gncScrubBusinessSplit (Split *split)
|
||||
const gchar *read_only = xaccTransGetReadOnly (txn);
|
||||
gboolean is_void = xaccTransGetVoidStatus (txn);
|
||||
GNCLot *lot = xaccSplitGetLot (split);
|
||||
GncInvoice *invoice = gncInvoiceGetInvoiceFromTxn (txn);
|
||||
Transaction *posted_txn = gncInvoiceGetPostedTxn (invoice);
|
||||
|
||||
/* Look for transactions as a result of double posting an invoice or bill
|
||||
* Refer to https://bugs.gnucash.org/show_bug.cgi?id=754209
|
||||
@ -544,6 +545,7 @@ gncScrubBusinessSplit (Split *split)
|
||||
*/
|
||||
if ((txntype == TXN_TYPE_NONE) && read_only && !is_void && lot)
|
||||
{
|
||||
const gchar *memo = _("Please delete this transaction. Explanation at https://wiki.gnucash.org/wiki/Business_Features_Issues#Double_posting");
|
||||
gchar *txn_date = qof_print_date (xaccTransGetDateEntered (txn));
|
||||
xaccTransClearReadOnly (txn);
|
||||
xaccSplitSetMemo (split, memo);
|
||||
@ -554,6 +556,28 @@ gncScrubBusinessSplit (Split *split)
|
||||
txn_date);
|
||||
g_free (txn_date);
|
||||
}
|
||||
/* Next check for transactions which claim to be the posted transaction of
|
||||
* an invoice but the invoice disagrees. In that case
|
||||
*/
|
||||
else if (invoice && (txn != posted_txn))
|
||||
{
|
||||
const gchar *memo = _("Please delete this transaction. Explanation at https://wiki.gnucash.org/wiki/Business_Features_Issues#Double_posting");
|
||||
gchar *txn_date = qof_print_date (xaccTransGetDateEntered (txn));
|
||||
xaccTransClearReadOnly (txn);
|
||||
xaccTransSetTxnType (txn, TXN_TYPE_NONE);
|
||||
xaccSplitSetMemo (split, memo);
|
||||
if (lot)
|
||||
{
|
||||
gnc_lot_remove_split (lot, split);
|
||||
gncInvoiceDetachFromLot (lot);
|
||||
gncOwnerAttachToLot (gncInvoiceGetOwner(invoice), lot);
|
||||
}
|
||||
PWARN("Cleared double post status of transaction \"%s\", dated %s. "
|
||||
"Please delete transaction and verify balance.",
|
||||
xaccTransGetDescription (txn),
|
||||
txn_date);
|
||||
g_free (txn_date);
|
||||
}
|
||||
/* Next delete any empty splits that aren't part of an invoice transaction
|
||||
* Such splits may be the result of scrubbing the business lots, which can
|
||||
* merge splits together while reducing superfluous lot links
|
||||
|
Loading…
Reference in New Issue
Block a user