mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Abort posting if not all required exchange rates are given.
Note that any exchange rate successfully entered before the posting is aborted are still saved with the invoice. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21712 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f69313f874
commit
89eaf45a7d
@ -658,6 +658,7 @@ gnc_invoice_window_postCB (GtkWidget *unused_widget, gpointer data)
|
||||
GncEntry* entry;
|
||||
gboolean reverse;
|
||||
gboolean show_dialog = TRUE;
|
||||
gboolean post_ok = TRUE;
|
||||
|
||||
/* Make sure the invoice is ok */
|
||||
if (!gnc_invoice_window_verify_ok (iw))
|
||||
@ -801,46 +802,64 @@ gnc_invoice_window_postCB (GtkWidget *unused_widget, gpointer data)
|
||||
gnc_xfer_dialog_hide_from_account_tree(xfer);
|
||||
gnc_xfer_dialog_hide_to_account_tree(xfer);
|
||||
gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate);
|
||||
gnc_xfer_dialog_run_until_done(xfer);
|
||||
if (gnc_xfer_dialog_run_until_done(xfer))
|
||||
{
|
||||
/* User finished the transfer dialog successfully */
|
||||
convprice = gnc_price_create(iw->book);
|
||||
gnc_price_begin_edit (convprice);
|
||||
gnc_price_set_commodity (convprice, xaccAccountGetCommodity(this_acc));
|
||||
gnc_price_set_currency (convprice, gncInvoiceGetCurrency (invoice));
|
||||
date.tv_sec = time (NULL);
|
||||
date.tv_nsec = 0;
|
||||
gnc_price_set_time (convprice, date);
|
||||
gnc_price_set_source (convprice, "user:invoice-post");
|
||||
|
||||
convprice = gnc_price_create(iw->book);
|
||||
gnc_price_begin_edit (convprice);
|
||||
gnc_price_set_commodity (convprice, xaccAccountGetCommodity(this_acc));
|
||||
gnc_price_set_currency (convprice, gncInvoiceGetCurrency (invoice));
|
||||
date.tv_sec = time (NULL);
|
||||
date.tv_nsec = 0;
|
||||
gnc_price_set_time (convprice, date);
|
||||
gnc_price_set_source (convprice, "user:invoice-post");
|
||||
|
||||
/* Yes, magic strings are evil but I can't find any defined constants
|
||||
for this..*/
|
||||
gnc_price_set_typestr (convprice, "last");
|
||||
gnc_price_set_value (convprice, exch_rate);
|
||||
gncInvoiceAddPrice(invoice, convprice);
|
||||
gnc_price_commit_edit (convprice);
|
||||
/* Yes, magic strings are evil but I can't find any defined constants
|
||||
for this..*/
|
||||
gnc_price_set_typestr (convprice, "last");
|
||||
gnc_price_set_value (convprice, exch_rate);
|
||||
gncInvoiceAddPrice(invoice, convprice);
|
||||
gnc_price_commit_edit (convprice);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* User canceled the transfer dialog, abort posting */
|
||||
post_ok = FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Save acc as last used account in the kvp frame of the invoice owner */
|
||||
/* Save account as last used account in the kvp frame of the invoice owner */
|
||||
kvp_val = kvp_value_new_guid (qof_instance_get_guid (QOF_INSTANCE (acc)));;
|
||||
qof_begin_edit (owner_inst);
|
||||
kvp_frame_set_slot_nc (kvpf, LAST_POSTED_TO_ACCT, kvp_val);
|
||||
qof_instance_set_dirty (owner_inst);
|
||||
qof_commit_edit (owner_inst);
|
||||
|
||||
/* ... post it; post date is set to now ... */
|
||||
/* ... post it ... */
|
||||
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, accumulate);
|
||||
|
||||
cleanup:
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
if (memo)
|
||||
g_free (memo);
|
||||
|
||||
/* Reset the type; change to read-only! */
|
||||
iw->dialog_type = VIEW_INVOICE;
|
||||
gnc_entry_ledger_set_readonly (iw->ledger, TRUE);
|
||||
if (post_ok)
|
||||
{
|
||||
/* Reset the type; change to read-only! */
|
||||
iw->dialog_type = VIEW_INVOICE;
|
||||
gnc_entry_ledger_set_readonly (iw->ledger, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
text = _("The post action was canceled because not all exchange rates were given.");
|
||||
gnc_info_dialog(iw_get_window(iw), "%s", text);
|
||||
}
|
||||
|
||||
/* ... and redisplay here. */
|
||||
gnc_invoice_update_window (iw, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user