-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
Invoices and bills were sharing the same counter. Unfortunately it's a
legal requirement in Belgium to have a separate numbering for those.
This patch fixes that. There was already a request for this on bugzilla:
http://bugzilla.gnome.org/show_bug.cgi?id=327218. I attached my patch
there too.
This is my first patch for gnucash. Don't shoot me for forgetting about
something ;)
Please CC me, I'm not on this list.
Alex
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGCHGyrCFWJqEhh1cRAmXuAJwMX3hfBa31LVcebKKCAJIj8h6/7gCbBI0r
TNrDXMr69842tTMBRgGbhVw=
=Yj5l
-----END PGP SIGNATURE-----
Index: src/business/business-core/gncInvoiceP.h
===================================================================
--- src/business/business-core/gncInvoiceP.h (revision 15756)
+++ src/business/business-core/gncInvoiceP.h (working copy)
@@ -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);
Index: src/business/business-core/gncInvoice.c
===================================================================
--- src/business/business-core/gncInvoice.c (revision 15756)
+++ src/business/business-core/gncInvoice.c (working copy)
@@ -1587,7 +1587,19 @@
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(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;
+ default:
+ nextID = qof_book_get_counter (book, _GNC_MOD_NAME);
+ break;
+ }
+ return nextID;
}
Index: src/business/business-gnome/dialog-invoice.c
===================================================================
--- src/business/business-gnome/dialog-invoice.c (revision 15756)
+++ src/business/business-gnome/dialog-invoice.c (working copy)
@@ -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);
}
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel