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.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16720 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2007-12-25 16:56:35 +00:00
parent 3b983ff5cb
commit 238141c6c4
3 changed files with 24 additions and 4 deletions

View File

@ -1623,7 +1623,22 @@ gboolean gncInvoiceRegister (void)
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;
}

View File

@ -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);

View File

@ -344,8 +344,12 @@ gnc_invoice_window_verify_ok (InvoiceWindow *iw)
/* 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);
}