mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Daniel Lindenaar's patch for posting invoices.
* src/business/business-core/gncInvoice.[ch] * src/business/business-gnome/dialog-date-close.[ch] * src/business/business-gnome/dialog-invoice.c * src/business/business-gnome/glade/date-close.glade * src/business/business-utils/business-prefs.scm Daniel Lindenaar's patch to implement a check-box in the Invoice Post Dialog (with a default in the File Preferences) to choose to accumulate splits when posting an invoice, or post a 1:1 mapping. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10305 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
11b5192d23
commit
a7fa3e05a4
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2004-10-15 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/business/business-core/gncInvoice.[ch]
|
||||
* src/business/business-gnome/dialog-date-close.[ch]
|
||||
* src/business/business-gnome/dialog-invoice.c
|
||||
* src/business/business-gnome/glade/date-close.glade
|
||||
* src/business/business-utils/business-prefs.scm
|
||||
Daniel Lindenaar's patch to implement a check-box in the Invoice Post
|
||||
Dialog (with a default in the File Preferences) to choose to accumulate
|
||||
splits when posting an invoice, or post a 1:1 mapping.
|
||||
|
||||
2004-10-13 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/import-export/qif-import/qif-object.scm:
|
||||
|
@ -612,6 +612,7 @@ gboolean gncInvoiceGetActive (GncInvoice *invoice)
|
||||
return invoice->active;
|
||||
}
|
||||
|
||||
|
||||
gnc_numeric gncInvoiceGetToChargeAmount (GncInvoice *invoice)
|
||||
{
|
||||
if (!invoice) return gnc_numeric_zero();
|
||||
@ -742,7 +743,7 @@ gnc_lot_match_owner_payment (GNCLot *lot, gpointer user_data)
|
||||
|
||||
Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||
Timespec *post_date, Timespec *due_date,
|
||||
const char * memo)
|
||||
const char * memo, gboolean accumulatesplits)
|
||||
{
|
||||
Transaction *txn;
|
||||
GNCLot *lot = NULL;
|
||||
@ -853,7 +854,25 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||
gncEntryGetBillAccount (entry));
|
||||
if (this_acc) {
|
||||
if (gnc_numeric_check (value) == GNC_ERROR_OK) {
|
||||
splitinfo = gncAccountValueAdd (splitinfo, this_acc, value);
|
||||
if (accumulatesplits) {
|
||||
gncAccountValueAdd (splitinfo, this_acc, value);
|
||||
} else {
|
||||
Split *split;
|
||||
|
||||
split = xaccMallocSplit (invoice->inst.book);
|
||||
/* set action and memo? */
|
||||
|
||||
xaccSplitSetMemo (split, gncEntryGetDescription (entry));
|
||||
xaccSplitSetAction (split, type);
|
||||
|
||||
xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (value)
|
||||
: value),
|
||||
invoice->currency);
|
||||
xaccAccountBeginEdit (this_acc);
|
||||
xaccAccountInsertSplit (this_acc, split);
|
||||
xaccAccountCommitEdit (this_acc);
|
||||
xaccTransAppendSplit (txn, split);
|
||||
}
|
||||
|
||||
/* If there is a credit-card account, and this is a CCard
|
||||
* payment type, the don't add it to the total, and instead
|
||||
|
@ -111,7 +111,7 @@ GList * gncInvoiceGetEntries (GncInvoice *invoice);
|
||||
Transaction *
|
||||
gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||
Timespec *posted_date, Timespec *due_date,
|
||||
const char *memo);
|
||||
const char *memo, gboolean accumulatesplits);
|
||||
|
||||
/**
|
||||
* UNpost this invoice. This will destroy the posted transaction and
|
||||
|
@ -42,6 +42,7 @@ typedef struct _dialog_date_close_window {
|
||||
GtkWidget *post_date;
|
||||
GtkWidget *acct_combo;
|
||||
GtkWidget *memo_entry;
|
||||
GtkWidget *question_check;
|
||||
GncBillTerm *terms;
|
||||
Timespec *ts, *ts2;
|
||||
GList * acct_types;
|
||||
@ -49,6 +50,7 @@ typedef struct _dialog_date_close_window {
|
||||
Account *acct;
|
||||
char **memo;
|
||||
gboolean retval;
|
||||
gboolean answer;
|
||||
} DialogDateClose;
|
||||
|
||||
static void
|
||||
@ -83,7 +85,8 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data)
|
||||
if (ddc->memo_entry && ddc->memo)
|
||||
*(ddc->memo) = gtk_editable_get_chars (GTK_EDITABLE (ddc->memo_entry),
|
||||
0, -1);
|
||||
|
||||
if (ddc->question_check)
|
||||
ddc->answer = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ddc->question_check));
|
||||
ddc->retval = TRUE;
|
||||
gnome_dialog_close (GNOME_DIALOG (ddc->dialog));
|
||||
}
|
||||
@ -226,16 +229,17 @@ post_date_changed_cb (GNCDateEdit *gde, gpointer d)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||
gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
|
||||
const char *ddue_label_message,
|
||||
const char *post_label_message,
|
||||
const char *acct_label_message,
|
||||
const char *question_check_message,
|
||||
gboolean ok_is_default,
|
||||
GList * acct_types, GNCBook *book,
|
||||
GncBillTerm *terms,
|
||||
/* Returned Data... */
|
||||
Timespec *ddue, Timespec *post,
|
||||
char **memo, Account **acct)
|
||||
char **memo, Account **acct, gboolean *answer)
|
||||
{
|
||||
DialogDateClose *ddc;
|
||||
GtkWidget *hbox;
|
||||
@ -248,6 +252,8 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||
if (!message || !ddue_label_message || !post_label_message ||
|
||||
!acct_label_message || !acct_types || !book || !ddue || !post || !acct)
|
||||
return FALSE;
|
||||
if (question_check_message && !answer)
|
||||
return FALSE;
|
||||
|
||||
ddc = g_new0 (DialogDateClose, 1);
|
||||
ddc->ts = ddue;
|
||||
@ -274,6 +280,8 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||
ddc->post_date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX(date_box), ddc->post_date, TRUE, TRUE, 0);
|
||||
|
||||
ddc->question_check = glade_xml_get_widget(xml, "question_check");
|
||||
|
||||
if (parent)
|
||||
gnome_dialog_set_parent (GNOME_DIALOG(ddc->dialog), GTK_WINDOW(parent));
|
||||
|
||||
@ -287,6 +295,16 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||
label = glade_xml_get_widget (xml, "acct_label");
|
||||
gtk_label_set_text (GTK_LABEL (label), acct_label_message);
|
||||
|
||||
if (question_check_message)
|
||||
{
|
||||
gtk_label_set_text(GTK_LABEL(GTK_BIN(ddc->question_check)->child), question_check_message);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ddc->question_check), *answer);
|
||||
} else {
|
||||
gtk_widget_hide(ddc->question_check);
|
||||
gtk_widget_hide(glade_xml_get_widget(xml, "hide1"));
|
||||
}
|
||||
|
||||
|
||||
/* Set the post date widget */
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->post_date), *post);
|
||||
|
||||
@ -319,6 +337,8 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||
|
||||
retval = ddc->retval;
|
||||
*acct = ddc->acct;
|
||||
if (question_check_message)
|
||||
*answer = ddc->answer;
|
||||
g_free (ddc);
|
||||
|
||||
return retval;
|
||||
|
@ -44,16 +44,40 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
||||
*/
|
||||
|
||||
gboolean
|
||||
gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
|
||||
gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
|
||||
const char *ddue_label_message,
|
||||
const char *post_label_message,
|
||||
const char *acct_label_message,
|
||||
const char *question_check_message,
|
||||
gboolean ok_is_default,
|
||||
GList * acct_types, GNCBook *book,
|
||||
GncBillTerm *terms,
|
||||
/* Returned Data... */
|
||||
Timespec *ddue, Timespec *post,
|
||||
char **memo, Account **acct);
|
||||
char **memo, Account **acct, gboolean *answer);
|
||||
|
||||
#define gnc_dialog_dates_acct_parented(parent, message, \
|
||||
ddue_label_message, \
|
||||
post_label_message, \
|
||||
acct_label_message, \
|
||||
ok_is_default, \
|
||||
acct_types, book, \
|
||||
terms, \
|
||||
/* Returned Data... */ \
|
||||
ddue, post, \
|
||||
memo, acct) \
|
||||
gnc_dialog_dates_acct_question_parented (parent, message, \
|
||||
ddue_label_message, \
|
||||
post_label_message, \
|
||||
acct_label_message, \
|
||||
NULL, \
|
||||
ok_is_default, \
|
||||
acct_types, book, \
|
||||
terms, \
|
||||
/* Returned Data... */ \
|
||||
ddue, post, \
|
||||
memo, acct, NULL) \
|
||||
|
||||
|
||||
gboolean
|
||||
gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
||||
|
@ -616,10 +616,11 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
InvoiceWindow *iw = data;
|
||||
GncInvoice *invoice;
|
||||
char *message, *memo, *ddue_label, *post_label, *acct_label;
|
||||
char *message, *memo, *ddue_label, *post_label, *acct_label, *question_label;
|
||||
Account *acc = NULL;
|
||||
GList * acct_types = NULL;
|
||||
Timespec ddue, postdate;
|
||||
gboolean accumulate;
|
||||
|
||||
/* Make sure the invoice is ok */
|
||||
if (!gnc_invoice_window_verify_ok (iw))
|
||||
@ -644,6 +645,7 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
|
||||
ddue_label = _("Due Date");
|
||||
post_label = _("Post Date");
|
||||
acct_label = _("Post to Account");
|
||||
question_label = _("Accumulate Splits?");
|
||||
|
||||
/* Determine the type of account to post to */
|
||||
acct_types = gnc_business_account_types (&(iw->owner));
|
||||
@ -653,10 +655,13 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
|
||||
ddue = postdate;
|
||||
memo = NULL;
|
||||
|
||||
if (!gnc_dialog_dates_acct_parented (iw->dialog, message, ddue_label,
|
||||
post_label, acct_label, TRUE,
|
||||
/* Get the default for the accumulate option */
|
||||
accumulate = gnc_lookup_boolean_option("Business", "Accumulate splits on Post?", TRUE);
|
||||
|
||||
if (!gnc_dialog_dates_acct_question_parented (iw->dialog, message, ddue_label,
|
||||
post_label, acct_label, question_label, TRUE,
|
||||
acct_types, iw->book, iw->terms,
|
||||
&ddue, &postdate, &memo, &acc))
|
||||
&ddue, &postdate, &memo, &acc, &accumulate))
|
||||
return;
|
||||
|
||||
/* Yep, we're posting. So, save the invoice...
|
||||
@ -668,7 +673,7 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
|
||||
gnc_invoice_window_ok_save (iw);
|
||||
|
||||
/* ... post it; post date is set to now ... */
|
||||
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo);
|
||||
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, accumulate);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
|
@ -382,6 +382,23 @@
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>hide1</name>
|
||||
<label></label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -457,6 +474,20 @@
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>question_check</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>question</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
|
@ -42,6 +42,15 @@
|
||||
1.0 ;; step size
|
||||
))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-simple-boolean-option
|
||||
gnc:*business-label* (N_ "Accumulate splits on Post?")
|
||||
"f0" (N_ (string-append
|
||||
"Whether multiple entries in an invoice which transfer to "
|
||||
"the same account should be accumulated into a single split by default."
|
||||
"This setting can be changed in the Post dialog."))
|
||||
#t))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-simple-boolean-option
|
||||
gnc:*business-label* (N_ "Invoice Tax Included?")
|
||||
|
Loading…
Reference in New Issue
Block a user