r16720 - gnucash/trunk/src/business - Maintain separate invoice number sequences for AR and AP (#327218)
Derek Atkins
warlord at cvs.gnucash.org
Tue Dec 25 11:56:35 EST 2007
Author: warlord
Date: 2007-12-25 11:56:35 -0500 (Tue, 25 Dec 2007)
New Revision: 16720
Trac: http://svn.gnucash.org/trac/changeset/16720
Modified:
gnucash/trunk/src/business/business-core/gncInvoice.c
gnucash/trunk/src/business/business-core/gncInvoiceP.h
gnucash/trunk/src/business/business-gnome/dialog-invoice.c
Log:
Maintain separate invoice number sequences for AR and AP (#327218)
Actually, maintain separate number sequences for Customer Invoices,
Vendor Bills, and Employee Expense Vouchers. Support Jobs, too.
Based on a patch by Alex Prinsier.
Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c 2007-12-25 16:47:50 UTC (rev 16719)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c 2007-12-25 16:56:35 UTC (rev 16720)
@@ -1623,7 +1623,22 @@
return qof_object_register (&gncInvoiceDesc);
}
-gint64 gncInvoiceNextID (QofBook *book)
+gint64 gncInvoiceNextID (QofBook *book, GncOwner *owner)
{
- return qof_book_get_counter (book, _GNC_MOD_NAME);
+ gint64 nextID;
+ switch(gncOwnerGetType(gncOwnerGetEndOwner(owner))) {
+ case GNC_OWNER_CUSTOMER:
+ nextID = qof_book_get_counter (book, "gncInvoice");
+ break;
+ case GNC_OWNER_VENDOR:
+ nextID = qof_book_get_counter (book, "gncBill");
+ break;
+ case GNC_OWNER_EMPLOYEE:
+ nextID = qof_book_get_counter (book, "gncExpVoucher");
+ break;
+ default:
+ nextID = qof_book_get_counter (book, _GNC_MOD_NAME);
+ break;
+ }
+ return nextID;
}
Modified: gnucash/trunk/src/business/business-core/gncInvoiceP.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoiceP.h 2007-12-25 16:47:50 UTC (rev 16719)
+++ gnucash/trunk/src/business/business-core/gncInvoiceP.h 2007-12-25 16:56:35 UTC (rev 16720)
@@ -32,9 +32,10 @@
#include "Account.h"
#include "Transaction.h"
#include "gnc-lot.h"
+#include "gncOwner.h"
gboolean gncInvoiceRegister (void);
-gint64 gncInvoiceNextID (QofBook *book);
+gint64 gncInvoiceNextID (QofBook *book, GncOwner *owner);
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc);
void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn);
void gncInvoiceSetPostedLot (GncInvoice *invoice, GNCLot *lot);
Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2007-12-25 16:47:50 UTC (rev 16719)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2007-12-25 16:56:35 UTC (rev 16720)
@@ -344,8 +344,12 @@
/* Check the ID; set one if necessary */
res = gtk_entry_get_text (GTK_ENTRY (iw->id_entry));
if (safe_strcmp (res, "") == 0) {
+ /* Invoices and bills have separate counters.
+ Therefore we pass the GncOwer to gncInvoiceNextID
+ so it knows whether we are creating a bill
+ or an invoice. */
string = g_strdup_printf ("%.6" G_GINT64_FORMAT,
- gncInvoiceNextID(iw->book));
+ gncInvoiceNextID(iw->book, &(iw->owner)));
gtk_entry_set_text (GTK_ENTRY (iw->id_entry), string);
g_free(string);
}
More information about the gnucash-changes
mailing list