@ -644,7 +644,7 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
KvpFrame * kvpf ;
KvpValue * kvp_val ;
const char * text ;
EntryList * entries ;
EntryList * entries , * entries_iter ;
GncEntry * entry ;
gboolean reverse ;
gboolean show_dialog = TRUE ;
@ -698,8 +698,31 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
/* Determine which commodity we're working with */
acct_commodities = gnc_business_commodities ( & ( iw - > owner ) ) ;
/* Get the invoice entries */
entries = gncInvoiceGetEntries ( invoice ) ;
/* Find the most suitable post date.
* For Customer Invoices that would be today .
* For Vendor Bills and Employee Vouchers
* that would be the date of the most recent invoice entry .
* Failing that , today is used as a fallback */
postdate = timespec_now ( ) ;
if ( entries & & ( ( gncInvoiceGetOwnerType ( invoice ) = = GNC_OWNER_VENDOR ) | |
( gncInvoiceGetOwnerType ( invoice ) = = GNC_OWNER_EMPLOYEE ) ) )
{
postdate = gncEntryGetDate ( ( GncEntry * ) entries - > data ) ;
for ( entries_iter = entries ; entries_iter ! = NULL ; entries_iter = g_list_next ( entries_iter ) )
{
Timespec entrydate ;
entrydate = gncEntryGetDate ( ( GncEntry * ) entries_iter - > data ) ;
if ( timespec_cmp ( & entrydate , & postdate ) > 0 )
postdate = entrydate ;
}
}
/* Get the due date and posted account */
postdate = gncInvoiceGetDateOpened ( invoice ) ;
ddue = postdate ;
memo = NULL ;
@ -728,11 +751,11 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
/* Fill in the conversion prices with feedback from the user */
text = _ ( " One or more of the entries are for accounts different from the invoice/bill currency. You will be asked a conversion rate for each. " ) ;
for ( entries = gncInvoiceGetEntries ( invoice ) ; entries ! = NULL ; entries = g_list_next ( entries ) )
for ( entries _iter = entries ; entries_iter ! = NULL ; entries _iter = g_list_next ( entries _iter ) )
{
Account * this_acc ;
entry = ( GncEntry * ) entries - > data ;
entry = ( GncEntry * ) entries _iter - > data ;
this_acc = ( reverse ? gncEntryGetInvAccount ( entry ) :
gncEntryGetBillAccount ( entry ) ) ;