gboolean gsb_data_mix_set_date ( gint transaction_number, GDate *date, gboolean is_transaction ) { if ( is_transaction ) return ( gsb_data_transaction_set_date ( transaction_number, date ) ); else return ( gsb_data_scheduled_set_date ( transaction_number, date ) ); }
/** * create a new transaction and fill it directly from a scheduled transaction * (don't pass throw the form) * if it's a child of split, append it automatickly to the mother * * \param scheduled_number the transaction we use to fill the new transaction * \param transaction_mother the number of the mother if it's a split child, 0 else * * \return the number of the new transaction * */ gint gsb_scheduler_create_transaction_from_scheduled_transaction ( gint scheduled_number, gint transaction_mother ) { gint transaction_number, payment_number; gint account_number; account_number = gsb_data_scheduled_get_account_number (scheduled_number); transaction_number = gsb_data_transaction_new_transaction (account_number); /* begin to fill the new transaction */ gsb_data_transaction_set_date ( transaction_number, gsb_date_copy (gsb_data_scheduled_get_date (scheduled_number))); gsb_data_transaction_set_party_number ( transaction_number, gsb_data_scheduled_get_party_number (scheduled_number)); gsb_data_transaction_set_amount ( transaction_number, gsb_data_scheduled_get_amount (scheduled_number)); gsb_data_transaction_set_currency_number ( transaction_number, gsb_data_scheduled_get_currency_number (scheduled_number)); gsb_data_transaction_set_account_number ( transaction_number, account_number ); /* ask for change if necessary, only for normal transaction ; a child must have the same currency number * than the mother */ if (!transaction_mother) gsb_currency_check_for_change ( transaction_number ); gsb_data_transaction_set_method_of_payment_number ( transaction_number, gsb_data_scheduled_get_method_of_payment_number (scheduled_number)); gsb_data_transaction_set_notes ( transaction_number, gsb_data_scheduled_get_notes (scheduled_number)); payment_number = gsb_data_scheduled_get_method_of_payment_number (scheduled_number); if ( payment_number ) { if (gsb_data_payment_get_show_entry (payment_number)) { if (gsb_data_payment_get_automatic_numbering (payment_number)) { gchar* tmpstr; tmpstr = gsb_data_payment_incremente_last_number ( payment_number, 1 ); gsb_data_transaction_set_method_of_payment_content ( transaction_number, tmpstr); gsb_data_payment_set_last_number ( payment_number, tmpstr ); g_free ( tmpstr ); } else gsb_data_transaction_set_method_of_payment_content ( transaction_number, gsb_data_scheduled_get_method_of_payment_content ( scheduled_number ) ); } } else { gsb_data_transaction_set_method_of_payment_content ( transaction_number, gsb_data_scheduled_get_method_of_payment_content ( scheduled_number ) ); } gsb_data_transaction_set_automatic_transaction ( transaction_number, gsb_data_scheduled_get_automatic_scheduled (scheduled_number)); gsb_data_transaction_set_budgetary_number ( transaction_number, gsb_data_scheduled_get_budgetary_number (scheduled_number)); gsb_data_transaction_set_sub_budgetary_number ( transaction_number, gsb_data_scheduled_get_sub_budgetary_number (scheduled_number)); /* if the financial year is automatic, we set it here */ if ( gsb_data_scheduled_get_financial_year_number (scheduled_number) == -2 ) gsb_data_transaction_set_financial_year_number ( transaction_number, gsb_data_fyear_get_from_date ( gsb_data_transaction_get_date (transaction_number))); else gsb_data_transaction_set_financial_year_number ( transaction_number, gsb_data_scheduled_get_financial_year_number (scheduled_number)); /* get the category */ gsb_scheduler_get_category_for_transaction_from_transaction ( transaction_number, scheduled_number ); /* set the mother split if exists */ gsb_data_transaction_set_mother_transaction_number ( transaction_number, transaction_mother ); /* we show the new transaction in the tree view */ gsb_transactions_list_append_new_transaction (transaction_number, TRUE); return transaction_number; }