void xaccTransScrubPostedDate (Transaction *trans) { time64 orig = xaccTransGetDate(trans); GDate date = xaccTransGetDatePostedGDate(trans); Timespec ts = gdate_to_timespec(date); if (orig && orig != ts.tv_sec) { /* xaccTransSetDatePostedTS handles committing the change. */ xaccTransSetDatePostedTS(trans, &ts); } }
void xaccTransScrubPostedDate (Transaction *trans) { time64 orig = xaccTransGetDate(trans); if(orig == INT64_MAX) { GDate date = xaccTransGetDatePostedGDate(trans); time64 time = gdate_to_time64(date); if(time != INT64_MAX) { // xaccTransSetDatePostedSecs handles committing the change. xaccTransSetDatePostedSecs(trans, time); } } }
PaymentWindow * gnc_ui_payment_new_with_txn (GncOwner *owner, Transaction *txn) { SplitList *slist; Split *assetaccount_split; Split *postaccount_split; gnc_numeric amount; PaymentWindow *pw; if (!txn) return NULL; // We require the txn to have one split in an Asset account. slist = xaccTransGetSplitList(txn); if (!slist) return NULL; if (countAssetAccounts(slist) == 0) { g_message("No asset splits in txn \"%s\"; cannot use this for assigning a payment.", xaccTransGetDescription(txn)); return NULL; } assetaccount_split = getFirstAssetAccountSplit(slist); postaccount_split = getFirstAPARAccountSplit(slist); // watch out: Might be NULL amount = xaccSplitGetValue(assetaccount_split); pw = gnc_ui_payment_new(owner, qof_instance_get_book(QOF_INSTANCE(txn))); g_assert(assetaccount_split); // we can rely on this because of the countAssetAccounts() check above g_debug("Amount=%s", gnc_numeric_to_string(amount)); // Fill in the values from the given txn pw->pre_existing_txn = txn; gnc_ui_payment_window_set_num(pw, gnc_get_num_action(txn, assetaccount_split)); gnc_ui_payment_window_set_memo(pw, xaccTransGetDescription(txn)); { GDate txn_date = xaccTransGetDatePostedGDate (txn); gnc_ui_payment_window_set_date(pw, &txn_date); } gnc_ui_payment_window_set_amount(pw, amount); gnc_ui_payment_window_set_xferaccount(pw, xaccSplitGetAccount(assetaccount_split)); if (postaccount_split) gnc_ui_payment_window_set_postaccount(pw, xaccSplitGetAccount(postaccount_split)); return pw; }