mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
AccWindow.h: Add comment about who owns the GList *
gncInvoice.[ch]: add date-posted, paid-txn change date-closed->date-paid add gncInvoicePayToAccount() dialog-date-close.[ch]: allow list of account-types provide a dialog with only 1 date and account (for invoice payment) dialog-invoice.c: provide list of accounts to date-close dialog(s) change 'close' to 'pay' hide cancel button on posted/paid invoices dialog-order.c: hide cancel button on closed orders search-date.c: remove unused time_t search-param.[ch]: provide a 'type' over-ride git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6707 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
edbbab384a
commit
ea0d741c3b
@ -41,6 +41,8 @@ AccountWindow * gnc_ui_new_account_window_with_default(AccountGroup *group,
|
|||||||
AccountWindow * gnc_ui_edit_account_window (Account *account);
|
AccountWindow * gnc_ui_edit_account_window (Account *account);
|
||||||
|
|
||||||
Account * gnc_ui_new_accounts_from_name_window (const char *name);
|
Account * gnc_ui_new_accounts_from_name_window (const char *name);
|
||||||
|
|
||||||
|
/* Note that the caller owns the valid_types list */
|
||||||
Account * gnc_ui_new_accounts_from_name_window_with_types (const char *name,
|
Account * gnc_ui_new_accounts_from_name_window_with_types (const char *name,
|
||||||
GList *valid_types);
|
GList *valid_types);
|
||||||
|
|
||||||
|
@ -35,11 +35,13 @@ struct _gncInvoice {
|
|||||||
GList * entries;
|
GList * entries;
|
||||||
GncOwner owner;
|
GncOwner owner;
|
||||||
Timespec date_opened;
|
Timespec date_opened;
|
||||||
|
Timespec date_posted;
|
||||||
Timespec date_due;
|
Timespec date_due;
|
||||||
Timespec date_closed;
|
Timespec date_paid;
|
||||||
|
|
||||||
Account * posted_acc;
|
Account * posted_acc;
|
||||||
Transaction * posted_txn;
|
Transaction * posted_txn;
|
||||||
|
Transaction * paid_txn;
|
||||||
|
|
||||||
gboolean active;
|
gboolean active;
|
||||||
|
|
||||||
@ -134,6 +136,13 @@ void gncInvoiceSetDateOpened (GncInvoice *invoice, const Timespec *date)
|
|||||||
invoice->dirty = TRUE;
|
invoice->dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gncInvoiceSetDatePosted (GncInvoice *invoice, const Timespec *date)
|
||||||
|
{
|
||||||
|
if (!invoice || !date) return;
|
||||||
|
invoice->date_posted = *date;
|
||||||
|
invoice->dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void gncInvoiceSetDateDue (GncInvoice *invoice, const Timespec *date)
|
void gncInvoiceSetDateDue (GncInvoice *invoice, const Timespec *date)
|
||||||
{
|
{
|
||||||
if (!invoice || !date) return;
|
if (!invoice || !date) return;
|
||||||
@ -141,10 +150,10 @@ void gncInvoiceSetDateDue (GncInvoice *invoice, const Timespec *date)
|
|||||||
invoice->dirty = TRUE;
|
invoice->dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncInvoiceSetDateClosed (GncInvoice *invoice, const Timespec *date)
|
void gncInvoiceSetDatePaid (GncInvoice *invoice, const Timespec *date)
|
||||||
{
|
{
|
||||||
if (!invoice || !date) return;
|
if (!invoice || !date) return;
|
||||||
invoice->date_closed = *date;
|
invoice->date_paid = *date;
|
||||||
invoice->dirty = TRUE;
|
invoice->dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +192,14 @@ void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn)
|
|||||||
invoice->dirty = TRUE;
|
invoice->dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gncInvoiceSetPaidTxn (GncInvoice *invoice, Transaction *txn)
|
||||||
|
{
|
||||||
|
if (!invoice) return;
|
||||||
|
|
||||||
|
invoice->paid_txn = txn;
|
||||||
|
invoice->dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc)
|
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc)
|
||||||
{
|
{
|
||||||
if (!invoice) return;
|
if (!invoice) return;
|
||||||
@ -248,6 +265,13 @@ Timespec gncInvoiceGetDateOpened (GncInvoice *invoice)
|
|||||||
return invoice->date_opened;
|
return invoice->date_opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timespec gncInvoiceGetDatePosted (GncInvoice *invoice)
|
||||||
|
{
|
||||||
|
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
|
||||||
|
if (!invoice) return ts;
|
||||||
|
return invoice->date_posted;
|
||||||
|
}
|
||||||
|
|
||||||
Timespec gncInvoiceGetDateDue (GncInvoice *invoice)
|
Timespec gncInvoiceGetDateDue (GncInvoice *invoice)
|
||||||
{
|
{
|
||||||
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
|
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
|
||||||
@ -255,11 +279,11 @@ Timespec gncInvoiceGetDateDue (GncInvoice *invoice)
|
|||||||
return invoice->date_due;
|
return invoice->date_due;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timespec gncInvoiceGetDateClosed (GncInvoice *invoice)
|
Timespec gncInvoiceGetDatePaid (GncInvoice *invoice)
|
||||||
{
|
{
|
||||||
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
|
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
|
||||||
if (!invoice) return ts;
|
if (!invoice) return ts;
|
||||||
return invoice->date_closed;
|
return invoice->date_paid;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * gncInvoiceGetTerms (GncInvoice *invoice)
|
const char * gncInvoiceGetTerms (GncInvoice *invoice)
|
||||||
@ -280,6 +304,12 @@ Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice)
|
|||||||
return invoice->posted_txn;
|
return invoice->posted_txn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transaction * gncInvoiceGetPaidTxn (GncInvoice *invoice)
|
||||||
|
{
|
||||||
|
if (!invoice) return NULL;
|
||||||
|
return invoice->posted_txn;
|
||||||
|
}
|
||||||
|
|
||||||
Account * gncInvoiceGetPostedAcc (GncInvoice *invoice)
|
Account * gncInvoiceGetPostedAcc (GncInvoice *invoice)
|
||||||
{
|
{
|
||||||
if (!invoice) return NULL;
|
if (!invoice) return NULL;
|
||||||
@ -304,7 +334,8 @@ gboolean gncInvoiceIsDirty (GncInvoice *invoice)
|
|||||||
return invoice->dirty;
|
return invoice->dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncInvoiceAttachInvoiceToTxn (GncInvoice *invoice, Transaction *txn)
|
static void
|
||||||
|
gncInvoiceAttachInvoiceToTxn (GncInvoice *invoice, Transaction *txn, char type)
|
||||||
{
|
{
|
||||||
kvp_frame *kvp;
|
kvp_frame *kvp;
|
||||||
kvp_value *value;
|
kvp_value *value;
|
||||||
@ -319,10 +350,19 @@ void gncInvoiceAttachInvoiceToTxn (GncInvoice *invoice, Transaction *txn)
|
|||||||
value = kvp_value_new_guid (gncInvoiceGetGUID (invoice));
|
value = kvp_value_new_guid (gncInvoiceGetGUID (invoice));
|
||||||
kvp_frame_set_slot_path (kvp, value, GNC_INVOICE_ID, GNC_INVOICE_GUID, NULL);
|
kvp_frame_set_slot_path (kvp, value, GNC_INVOICE_ID, GNC_INVOICE_GUID, NULL);
|
||||||
kvp_value_delete (value);
|
kvp_value_delete (value);
|
||||||
xaccTransSetTxnType (txn, TXN_TYPE_INVOICE);
|
xaccTransSetTxnType (txn, type);
|
||||||
xaccTransCommitEdit (txn);
|
xaccTransCommitEdit (txn);
|
||||||
|
|
||||||
gncInvoiceSetPostedTxn (invoice, txn);
|
switch (type) {
|
||||||
|
case TXN_TYPE_PAYMENT:
|
||||||
|
gncInvoiceSetPaidTxn (invoice, txn);
|
||||||
|
break;
|
||||||
|
case TXN_TYPE_INVOICE:
|
||||||
|
gncInvoiceSetPostedTxn (invoice, txn);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GET_OR_ADD_ACCVAL(list,t_acc,res) { \
|
#define GET_OR_ADD_ACCVAL(list,t_acc,res) { \
|
||||||
@ -357,11 +397,11 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
|||||||
|
|
||||||
if (!invoice || !acc) return NULL;
|
if (!invoice || !acc) return NULL;
|
||||||
|
|
||||||
|
/* XXX: Figure out the common currency */
|
||||||
|
|
||||||
txn = xaccMallocTransaction (invoice->book);
|
txn = xaccMallocTransaction (invoice->book);
|
||||||
xaccTransBeginEdit (txn);
|
xaccTransBeginEdit (txn);
|
||||||
|
|
||||||
/* XXX: Figure out the common currency */
|
|
||||||
|
|
||||||
/* Set Transaction Description (customer), Num (invoice ID), Currency */
|
/* Set Transaction Description (customer), Num (invoice ID), Currency */
|
||||||
xaccTransSetDescription
|
xaccTransSetDescription
|
||||||
(txn, gncOwnerGetName (gncInvoiceGetOwner (invoice)));
|
(txn, gncOwnerGetName (gncInvoiceGetOwner (invoice)));
|
||||||
@ -373,6 +413,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
|||||||
if (date) {
|
if (date) {
|
||||||
xaccTransSetDateEnteredTS (txn, date);
|
xaccTransSetDateEnteredTS (txn, date);
|
||||||
xaccTransSetDatePostedTS (txn, date);
|
xaccTransSetDatePostedTS (txn, date);
|
||||||
|
gncInvoiceSetDatePosted (invoice, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the txn due date to be equal to the invoice */
|
/* Set the txn due date to be equal to the invoice */
|
||||||
@ -445,7 +486,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now attach this invoice to the txn and account */
|
/* Now attach this invoice to the txn and account */
|
||||||
gncInvoiceAttachInvoiceToTxn (invoice, txn);
|
gncInvoiceAttachInvoiceToTxn (invoice, txn, TXN_TYPE_INVOICE);
|
||||||
gncInvoiceSetPostedAcc (invoice, acc);
|
gncInvoiceSetPostedAcc (invoice, acc);
|
||||||
|
|
||||||
xaccTransCommitEdit (txn);
|
xaccTransCommitEdit (txn);
|
||||||
@ -453,6 +494,92 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
|||||||
return txn;
|
return txn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transaction *
|
||||||
|
gncInvoicePayToAccount (GncInvoice *invoice, Account *acc,
|
||||||
|
Timespec *paid_date)
|
||||||
|
{
|
||||||
|
Transaction *txn;
|
||||||
|
gnc_numeric total;
|
||||||
|
gnc_commodity *commonCommodity = NULL; /* XXX: FIXME */
|
||||||
|
Account *acct;
|
||||||
|
|
||||||
|
if (!invoice || !acc) return NULL;
|
||||||
|
|
||||||
|
/* Must have posted before you can pay */
|
||||||
|
g_return_val_if_fail (gncInvoiceGetPostedTxn(invoice), NULL);
|
||||||
|
acct = gncInvoiceGetPostedAcc (invoice);
|
||||||
|
g_return_val_if_fail (acct, NULL);
|
||||||
|
|
||||||
|
/* Determine the value for this payment.. Find the split into
|
||||||
|
* the posted account and pull the value out of that.
|
||||||
|
* XXX: Should the payment value be an argument here?
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
GList *l = xaccTransGetSplitList (gncInvoiceGetPostedTxn (invoice));
|
||||||
|
|
||||||
|
for (; l; l=l->next) {
|
||||||
|
Split *s = l->data;
|
||||||
|
|
||||||
|
if (xaccSplitGetAccount (s) == acct) {
|
||||||
|
total = xaccSplitGetValue (s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure we found the Split */
|
||||||
|
g_return_val_if_fail (l, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX: Figure out the common currency */
|
||||||
|
|
||||||
|
txn = xaccMallocTransaction (invoice->book);
|
||||||
|
xaccTransBeginEdit (txn);
|
||||||
|
|
||||||
|
/* Set Transaction Description (customer), Num (invoice ID), Currency */
|
||||||
|
xaccTransSetDescription
|
||||||
|
(txn, gncOwnerGetName (gncInvoiceGetOwner (invoice)));
|
||||||
|
|
||||||
|
xaccTransSetNum (txn, gncInvoiceGetID (invoice));
|
||||||
|
xaccTransSetCurrency (txn, commonCommodity);
|
||||||
|
|
||||||
|
/* Entered and Posted at date */
|
||||||
|
if (paid_date) {
|
||||||
|
xaccTransSetDateEnteredTS (txn, paid_date);
|
||||||
|
xaccTransSetDatePostedTS (txn, paid_date);
|
||||||
|
gncInvoiceSetDatePaid (invoice, paid_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create the split to the payment account */
|
||||||
|
{
|
||||||
|
Split *split = xaccMallocSplit (invoice->book);
|
||||||
|
/* Set action/memo */
|
||||||
|
xaccSplitSetBaseValue (split, total, commonCommodity);
|
||||||
|
xaccAccountBeginEdit (acc);
|
||||||
|
xaccAccountInsertSplit (acc, split);
|
||||||
|
xaccAccountCommitEdit (acc);
|
||||||
|
xaccTransAppendSplit (txn, split);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now create the Payment split for the posted acc, reverse value */
|
||||||
|
{
|
||||||
|
Split *split = xaccMallocSplit (invoice->book);
|
||||||
|
|
||||||
|
/* Set action/memo */
|
||||||
|
xaccSplitSetBaseValue (split, gnc_numeric_neg (total), commonCommodity);
|
||||||
|
xaccAccountBeginEdit (acct);
|
||||||
|
xaccAccountInsertSplit (acct, split);
|
||||||
|
xaccAccountCommitEdit (acct);
|
||||||
|
xaccTransAppendSplit (txn, split);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now attach this invoice to the txn and account */
|
||||||
|
gncInvoiceAttachInvoiceToTxn (invoice, txn, TXN_TYPE_PAYMENT);
|
||||||
|
|
||||||
|
xaccTransCommitEdit (txn);
|
||||||
|
|
||||||
|
return txn;
|
||||||
|
}
|
||||||
|
|
||||||
GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn)
|
GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn)
|
||||||
{
|
{
|
||||||
kvp_frame *kvp;
|
kvp_frame *kvp;
|
||||||
@ -503,7 +630,10 @@ int gncInvoiceCompare (GncInvoice *a, GncInvoice *b)
|
|||||||
compare = timespec_cmp (&(a->date_opened), &(b->date_opened));
|
compare = timespec_cmp (&(a->date_opened), &(b->date_opened));
|
||||||
if (!compare) return compare;
|
if (!compare) return compare;
|
||||||
|
|
||||||
compare = timespec_cmp (&(a->date_closed), &(b->date_closed));
|
compare = timespec_cmp (&(a->date_posted), &(b->date_posted));
|
||||||
|
if (!compare) return compare;
|
||||||
|
|
||||||
|
compare = timespec_cmp (&(a->date_paid), &(b->date_paid));
|
||||||
if (!compare) return compare;
|
if (!compare) return compare;
|
||||||
|
|
||||||
return guid_compare (&(a->guid), &(b->guid));
|
return guid_compare (&(a->guid), &(b->guid));
|
||||||
@ -577,11 +707,13 @@ gboolean gncInvoiceRegister (void)
|
|||||||
{ INVOICE_ID, QUERYCORE_STRING, (QueryAccess)gncInvoiceGetID },
|
{ INVOICE_ID, QUERYCORE_STRING, (QueryAccess)gncInvoiceGetID },
|
||||||
{ INVOICE_OWNER, GNC_OWNER_MODULE_NAME, (QueryAccess)gncInvoiceGetOwner },
|
{ INVOICE_OWNER, GNC_OWNER_MODULE_NAME, (QueryAccess)gncInvoiceGetOwner },
|
||||||
{ INVOICE_OPENED, QUERYCORE_DATE, (QueryAccess)gncInvoiceGetDateOpened },
|
{ INVOICE_OPENED, QUERYCORE_DATE, (QueryAccess)gncInvoiceGetDateOpened },
|
||||||
|
{ INVOICE_POSTED, QUERYCORE_DATE, (QueryAccess)gncInvoiceGetDatePosted },
|
||||||
{ INVOICE_DUE, QUERYCORE_DATE, (QueryAccess)gncInvoiceGetDateDue },
|
{ INVOICE_DUE, QUERYCORE_DATE, (QueryAccess)gncInvoiceGetDateDue },
|
||||||
{ INVOICE_CLOSED, QUERYCORE_DATE, (QueryAccess)gncInvoiceGetDateClosed },
|
{ INVOICE_PAID, QUERYCORE_DATE, (QueryAccess)gncInvoiceGetDatePaid },
|
||||||
{ INVOICE_NOTES, QUERYCORE_STRING, (QueryAccess)gncInvoiceGetNotes },
|
{ INVOICE_NOTES, QUERYCORE_STRING, (QueryAccess)gncInvoiceGetNotes },
|
||||||
{ INVOICE_ACC, GNC_ID_ACCOUNT, (QueryAccess)gncInvoiceGetPostedAcc },
|
{ INVOICE_ACC, GNC_ID_ACCOUNT, (QueryAccess)gncInvoiceGetPostedAcc },
|
||||||
{ INVOICE_TXN, GNC_ID_TRANS, (QueryAccess)gncInvoiceGetPostedTxn },
|
{ INVOICE_POST_TXN, GNC_ID_TRANS, (QueryAccess)gncInvoiceGetPostedTxn },
|
||||||
|
{ INVOICE_PD_TXN, GNC_ID_TRANS, (QueryAccess)gncInvoiceGetPaidTxn },
|
||||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncInvoiceGetBook },
|
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncInvoiceGetBook },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
@ -25,8 +25,9 @@ void gncInvoiceDestroy (GncInvoice *invoice);
|
|||||||
void gncInvoiceSetID (GncInvoice *invoice, const char *id);
|
void gncInvoiceSetID (GncInvoice *invoice, const char *id);
|
||||||
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner);
|
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner);
|
||||||
void gncInvoiceSetDateOpened (GncInvoice *invoice, const Timespec *date);
|
void gncInvoiceSetDateOpened (GncInvoice *invoice, const Timespec *date);
|
||||||
|
void gncInvoiceSetDatePosted (GncInvoice *invoice, const Timespec *date);
|
||||||
void gncInvoiceSetDateDue (GncInvoice *invoice, const Timespec *date);
|
void gncInvoiceSetDateDue (GncInvoice *invoice, const Timespec *date);
|
||||||
void gncInvoiceSetDateClosed (GncInvoice *invoice, const Timespec *date);
|
void gncInvoiceSetDatePaid (GncInvoice *invoice, const Timespec *date);
|
||||||
void gncInvoiceSetTerms (GncInvoice *invoice, const char *terms);
|
void gncInvoiceSetTerms (GncInvoice *invoice, const char *terms);
|
||||||
void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes);
|
void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes);
|
||||||
void gncInvoiceSetActive (GncInvoice *invoice, gboolean active);
|
void gncInvoiceSetActive (GncInvoice *invoice, gboolean active);
|
||||||
@ -41,13 +42,15 @@ const GUID * gncInvoiceGetGUID (GncInvoice *invoice);
|
|||||||
const char * gncInvoiceGetID (GncInvoice *invoice);
|
const char * gncInvoiceGetID (GncInvoice *invoice);
|
||||||
GncOwner * gncInvoiceGetOwner (GncInvoice *invoice);
|
GncOwner * gncInvoiceGetOwner (GncInvoice *invoice);
|
||||||
Timespec gncInvoiceGetDateOpened (GncInvoice *invoice);
|
Timespec gncInvoiceGetDateOpened (GncInvoice *invoice);
|
||||||
|
Timespec gncInvoiceGetDatePosted (GncInvoice *invoice);
|
||||||
Timespec gncInvoiceGetDateDue (GncInvoice *invoice);
|
Timespec gncInvoiceGetDateDue (GncInvoice *invoice);
|
||||||
Timespec gncInvoiceGetDateClosed (GncInvoice *invoice);
|
Timespec gncInvoiceGetDatePaid (GncInvoice *invoice);
|
||||||
const char * gncInvoiceGetTerms (GncInvoice *invoice);
|
const char * gncInvoiceGetTerms (GncInvoice *invoice);
|
||||||
const char * gncInvoiceGetNotes (GncInvoice *invoice);
|
const char * gncInvoiceGetNotes (GncInvoice *invoice);
|
||||||
gboolean gncInvoiceGetActive (GncInvoice *invoice);
|
gboolean gncInvoiceGetActive (GncInvoice *invoice);
|
||||||
|
|
||||||
Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice);
|
Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice);
|
||||||
|
Transaction * gncInvoiceGetPaidTxn (GncInvoice *invoice);
|
||||||
Account * gncInvoiceGetPostedAcc (GncInvoice *invoice);
|
Account * gncInvoiceGetPostedAcc (GncInvoice *invoice);
|
||||||
|
|
||||||
GList * gncInvoiceGetEntries (GncInvoice *invoice);
|
GList * gncInvoiceGetEntries (GncInvoice *invoice);
|
||||||
@ -62,6 +65,14 @@ Transaction *
|
|||||||
gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||||
Timespec *posted_date, gboolean reverse);
|
Timespec *posted_date, gboolean reverse);
|
||||||
|
|
||||||
|
|
||||||
|
/* Pay this invoice, by creating a split from the posted_acc to the
|
||||||
|
* supplied (bank) account, occuring at the specified paid_date.
|
||||||
|
*/
|
||||||
|
Transaction *
|
||||||
|
gncInvoicePayToAccount (GncInvoice *invoice, Account *acc,
|
||||||
|
Timespec *paid_date);
|
||||||
|
|
||||||
/* Given a transaction, find and return the Invoice */
|
/* Given a transaction, find and return the Invoice */
|
||||||
GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn);
|
GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn);
|
||||||
|
|
||||||
@ -75,10 +86,12 @@ int gncInvoiceCompare (GncInvoice *a, GncInvoice *b);
|
|||||||
#define INVOICE_ID "id"
|
#define INVOICE_ID "id"
|
||||||
#define INVOICE_OWNER "owner"
|
#define INVOICE_OWNER "owner"
|
||||||
#define INVOICE_OPENED "date_opened"
|
#define INVOICE_OPENED "date_opened"
|
||||||
|
#define INVOICE_POSTED "date_posted"
|
||||||
#define INVOICE_DUE "date_due"
|
#define INVOICE_DUE "date_due"
|
||||||
#define INVOICE_CLOSED "date_closed"
|
#define INVOICE_PAID "date_paid"
|
||||||
#define INVOICE_NOTES "notes"
|
#define INVOICE_NOTES "notes"
|
||||||
#define INVOICE_ACC "account"
|
#define INVOICE_ACC "account"
|
||||||
#define INVOICE_TXN "txn"
|
#define INVOICE_POST_TXN "posted_txn"
|
||||||
|
#define INVOICE_PD_TXN "paid_txn"
|
||||||
|
|
||||||
#endif /* GNC_INVOICE_H_ */
|
#endif /* GNC_INVOICE_H_ */
|
||||||
|
@ -17,6 +17,6 @@ void gncInvoiceSetGUID (GncInvoice *invoice, const GUID *guid);
|
|||||||
void gncInvoiceSetDirty (GncInvoice *invoice, gboolean dirty);
|
void gncInvoiceSetDirty (GncInvoice *invoice, gboolean dirty);
|
||||||
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc);
|
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc);
|
||||||
void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn);
|
void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn);
|
||||||
void gncInvoiceAttachInvoiceToTxn (GncInvoice *invoice, Transaction *txn);
|
void gncInvoiceSetPaidTxn (GncInvoice *invoice, Transaction *txn);
|
||||||
|
|
||||||
#endif /* GNC_INVOICEP_H_ */
|
#endif /* GNC_INVOICEP_H_ */
|
||||||
|
@ -24,7 +24,7 @@ typedef struct _dialog_date_close_window {
|
|||||||
GtkWidget *post_date;
|
GtkWidget *post_date;
|
||||||
GtkWidget *acct_combo;
|
GtkWidget *acct_combo;
|
||||||
Timespec *ts, *ts2;
|
Timespec *ts, *ts2;
|
||||||
GNCAccountType acct_type;
|
GList * acct_types;
|
||||||
GNCBook *book;
|
GNCBook *book;
|
||||||
Account *acct;
|
Account *acct;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
@ -49,8 +49,8 @@ ask_make_acct (DialogDateClose *ddc, const char *name, gboolean new_acc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
types = g_list_append (types, (gpointer)(ddc->acct_type));
|
acc = gnc_ui_new_accounts_from_name_window_with_types (name,
|
||||||
acc = gnc_ui_new_accounts_from_name_window_with_types (name, types);
|
ddc->acct_types);
|
||||||
g_list_free (types);
|
g_list_free (types);
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
@ -83,13 +83,12 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xaccAccountGetType (acc) != ddc->acct_type) {
|
if (g_list_index (ddc->acct_types, (gpointer)xaccAccountGetType (acc))
|
||||||
|
== -1) {
|
||||||
char *message =
|
char *message =
|
||||||
g_strdup_printf (_("Invalid Account Type, %s.\n"
|
g_strdup_printf (_("Invalid Account Type, %s.\n"
|
||||||
"You need an account of type %s."
|
|
||||||
"Please try again..."),
|
"Please try again..."),
|
||||||
xaccAccountGetTypeStr (xaccAccountGetType (acc)),
|
xaccAccountGetTypeStr (xaccAccountGetType (acc)));
|
||||||
xaccAccountGetTypeStr (ddc->acct_type));
|
|
||||||
gnc_error_dialog_parented (GTK_WINDOW (ddc->dialog), message);
|
gnc_error_dialog_parented (GTK_WINDOW (ddc->dialog), message);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
name = xaccAccountGetFullName (acc, gnc_get_account_separator ());
|
name = xaccAccountGetFullName (acc, gnc_get_account_separator ());
|
||||||
@ -144,7 +143,8 @@ fill_in_acct_info (DialogDateClose *ddc)
|
|||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/* Only present accounts of the appropriate type */
|
/* Only present accounts of the appropriate type */
|
||||||
if (xaccAccountGetType (account) != ddc->acct_type)
|
if (g_list_index (ddc->acct_types,
|
||||||
|
(gpointer)xaccAccountGetType (account)) == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
name = xaccAccountGetFullName (account, gnc_get_account_separator ());
|
name = xaccAccountGetFullName (account, gnc_get_account_separator ());
|
||||||
@ -252,20 +252,21 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
|||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
retval = ddc->retval;
|
retval = ddc->retval;
|
||||||
|
g_list_free (ddc->acct_types);
|
||||||
g_free (ddc);
|
g_free (ddc);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||||
const char *ddue_label_message,
|
const char *ddue_label_message,
|
||||||
const char *post_label_message,
|
const char *post_label_message,
|
||||||
const char *acct_label_message,
|
const char *acct_label_message,
|
||||||
gboolean ok_is_default,
|
gboolean ok_is_default,
|
||||||
GNCAccountType acct_type, GNCBook *book,
|
GList * acct_types, GNCBook *book,
|
||||||
/* Returned Data... */
|
/* Returned Data... */
|
||||||
Timespec *ddue, Timespec *post, Account **acct)
|
Timespec *ddue, Timespec *post, Account **acct)
|
||||||
{
|
{
|
||||||
DialogDateClose *ddc;
|
DialogDateClose *ddc;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
@ -274,14 +275,14 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
|||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
if (!message || !ddue_label_message || !post_label_message ||
|
if (!message || !ddue_label_message || !post_label_message ||
|
||||||
!acct_label_message || !book || !ddue || !post || !acct)
|
!acct_label_message || !acct_types || !book || !ddue || !post || !acct)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
ddc = g_new0 (DialogDateClose, 1);
|
ddc = g_new0 (DialogDateClose, 1);
|
||||||
ddc->ts = ddue;
|
ddc->ts = ddue;
|
||||||
ddc->ts2 = post;
|
ddc->ts2 = post;
|
||||||
ddc->book = book;
|
ddc->book = book;
|
||||||
ddc->acct_type = acct_type;
|
ddc->acct_types = acct_types;
|
||||||
|
|
||||||
xml = gnc_glade_xml_new ("date-close.glade", "Date Account Dialog");
|
xml = gnc_glade_xml_new ("date-close.glade", "Date Account Dialog");
|
||||||
ddc->dialog = glade_xml_get_widget (xml, "Date Account Dialog");
|
ddc->dialog = glade_xml_get_widget (xml, "Date Account Dialog");
|
||||||
@ -332,3 +333,75 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
||||||
|
const char *date_label_message,
|
||||||
|
const char *acct_label_message,
|
||||||
|
gboolean ok_is_default,
|
||||||
|
GList * acct_types, GNCBook *book,
|
||||||
|
/* Returned Data... */
|
||||||
|
Timespec *date, Account **acct)
|
||||||
|
{
|
||||||
|
DialogDateClose *ddc;
|
||||||
|
GtkWidget *hbox;
|
||||||
|
GtkWidget *label;
|
||||||
|
GladeXML *xml;
|
||||||
|
gboolean retval;
|
||||||
|
|
||||||
|
if (!message || !date_label_message || !acct_label_message ||
|
||||||
|
!acct_types || !book || !date || !acct)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
ddc = g_new0 (DialogDateClose, 1);
|
||||||
|
ddc->ts = date;
|
||||||
|
ddc->book = book;
|
||||||
|
ddc->acct_types = acct_types;
|
||||||
|
|
||||||
|
xml = gnc_glade_xml_new ("date-close.glade", "Date Account Dialog");
|
||||||
|
ddc->dialog = glade_xml_get_widget (xml, "Date Account Dialog");
|
||||||
|
ddc->date = glade_xml_get_widget (xml, "date");
|
||||||
|
ddc->acct_combo = glade_xml_get_widget (xml, "acct_combo");
|
||||||
|
hbox = glade_xml_get_widget (xml, "the_hbox");
|
||||||
|
|
||||||
|
if (parent)
|
||||||
|
gnome_dialog_set_parent (GNOME_DIALOG(ddc->dialog), GTK_WINDOW(parent));
|
||||||
|
|
||||||
|
build_date_close_window (hbox, message);
|
||||||
|
|
||||||
|
/* Set the labels */
|
||||||
|
label = glade_xml_get_widget (xml, "date_label");
|
||||||
|
gtk_label_set_text (GTK_LABEL (label), date_label_message);
|
||||||
|
label = glade_xml_get_widget (xml, "acct_label");
|
||||||
|
gtk_label_set_text (GTK_LABEL (label), acct_label_message);
|
||||||
|
|
||||||
|
/* Set the date widget */
|
||||||
|
gnome_date_edit_set_time (GNOME_DATE_EDIT (ddc->date), date->tv_sec);
|
||||||
|
|
||||||
|
/* Setup the account widget */
|
||||||
|
fill_in_acct_info (ddc);
|
||||||
|
|
||||||
|
/* Connect the buttons */
|
||||||
|
gnome_dialog_button_connect
|
||||||
|
(GNOME_DIALOG(ddc->dialog), 0,
|
||||||
|
GTK_SIGNAL_FUNC(gnc_dialog_date_close_ok_cb), ddc);
|
||||||
|
gnome_dialog_button_connect
|
||||||
|
(GNOME_DIALOG(ddc->dialog), 1,
|
||||||
|
GTK_SIGNAL_FUNC(gnc_dialog_date_close_cancel_cb), ddc);
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT(ddc->dialog), "close",
|
||||||
|
GTK_SIGNAL_FUNC(gnc_dialog_date_close_cb), ddc);
|
||||||
|
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (ddc->dialog), TRUE);
|
||||||
|
gtk_widget_show (ddc->dialog);
|
||||||
|
|
||||||
|
gtk_widget_hide_all (glade_xml_get_widget (xml, "postdate_label"));
|
||||||
|
gtk_widget_hide_all (glade_xml_get_widget (xml, "post_date"));
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
|
|
||||||
|
retval = ddc->retval;
|
||||||
|
*acct = ddc->acct;
|
||||||
|
g_free (ddc);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
@ -19,15 +19,29 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
|||||||
Timespec *date);
|
Timespec *date);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note that the dialog will "own" (and free) the acct_types list.
|
||||||
|
* it should be a list of GNCAccountTypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||||
|
const char *ddue_label_message,
|
||||||
|
const char *post_label_message,
|
||||||
|
const char *acct_label_message,
|
||||||
|
gboolean ok_is_default,
|
||||||
|
GList * acct_types, GNCBook *book,
|
||||||
|
/* Returned Data... */
|
||||||
|
Timespec *ddue, Timespec *post,
|
||||||
|
Account **acct);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
||||||
const char *ddue_label_message,
|
const char *date_label_message,
|
||||||
const char *post_label_message,
|
|
||||||
const char *acct_label_message,
|
const char *acct_label_message,
|
||||||
gboolean ok_is_default,
|
gboolean ok_is_default,
|
||||||
GNCAccountType acct_type, GNCBook *book,
|
GList * acct_types, GNCBook *book,
|
||||||
/* Returned Data... */
|
/* Returned Data... */
|
||||||
Timespec *ddue, Timespec *post, Account **acct);
|
Timespec *date, Account **acct);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _DIALOG_DATE_CLOSE_H */
|
#endif /* _DIALOG_DATE_CLOSE_H */
|
||||||
|
@ -206,7 +206,7 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
|
|||||||
GncInvoice *invoice;
|
GncInvoice *invoice;
|
||||||
char *message, *ddue_label, *post_label, *acct_label;
|
char *message, *ddue_label, *post_label, *acct_label;
|
||||||
Account *acc = NULL;
|
Account *acc = NULL;
|
||||||
GNCAccountType acct_type;
|
GList * acct_types = NULL;
|
||||||
Timespec ddue, postdate;
|
Timespec ddue, postdate;
|
||||||
gboolean reverse = FALSE;
|
gboolean reverse = FALSE;
|
||||||
|
|
||||||
@ -218,8 +218,8 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
|
|||||||
if (!invoice)
|
if (!invoice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Ok, we can close this. Ask for verification, set the closed date,
|
/* Ok, we can post this invoice. Ask for verification, set the due date,
|
||||||
* due date, and posted account
|
* post date, and posted account
|
||||||
*/
|
*/
|
||||||
message = _("Do you really want to post the invoice?");
|
message = _("Do you really want to post the invoice?");
|
||||||
ddue_label = _("Due Date");
|
ddue_label = _("Due Date");
|
||||||
@ -229,22 +229,22 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
|
|||||||
/* Determine the type of account to post to */
|
/* Determine the type of account to post to */
|
||||||
switch (gncOwnerGetType (&(iw->owner))) {
|
switch (gncOwnerGetType (&(iw->owner))) {
|
||||||
case GNC_OWNER_CUSTOMER:
|
case GNC_OWNER_CUSTOMER:
|
||||||
acct_type = RECEIVABLE;
|
acct_types = g_list_prepend (NULL, (gpointer)RECEIVABLE);
|
||||||
reverse = TRUE;
|
reverse = TRUE;
|
||||||
break;
|
break;
|
||||||
case GNC_OWNER_VENDOR:
|
case GNC_OWNER_VENDOR:
|
||||||
acct_type = PAYABLE;
|
acct_types = g_list_prepend (NULL, (gpointer)PAYABLE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
acct_type = NO_TYPE;
|
acct_types = g_list_prepend (NULL, (gpointer)NO_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the due date and posted account */
|
/* Get the due date and posted account */
|
||||||
timespecFromTime_t (&postdate, time(NULL));
|
timespecFromTime_t (&postdate, time(NULL));
|
||||||
ddue = postdate;
|
ddue = postdate;
|
||||||
ddue.tv_sec += 3600*24*30; /* XXX: due in 30 days */
|
ddue.tv_sec += 3600*24*30; /* XXX: due in 30 days */
|
||||||
if (!gnc_dialog_date_acct_parented (iw->dialog, message, ddue_label,
|
if (!gnc_dialog_dates_acct_parented (iw->dialog, message, ddue_label,
|
||||||
post_label, acct_label, TRUE, acct_type,
|
post_label, acct_label, TRUE, acct_types,
|
||||||
iw->book, &ddue, &postdate, &acc))
|
iw->book, &ddue, &postdate, &acc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -269,30 +269,45 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_invoice_window_close_invoice_cb (GtkWidget *widget, gpointer data)
|
gnc_invoice_window_pay_invoice_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
InvoiceWindow *iw = data;
|
InvoiceWindow *iw = data;
|
||||||
GncInvoice *invoice;
|
GncInvoice *invoice;
|
||||||
char *message, *label;
|
char *message, *date_label, *acct_label;
|
||||||
Timespec ts;
|
GList *acct_types;
|
||||||
|
Timespec paid_date;
|
||||||
|
Account *acc = NULL;
|
||||||
|
|
||||||
/* Note that this assumes we're already posted! Should we check? */
|
/* Note that this assumes we're already posted! Should we check?
|
||||||
|
* There shuldn't be any way to get to this callback unless we're
|
||||||
|
* already posted.
|
||||||
|
*/
|
||||||
|
|
||||||
invoice = iw_get_invoice (iw);
|
invoice = iw_get_invoice (iw);
|
||||||
if (!invoice)
|
if (!invoice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
message = _("Do you really want to close the invoice?");
|
message = _("Do you really want to pay the invoice?");
|
||||||
label = _("Closed Date");
|
date_label = _("Date Paid");
|
||||||
|
acct_label = _("Pay to Account");
|
||||||
|
|
||||||
timespecFromTime_t (&ts, time(NULL));
|
/* Add "appropriate" accounts */
|
||||||
if (!gnc_dialog_date_close_parented (iw->dialog, message, label, TRUE, &ts))
|
acct_types = g_list_prepend (NULL, BANK);
|
||||||
|
acct_types = g_list_prepend (acct_types, CASH);
|
||||||
|
acct_types = g_list_prepend (acct_types, ASSET);
|
||||||
|
acct_types = g_list_prepend (acct_types, LIABILITY);
|
||||||
|
|
||||||
|
timespecFromTime_t (&paid_date, time(NULL));
|
||||||
|
if (!gnc_dialog_date_acct_parented (iw->dialog, message, date_label,
|
||||||
|
acct_label, TRUE, acct_types,
|
||||||
|
iw->book, &paid_date, &acc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gncInvoiceSetDateClosed (invoice, &ts);
|
/* Pay to the account now */
|
||||||
|
gncInvoicePayToAccount (invoice, acc, &paid_date);
|
||||||
|
|
||||||
/* And close the invoice */
|
/* ... and redisplay here. */
|
||||||
return gnc_invoice_window_ok_cb (widget, data);
|
gnc_invoice_update_window (iw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -415,18 +430,19 @@ gnc_configure_register_colors (void)
|
|||||||
static void
|
static void
|
||||||
gnc_invoice_update_window (InvoiceWindow *iw)
|
gnc_invoice_update_window (InvoiceWindow *iw)
|
||||||
{
|
{
|
||||||
GtkWidget *closed_date, *due_date, *acct_entry;
|
GtkWidget *paid_date, *posted_date, *due_date, *acct_entry;
|
||||||
GncInvoice *invoice;
|
GncInvoice *invoice;
|
||||||
GncOwner *owner;
|
GncOwner *owner;
|
||||||
gboolean is_posted = FALSE;
|
gboolean is_posted = FALSE;
|
||||||
gboolean is_closed = FALSE;
|
gboolean is_paid = FALSE;
|
||||||
|
|
||||||
invoice = iw_get_invoice (iw);
|
invoice = iw_get_invoice (iw);
|
||||||
owner = gncInvoiceGetOwner (invoice);
|
owner = gncInvoiceGetOwner (invoice);
|
||||||
|
|
||||||
gtk_widget_show_all (iw->dialog);
|
gtk_widget_show_all (iw->dialog);
|
||||||
|
|
||||||
closed_date = glade_xml_get_widget (iw->xml, "closed_date");
|
paid_date = glade_xml_get_widget (iw->xml, "paid_date");
|
||||||
|
posted_date = glade_xml_get_widget (iw->xml, "posted_date");
|
||||||
due_date = glade_xml_get_widget (iw->xml, "due_date");
|
due_date = glade_xml_get_widget (iw->xml, "due_date");
|
||||||
acct_entry = glade_xml_get_widget (iw->xml, "acct_entry");
|
acct_entry = glade_xml_get_widget (iw->xml, "acct_entry");
|
||||||
|
|
||||||
@ -473,50 +489,57 @@ gnc_invoice_update_window (InvoiceWindow *iw)
|
|||||||
ts = gncInvoiceGetDateDue (invoice);
|
ts = gncInvoiceGetDateDue (invoice);
|
||||||
gnome_date_edit_set_time (GNOME_DATE_EDIT (due_date), ts.tv_sec);
|
gnome_date_edit_set_time (GNOME_DATE_EDIT (due_date), ts.tv_sec);
|
||||||
|
|
||||||
|
ts = gncInvoiceGetDatePosted (invoice);
|
||||||
|
gnome_date_edit_set_time (GNOME_DATE_EDIT (posted_date), ts.tv_sec);
|
||||||
|
|
||||||
string = xaccAccountGetFullName (acct, gnc_get_account_separator ());
|
string = xaccAccountGetFullName (acct, gnc_get_account_separator ());
|
||||||
gtk_entry_set_text (GTK_ENTRY (acct_entry), string);
|
gtk_entry_set_text (GTK_ENTRY (acct_entry), string);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if we're closed. By closed, we'll have an actual
|
* Check if we're paid. By paid, we'll have an actual
|
||||||
* closed-date as well as everything else. Note that you can be
|
* paid-date as well as everything else. Note that you can be
|
||||||
* posted without being closed, but not the reverse. Perhaps
|
* posted without being paid, but not the reverse.
|
||||||
* "closed" should be renamed to "paid"?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ts = gncInvoiceGetDateClosed (invoice);
|
ts = gncInvoiceGetDatePaid (invoice);
|
||||||
if (timespec_equal (&ts, &ts_zero))
|
if (timespec_equal (&ts, &ts_zero))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
is_closed = TRUE;
|
is_paid = TRUE;
|
||||||
gnome_date_edit_set_time (GNOME_DATE_EDIT (closed_date), ts.tv_sec);
|
gnome_date_edit_set_time (GNOME_DATE_EDIT (paid_date), ts.tv_sec);
|
||||||
|
|
||||||
} while (FALSE);
|
} while (FALSE);
|
||||||
|
|
||||||
/* Hide/show the appropriate widgets based on our posted/closed state */
|
/* Hide/show the appropriate widgets based on our posted/paid state */
|
||||||
|
|
||||||
if (is_closed == FALSE) {
|
if (is_paid == FALSE) {
|
||||||
GtkWidget *hide;
|
GtkWidget *hide;
|
||||||
|
|
||||||
hide = glade_xml_get_widget (iw->xml, "cd_label");
|
hide = glade_xml_get_widget (iw->xml, "paid_label");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
gtk_widget_hide_all (closed_date);
|
gtk_widget_hide_all (paid_date);
|
||||||
|
|
||||||
hide = glade_xml_get_widget (iw->xml, "hide1");
|
if (is_posted == TRUE) {
|
||||||
gtk_widget_hide_all (hide);
|
hide = glade_xml_get_widget (iw->xml, "hide1");
|
||||||
hide = glade_xml_get_widget (iw->xml, "hide2");
|
gtk_widget_hide_all (hide);
|
||||||
gtk_widget_hide_all (hide);
|
hide = glade_xml_get_widget (iw->xml, "hide2");
|
||||||
|
gtk_widget_hide_all (hide);
|
||||||
|
|
||||||
if (is_posted == FALSE) {
|
} else { /* ! posted */
|
||||||
hide = glade_xml_get_widget (iw->xml, "dd_label");
|
hide = glade_xml_get_widget (iw->xml, "due_label");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
gtk_widget_hide_all (due_date);
|
gtk_widget_hide_all (due_date);
|
||||||
|
|
||||||
|
hide = glade_xml_get_widget (iw->xml, "posted_label");
|
||||||
|
gtk_widget_hide_all (hide);
|
||||||
|
gtk_widget_hide_all (posted_date);
|
||||||
|
|
||||||
hide = glade_xml_get_widget (iw->xml, "acct_label");
|
hide = glade_xml_get_widget (iw->xml, "acct_label");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
gtk_widget_hide_all (acct_entry);
|
gtk_widget_hide_all (acct_entry);
|
||||||
|
|
||||||
/* hide the close invoice button -- it needs to be posted first! */
|
/* hide the close invoice button -- it needs to be posted first! */
|
||||||
hide = glade_xml_get_widget (iw->xml, "close_invoice_button");
|
hide = glade_xml_get_widget (iw->xml, "pay_invoice_button");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
|
|
||||||
/* Also hide the print invoice button, for the same reason */
|
/* Also hide the print invoice button, for the same reason */
|
||||||
@ -534,12 +557,16 @@ gnc_invoice_update_window (InvoiceWindow *iw)
|
|||||||
gtk_widget_set_sensitive (iw->opened_date, FALSE);
|
gtk_widget_set_sensitive (iw->opened_date, FALSE);
|
||||||
gtk_widget_set_sensitive (iw->notes_text, FALSE); /* XXX: should notes remain writable? */
|
gtk_widget_set_sensitive (iw->notes_text, FALSE); /* XXX: should notes remain writable? */
|
||||||
|
|
||||||
/* Hide the 'post invoice' button: "VIEW" implies is_posted */
|
/* Hide the 'post invoice' button */
|
||||||
hide = glade_xml_get_widget (iw->xml, "post_invoice_button");
|
hide = glade_xml_get_widget (iw->xml, "post_invoice_button");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
|
|
||||||
if (is_closed) {
|
/* Hide the 'cancel' button */
|
||||||
hide = glade_xml_get_widget (iw->xml, "close_invoice_button");
|
hide = glade_xml_get_widget (iw->xml, "cancel_button");
|
||||||
|
gtk_widget_hide_all (hide);
|
||||||
|
|
||||||
|
if (is_paid) {
|
||||||
|
hide = glade_xml_get_widget (iw->xml, "pay_invoice_button");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -647,7 +674,7 @@ gnc_invoice_new_window (GtkWidget *parent, GNCBook *bookp,
|
|||||||
(iwd, 4, GTK_SIGNAL_FUNC(gnc_invoice_window_post_invoice_cb), iw);
|
(iwd, 4, GTK_SIGNAL_FUNC(gnc_invoice_window_post_invoice_cb), iw);
|
||||||
|
|
||||||
gnome_dialog_button_connect
|
gnome_dialog_button_connect
|
||||||
(iwd, 5, GTK_SIGNAL_FUNC(gnc_invoice_window_close_invoice_cb), iw);
|
(iwd, 5, GTK_SIGNAL_FUNC(gnc_invoice_window_pay_invoice_cb), iw);
|
||||||
|
|
||||||
/* Setup initial values */
|
/* Setup initial values */
|
||||||
iw->invoice_guid = *gncInvoiceGetGUID (invoice);
|
iw->invoice_guid = *gncInvoiceGetGUID (invoice);
|
||||||
|
@ -589,6 +589,8 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
|
|||||||
/* Hide the 'close order' button */
|
/* Hide the 'close order' button */
|
||||||
hide = glade_xml_get_widget (xml, "close_order_button");
|
hide = glade_xml_get_widget (xml, "close_order_button");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
|
hide = glade_xml_get_widget (xml, "cancel_button");
|
||||||
|
gtk_widget_hide_all (hide);
|
||||||
hide = glade_xml_get_widget (xml, "new_invoice_button");
|
hide = glade_xml_get_widget (xml, "new_invoice_button");
|
||||||
gtk_widget_hide_all (hide);
|
gtk_widget_hide_all (hide);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkButton</class>
|
<class>GtkButton</class>
|
||||||
<name>button2</name>
|
<name>cancel_button</name>
|
||||||
<can_default>True</can_default>
|
<can_default>True</can_default>
|
||||||
<can_focus>True</can_focus>
|
<can_focus>True</can_focus>
|
||||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||||
@ -101,10 +101,10 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkButton</class>
|
<class>GtkButton</class>
|
||||||
<name>close_invoice_button</name>
|
<name>pay_invoice_button</name>
|
||||||
<can_default>True</can_default>
|
<can_default>True</can_default>
|
||||||
<can_focus>True</can_focus>
|
<can_focus>True</can_focus>
|
||||||
<label>Close Invoice</label>
|
<label>Pay Invoice</label>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
@ -195,8 +195,8 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<name>dd_label</name>
|
<name>posted_label</name>
|
||||||
<label>Date Due</label>
|
<label>Date Posted</label>
|
||||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||||
<wrap>False</wrap>
|
<wrap>False</wrap>
|
||||||
<xalign>1</xalign>
|
<xalign>1</xalign>
|
||||||
@ -212,8 +212,8 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<name>cd_label</name>
|
<name>paid_label</name>
|
||||||
<label>Date Closed</label>
|
<label>Date Paid</label>
|
||||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||||
<wrap>False</wrap>
|
<wrap>False</wrap>
|
||||||
<xalign>1</xalign>
|
<xalign>1</xalign>
|
||||||
@ -288,7 +288,7 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GnomeDateEdit</class>
|
<class>GnomeDateEdit</class>
|
||||||
<name>due_date</name>
|
<name>posted_date</name>
|
||||||
<sensitive>False</sensitive>
|
<sensitive>False</sensitive>
|
||||||
<show_time>False</show_time>
|
<show_time>False</show_time>
|
||||||
<use_24_format>False</use_24_format>
|
<use_24_format>False</use_24_format>
|
||||||
@ -304,7 +304,7 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GnomeDateEdit</class>
|
<class>GnomeDateEdit</class>
|
||||||
<name>closed_date</name>
|
<name>paid_date</name>
|
||||||
<sensitive>False</sensitive>
|
<sensitive>False</sensitive>
|
||||||
<show_time>False</show_time>
|
<show_time>False</show_time>
|
||||||
<use_24_format>False</use_24_format>
|
<use_24_format>False</use_24_format>
|
||||||
@ -417,11 +417,11 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<name>hide1</name>
|
<name>due_label</name>
|
||||||
<label></label>
|
<label>Date Due</label>
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||||
<wrap>False</wrap>
|
<wrap>False</wrap>
|
||||||
<xalign>0.5</xalign>
|
<xalign>1</xalign>
|
||||||
<yalign>0.5</yalign>
|
<yalign>0.5</yalign>
|
||||||
<xpad>0</xpad>
|
<xpad>0</xpad>
|
||||||
<ypad>0</ypad>
|
<ypad>0</ypad>
|
||||||
@ -434,7 +434,7 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<name>label11</name>
|
<name>hide1</name>
|
||||||
<label></label>
|
<label></label>
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||||
<wrap>False</wrap>
|
<wrap>False</wrap>
|
||||||
@ -508,15 +508,14 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GnomeDateEdit</class>
|
||||||
<name>hide2</name>
|
<name>due_date</name>
|
||||||
<label></label>
|
<sensitive>False</sensitive>
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
<show_time>False</show_time>
|
||||||
<wrap>False</wrap>
|
<use_24_format>False</use_24_format>
|
||||||
<xalign>0.5</xalign>
|
<week_start_monday>False</week_start_monday>
|
||||||
<yalign>0.5</yalign>
|
<lower_hour>7</lower_hour>
|
||||||
<xpad>0</xpad>
|
<upper_hour>19</upper_hour>
|
||||||
<ypad>0</ypad>
|
|
||||||
<child>
|
<child>
|
||||||
<padding>0</padding>
|
<padding>0</padding>
|
||||||
<expand>False</expand>
|
<expand>False</expand>
|
||||||
@ -526,7 +525,7 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<name>label12</name>
|
<name>hide2</name>
|
||||||
<label></label>
|
<label></label>
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||||
<wrap>False</wrap>
|
<wrap>False</wrap>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkButton</class>
|
<class>GtkButton</class>
|
||||||
<name>button2</name>
|
<name>cancel_button</name>
|
||||||
<can_default>True</can_default>
|
<can_default>True</can_default>
|
||||||
<can_focus>True</can_focus>
|
<can_focus>True</can_focus>
|
||||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||||
|
@ -172,8 +172,6 @@ option_changed (GtkWidget *widget, GNCSearchDate *fe)
|
|||||||
static void
|
static void
|
||||||
date_changed (GNCDateEdit *date_edit, GNCSearchDate *fe)
|
date_changed (GNCDateEdit *date_edit, GNCSearchDate *fe)
|
||||||
{
|
{
|
||||||
time_t tt;
|
|
||||||
|
|
||||||
fe->ts = gnc_date_edit_get_date_ts (date_edit);
|
fe->ts = gnc_date_edit_get_date_ts (date_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +148,15 @@ gnc_search_param_set_param_path (GNCSearchParam *param,
|
|||||||
param->priv->type = type;
|
param->priv->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gnc_search_param_override_param_type (GNCSearchParam *param,
|
||||||
|
GNCIdTypeConst *param_type)
|
||||||
|
{
|
||||||
|
g_assert (IS_GNCSEARCH_PARAM (param));
|
||||||
|
g_assert (param_type != NULL && *param_type != '\0');
|
||||||
|
param->priv->type = param_type;
|
||||||
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
gnc_search_param_get_param_path (GNCSearchParam *param)
|
gnc_search_param_get_param_path (GNCSearchParam *param)
|
||||||
{
|
{
|
||||||
|
@ -47,4 +47,14 @@ void gnc_search_param_set_title (GNCSearchParam *param,
|
|||||||
gboolean gnc_search_param_type_match (GNCSearchParam *a,
|
gboolean gnc_search_param_type_match (GNCSearchParam *a,
|
||||||
GNCSearchParam *b);
|
GNCSearchParam *b);
|
||||||
|
|
||||||
|
|
||||||
|
/* This will override the automatic param_type logic from "set_param_path()"
|
||||||
|
* so that the programmer can force a particular UI to appear for a given
|
||||||
|
* parameter path. This should be used with care -- if used improperly
|
||||||
|
* it could result in an invalid Query Term, where the path and the predicate
|
||||||
|
* don't match types properly.
|
||||||
|
*/
|
||||||
|
void gnc_search_param_override_param_type (GNCSearchParam *param,
|
||||||
|
GNCIdTypeConst *param_type);
|
||||||
|
|
||||||
#endif /* _GNCSEARCH_PARAM_H */
|
#endif /* _GNCSEARCH_PARAM_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user