mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add APIs to get/set a flag signifying that a transaction is a book-closing txn.
This is necessary for Bug #570042 but doesn't completely solve it until the reports are updated to use the new API. This is backwards-compatible with the slot data inserted by the book closing since 2010-03-02. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19945 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
5d1e22bf92
commit
3f70c99002
@ -175,6 +175,7 @@ const char *trans_notes_str = "notes";
|
||||
const char *void_reason_str = "void-reason";
|
||||
const char *void_time_str = "void-time";
|
||||
const char *void_former_notes_str = "void-former-notes";
|
||||
const char *trans_is_closing_str = "book_closing";
|
||||
|
||||
/* KVP entry for date-due value */
|
||||
#define TRANS_DATE_DUE_KVP "trans-date-due"
|
||||
@ -1785,6 +1786,21 @@ xaccTransSetNotes (Transaction *trans, const char *notes)
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
|
||||
void
|
||||
xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
|
||||
{
|
||||
if (!trans) return;
|
||||
xaccTransBeginEdit(trans);
|
||||
|
||||
if (is_closing)
|
||||
kvp_frame_set_gint64 (trans->inst.kvp_data, trans_is_closing_str, 1);
|
||||
else
|
||||
kvp_frame_replace_value_nc (trans->inst.kvp_data, trans_is_closing_str, NULL);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@ -1841,6 +1857,14 @@ xaccTransGetNotes (const Transaction *trans)
|
||||
kvp_frame_get_string (trans->inst.kvp_data, trans_notes_str) : NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xaccTransGetIsClosingTxn (const Transaction *trans)
|
||||
{
|
||||
return trans ?
|
||||
kvp_frame_get_gint64 (trans->inst.kvp_data, trans_is_closing_str)
|
||||
: FALSE;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@ -2340,6 +2364,10 @@ gboolean xaccTransRegister (void)
|
||||
(QofAccessFunc)xaccTransGetNotes,
|
||||
(QofSetterFunc)qofTransSetNotes
|
||||
},
|
||||
{
|
||||
TRANS_IS_CLOSING, QOF_TYPE_BOOLEAN,
|
||||
(QofAccessFunc)xaccTransGetIsClosingTxn, NULL
|
||||
},
|
||||
{
|
||||
TRANS_IS_BALANCED, QOF_TYPE_BOOLEAN,
|
||||
(QofAccessFunc)trans_is_balanced_p, NULL
|
||||
|
@ -283,6 +283,13 @@ const char * xaccTransGetDescription (const Transaction *trans);
|
||||
const char * xaccTransGetNotes (const Transaction *trans);
|
||||
|
||||
|
||||
/** Sets whether or not this transaction is a "closing transaction" */
|
||||
void xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing);
|
||||
|
||||
/** Returns whether this transaction is a "closing transaction" */
|
||||
gboolean xaccTransGetIsClosingTxn (const Transaction *trans);
|
||||
|
||||
|
||||
/** Add a split to the transaction
|
||||
*
|
||||
The xaccTransAppendSplit() method will append the indicated
|
||||
@ -597,6 +604,7 @@ Timespec xaccTransGetVoidTime(const Transaction *tr);
|
||||
#define TRANS_DATE_DUE "date-due"
|
||||
#define TRANS_IMBALANCE "trans-imbalance"
|
||||
#define TRANS_IS_BALANCED "trans-balanced?"
|
||||
#define TRANS_IS_CLOSING "trans-is-closing?"
|
||||
#define TRANS_NOTES "notes"
|
||||
#define TRANS_TYPE "type"
|
||||
#define TRANS_VOID_STATUS "void-p"
|
||||
|
@ -104,12 +104,7 @@ find_or_create_txn(struct CloseAccountsCB* cacb, gnc_commodity* cmdty)
|
||||
xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
|
||||
xaccTransSetDescription(txn->txn, cacb->cbw->desc);
|
||||
xaccTransSetCurrency(txn->txn, cmdty);
|
||||
frame = xaccTransGetSlots(txn->txn);
|
||||
/* Add a bool flag to indicate this txn was created automatically
|
||||
by the book closing feature. See
|
||||
https://lists.gnucash.org/pipermail/gnucash-devel/2008-August/023757.html */
|
||||
kvp_frame_set_gint64(frame, "book_closing", 1);
|
||||
|
||||
xaccTransSetIsClosingTxn(txn->txn, TRUE);
|
||||
g_hash_table_insert(cacb->txns, cmdty, txn);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user