/* Copy the values in the GUI to the financial_info structure */ static void gui_to_fi(FinCalcDialog *fcd) { GtkToggleButton *toggle; gnc_numeric npp; int i; if (fcd == NULL) return; npp = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(fcd->amounts[PAYMENT_PERIODS])); fcd->financial_info.npp = npp.num; fcd->financial_info.ir = gnc_amount_edit_get_damount(GNC_AMOUNT_EDIT(fcd->amounts[INTEREST_RATE])); fcd->financial_info.pv = gnc_amount_edit_get_damount(GNC_AMOUNT_EDIT(fcd->amounts[PRESENT_VALUE])); fcd->financial_info.pmt = gnc_amount_edit_get_damount(GNC_AMOUNT_EDIT(fcd->amounts[PERIODIC_PAYMENT])); fcd->financial_info.fv = gnc_amount_edit_get_damount(GNC_AMOUNT_EDIT(fcd->amounts[FUTURE_VALUE])); fcd->financial_info.fv = -fcd->financial_info.fv; i = gtk_combo_box_get_active(GTK_COMBO_BOX(fcd->compounding_combo)); fcd->financial_info.CF = periods[i]; i = gtk_combo_box_get_active(GTK_COMBO_BOX(fcd->payment_combo)); fcd->financial_info.PF = periods[i]; toggle = GTK_TOGGLE_BUTTON(fcd->end_of_period_radio); fcd->financial_info.bep = !gtk_toggle_button_get_active(toggle); toggle = GTK_TOGGLE_BUTTON(fcd->discrete_compounding_radio); fcd->financial_info.disc = gtk_toggle_button_get_active(toggle); fcd->financial_info.prec = gnc_locale_decimal_places (); }
/** * Create a new AB_TRANSACTION, fill the values from the entry fields into it * and return it. The caller must AB_TRANSACTION_free() it when finished. */ static AB_TRANSACTION * ab_trans_fill_values(GncABTransDialog *td) { /* Fill in the user-entered values */ AB_TRANSACTION *trans = AB_Transaction_new(); AB_VALUE *value; AB_Transaction_SetLocalBankCode(trans, AB_Account_GetBankCode(td->ab_acc)); AB_Transaction_SetLocalAccountNumber( trans, AB_Account_GetAccountNumber(td->ab_acc)); AB_Transaction_SetLocalCountry(trans, "DE"); AB_Transaction_SetRemoteBankCode( trans, gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry))); AB_Transaction_SetRemoteAccountNumber( trans, gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry))); AB_Transaction_SetRemoteCountry(trans, "DE"); AB_Transaction_AddRemoteName( trans, gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont2_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont3_entry)), FALSE); value = AB_Value_fromDouble(gnc_amount_edit_get_damount( GNC_AMOUNT_EDIT(td->amount_edit))); /* FIXME: Replace "EUR" by account-dependent string here. */ AB_Value_SetCurrency(value, "EUR"); AB_Transaction_SetValue(trans, value); AB_Value_free(value); /* If this is a direct debit, a textkey/ "Textschluessel"/transactionCode * different from the default has to be set. */ switch (td->trans_type) { case SINGLE_DEBITNOTE: /* AB_Transaction_SetTransactionCode (trans, 05); */ AB_Transaction_SetTextKey(trans, 05); break; default: /* AB_Transaction_SetTransactionCode (trans, 51); */ AB_Transaction_SetTextKey (trans, 51); break; } return trans; }