PageRenderTime 298ms CodeModel.GetById 36ms RepoModel.GetById 3ms app.codeStats 9ms

/grisbi-0.8.8/src/gsb_file_load.c

#
C | 9049 lines | 7053 code | 1317 blank | 679 comment | 1181 complexity | e349fee8c1f640345d425cb15981f5fd MD5 | raw file
Possible License(s): GPL-2.0
  1. /* ************************************************************************** */
  2. /* */
  3. /* Copyright (C) 2000-2008 Cédric Auger (cedric@grisbi.org) */
  4. /* 2003-2009 Benjamin Drieu (bdrieu@april.org) */
  5. /* 2008-2010 Pierre Biava (grisbi@pierre.biava.name) */
  6. /* http://www.grisbi.org */
  7. /* */
  8. /* This program is free software; you can redistribute it and/or modify */
  9. /* it under the terms of the GNU General Public License as published by */
  10. /* the Free Software Foundation; either version 2 of the License, or */
  11. /* (at your option) any later version. */
  12. /* */
  13. /* This program is distributed in the hope that it will be useful, */
  14. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  15. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  16. /* GNU General Public License for more details. */
  17. /* */
  18. /* You should have received a copy of the GNU General Public License */
  19. /* along with this program; if not, write to the Free Software */
  20. /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  21. /* */
  22. /* ************************************************************************** */
  23. #ifdef HAVE_CONFIG_H
  24. #include <config.h>
  25. #endif
  26. #include "include.h"
  27. #include <glib/gstdio.h>
  28. #include <gio/gio.h>
  29. /*START_INCLUDE*/
  30. #include "gsb_file_load.h"
  31. #include "bet_data.h"
  32. #include "custom_list.h"
  33. #include "dialog.h"
  34. #include "fenetre_principale.h"
  35. #include "gsb_assistant_archive.h"
  36. #include "gsb_assistant_first.h"
  37. #include "gsb_calendar.h"
  38. #include "gsb_currency_config.h"
  39. #include "gsb_data_account.h"
  40. #include "gsb_data_archive.h"
  41. #include "gsb_data_bank.h"
  42. #include "gsb_data_budget.h"
  43. #include "gsb_data_category.h"
  44. #include "gsb_data_currency.h"
  45. #include "gsb_data_currency_link.h"
  46. #include "gsb_data_form.h"
  47. #include "gsb_data_fyear.h"
  48. #include "gsb_data_import_rule.h"
  49. #include "gsb_data_partial_balance.h"
  50. #include "gsb_data_payee.h"
  51. #include "gsb_data_payment.h"
  52. #include "gsb_data_print_config.h"
  53. #include "gsb_data_reconcile.h"
  54. #include "gsb_data_report.h"
  55. #include "gsb_data_report_amout_comparison.h"
  56. #include "gsb_data_report_text_comparison.h"
  57. #include "gsb_data_scheduled.h"
  58. #include "gsb_data_transaction.h"
  59. #include "gsb_file.h"
  60. #include "gsb_file_util.h"
  61. #include "gsb_plugins.h"
  62. #include "gsb_real.h"
  63. #include "gsb_select_icon.h"
  64. #include "gsb_scheduler_list.h"
  65. #include "import.h"
  66. #include "structures.h"
  67. #include "traitement_variables.h"
  68. #include "utils.h"
  69. #include "utils_dates.h"
  70. #include "utils_files.h"
  71. #include "utils_str.h"
  72. #include "erreur.h"
  73. /*END_INCLUDE*/
  74. /*START_STATIC*/
  75. static void gsb_file_load_account_icon_part ( const gchar **attribute_names,
  76. const gchar **attribute_values );
  77. static void gsb_file_load_account_part ( const gchar **attribute_names,
  78. const gchar **attribute_values );
  79. static void gsb_file_load_account_part_before_0_6 ( GMarkupParseContext *context,
  80. const gchar *text );
  81. static void gsb_file_load_archive ( const gchar **attribute_names,
  82. const gchar **attribute_values );
  83. static void gsb_file_load_bank ( const gchar **attribute_names,
  84. const gchar **attribute_values );
  85. static void gsb_file_load_bet_future_data ( const gchar **attribute_names,
  86. const gchar **attribute_values );
  87. static void gsb_file_load_bet_historical ( const gchar **attribute_names,
  88. const gchar **attribute_values );
  89. static void gsb_file_load_bet_part ( const gchar **attribute_names,
  90. const gchar **attribute_values );
  91. static void gsb_file_load_bet_transfert_part ( const gchar **attribute_names,
  92. const gchar **attribute_values );
  93. static gboolean gsb_file_load_check_new_structure ( gchar *file_content );
  94. static void gsb_file_load_color_part ( const gchar **attribute_names,
  95. const gchar **attribute_values );
  96. static void gsb_file_load_copy_old_file ( gchar *filename, gchar *file_content);
  97. static void gsb_file_load_currency ( const gchar **attribute_names,
  98. const gchar **attribute_values );
  99. static void gsb_file_load_currency_link ( const gchar **attribute_names,
  100. const gchar **attribute_values );
  101. static void gsb_file_load_end_element_before_0_6 ( GMarkupParseContext *context,
  102. const gchar *element_name,
  103. gpointer user_data,
  104. GError **error);
  105. static void gsb_file_load_financial_year ( const gchar **attribute_names,
  106. const gchar **attribute_values );
  107. static void gsb_file_load_general_part ( const gchar **attribute_names,
  108. const gchar **attribute_values );
  109. static void gsb_file_load_general_part_before_0_6 ( GMarkupParseContext *context,
  110. const gchar *text );
  111. static gint gsb_file_load_get_new_payment_number ( gint account_number,
  112. gint payment_number );
  113. static void gsb_file_load_import_rule ( const gchar **attribute_names,
  114. const gchar **attribute_values );
  115. static void gsb_file_load_logo_accueil ( const gchar **attribute_names,
  116. const gchar **attribute_values );
  117. static void gsb_file_load_partial_balance ( const gchar **attribute_names,
  118. const gchar **attribute_values );
  119. static void gsb_file_load_party ( const gchar **attribute_names,
  120. const gchar **attribute_values );
  121. static void gsb_file_load_payment_part ( const gchar **attribute_names,
  122. const gchar **attribute_values );
  123. static void gsb_file_load_print_part ( const gchar **attribute_names,
  124. const gchar **attribute_values );
  125. static void gsb_file_load_reconcile ( const gchar **attribute_names,
  126. const gchar **attribute_values );
  127. static void gsb_file_load_report_part_before_0_6 ( GMarkupParseContext *context,
  128. const gchar *text );
  129. static void gsb_file_load_scheduled_transactions ( const gchar **attribute_names,
  130. const gchar **attribute_values );
  131. static gboolean gsb_file_load_set_last_reconcile_data ( gint account_number,
  132. GDate *final_date,
  133. gsb_real final_balance );
  134. static void gsb_file_load_start_element ( GMarkupParseContext *context,
  135. const gchar *element_name,
  136. const gchar **attribute_names,
  137. const gchar **attribute_values,
  138. gpointer user_data,
  139. GError **error);
  140. static void gsb_file_load_start_element_before_0_6 ( GMarkupParseContext *context,
  141. const gchar *element_name,
  142. const gchar **attribute_names,
  143. const gchar **attribute_values,
  144. gpointer user_data,
  145. GError **error);
  146. static void gsb_file_load_text_element_before_0_6 ( GMarkupParseContext *context,
  147. const gchar *text,
  148. gsize text_len,
  149. gpointer user_data,
  150. GError **error);
  151. static void gsb_file_load_transactions ( const gchar **attribute_names,
  152. const gchar **attribute_values );
  153. static gboolean gsb_file_load_update_previous_version ( void );
  154. /*END_STATIC*/
  155. /*START_EXTERN*/
  156. extern gchar *adresse_commune;
  157. extern gchar *adresse_secondaire;
  158. extern gint affichage_echeances;
  159. extern gint affichage_echeances_perso_nb_libre;
  160. extern GdkColor archive_background_color;
  161. extern gint bet_array_col_width[BET_ARRAY_COLUMNS];
  162. extern GdkColor calendar_entry_color;
  163. extern GdkColor couleur_bet_division;
  164. extern GdkColor couleur_bet_future;
  165. extern GdkColor couleur_bet_solde;
  166. extern GdkColor couleur_bet_transfert;
  167. extern GdkColor couleur_fond[2];
  168. extern GdkColor couleur_grise;
  169. extern GdkColor couleur_jour;
  170. extern GdkColor couleur_selection;
  171. extern gint display_one_line;
  172. extern gint display_three_lines;
  173. extern gint display_two_lines;
  174. extern gsb_real error_real;
  175. extern struct iso_4217_currency iso_4217_currencies[];
  176. extern GtkWidget *logo_accueil;
  177. extern gint no_devise_totaux_categ;
  178. extern gint no_devise_totaux_ib;
  179. extern gint no_devise_totaux_tiers;
  180. extern gsb_real null_real;
  181. extern gint scheduler_col_width[SCHEDULER_COL_VISIBLE_COLUMNS];
  182. extern GdkColor split_background;
  183. extern gint tab_affichage_ope[TRANSACTION_LIST_ROWS_NB][CUSTOM_MODEL_VISIBLE_COLUMNS];
  184. extern GdkColor text_color[2];
  185. extern gchar *titre_fichier;
  186. extern gint transaction_col_align[CUSTOM_MODEL_N_VISIBLES_COLUMN];
  187. extern gint transaction_col_width[CUSTOM_MODEL_N_VISIBLES_COLUMN];
  188. extern gint valeur_echelle_recherche_date_import;
  189. /*END_EXTERN*/
  190. static struct
  191. {
  192. gboolean download_ok;
  193. gchar *file_version;
  194. gchar *grisbi_version;
  195. /* there is always only one to TRUE, used to split the retrieves functions */
  196. gboolean general_part;
  197. gboolean account_part;
  198. gboolean report_part;
  199. } download_tmp_values = { FALSE, NULL, NULL, FALSE, FALSE, FALSE};
  200. static gint account_number;
  201. /* to import older file than 0.6, makes the link between category and sub-category */
  202. static gint last_category = 0;
  203. static gint last_sub_category_number = 0;
  204. /* to import older file than 0.6, makes the link between budget and sub-budget */
  205. static gint last_budget = 0;
  206. static gint last_sub_budget_number = 0;
  207. /* to import older file than 0.6, makes the link between report and comparison structures */
  208. static gint last_report_number;
  209. /* filled only when loading a version before 0.6, contains the order of the accounts
  210. * in the 0.6, the accounts are saved directly in the good order
  211. * this is a list of the accounts number, in the good order */
  212. static GSList *sort_accounts = NULL;
  213. /* temporary structure used to go from the 0.5.x versions to 0.6.x versions
  214. * because before, method of payment were saved in each account, and now
  215. * there is a general list of method of payment */
  216. struct payment_conversion_struct
  217. {
  218. gint account_number;
  219. gint last_payment_number;
  220. gint new_payment_number;
  221. };
  222. static GSList *payment_conversion_list = NULL;
  223. /* temporary structure to set the final date and the final balance of a reconcile
  224. * in the reconcile itself, and not in the account as before 0.6.0 */
  225. struct reconcile_conversion_struct
  226. {
  227. gint reconcile_number;
  228. gint account_number;
  229. GDate *final_date;
  230. gsb_real final_balance;
  231. };
  232. gboolean result_reconcile = FALSE;
  233. static GSList *reconcile_conversion_list = NULL;
  234. static struct reconcile_conversion_struct *buffer_reconcile_conversion;
  235. /* structure temporaire utilisée pour faire un lien entre ancien et nouveau numéro
  236. * de rapprochement et chaque compte parce que dans les versions précédentes de Grisbi
  237. * on pouvait utiliser un męme rapprochement dans les opérations car celles-ci étaient
  238. * organisées par comptes */
  239. struct old_new_rec_conversion_struct
  240. {
  241. gint account_number;
  242. gint old_rec_number;
  243. gint new_rec_number;
  244. };
  245. static GSList *old_new_rec_list = NULL;
  246. static struct old_new_rec_conversion_struct *buffer_old_new_rec_conversion;
  247. /* variable utilisée pour indiquer le chemin de la copie d'un fichier de compte
  248. * d'une version antérieure de grisbi */
  249. gchar *copy_old_filename = NULL;
  250. /* structure temporaire pour le chargement d'un tiers/catégorie/imputation et sous-catégorie
  251. * sous-imputation */
  252. struct new_div_sous_div_struct
  253. {
  254. gint no_div;
  255. gint new_no_div;
  256. gint no_sub_div;
  257. gchar *name;
  258. gint type;
  259. };
  260. static struct new_div_sous_div_struct *buffer_new_div_sous_div;
  261. /**
  262. * called to open the grisbi file given in param
  263. *
  264. * \filename the filename to load with full path
  265. *
  266. * \return TRUE if ok
  267. * */
  268. gboolean gsb_file_load_open_file ( gchar *filename )
  269. {
  270. struct stat buffer_stat;
  271. gint return_value;
  272. gchar *file_content;
  273. gulong length;
  274. devel_debug ( filename );
  275. /* general check */
  276. if ( !g_file_test (filename, G_FILE_TEST_EXISTS) )
  277. {
  278. gchar* tmpstr1 = g_strdup_printf ( _("Cannot open file '%s': %s"),
  279. filename,
  280. _("File does not exist") );
  281. gchar* tmpstr2 = g_strdup_printf ( _("Error loading file '%s'"), filename);
  282. dialogue_error_hint ( tmpstr1, tmpstr2 );
  283. g_free ( tmpstr1 );
  284. g_free ( tmpstr2 );
  285. gsb_file_remove_name_from_opened_list (filename);
  286. return FALSE;
  287. }
  288. /* check here if it's not a regular file */
  289. if ( !g_file_test ( filename, G_FILE_TEST_IS_REGULAR ))
  290. {
  291. gchar* tmpstr1 = g_strdup_printf (
  292. _("%s doesn't seem to be a regular file,\nplease check it and try again."),
  293. filename );
  294. gchar* tmpstr2 = g_strdup_printf ( _("Error loading file '%s'"), filename);
  295. dialogue_error_hint ( tmpstr1 , tmpstr2);
  296. g_free ( tmpstr1 );
  297. g_free ( tmpstr2 );
  298. gsb_file_remove_name_from_opened_list (filename);
  299. return ( FALSE );
  300. }
  301. /* fill the buffer stat to check the permission */
  302. return_value = g_stat (filename, &buffer_stat);
  303. /* check the access to the file and display a message */
  304. #ifndef _WIN32
  305. if ( buffer_stat.st_mode != 33152 )
  306. gsb_file_util_display_warning_permissions ( );
  307. #endif /* _WIN32 */
  308. /* load the file */
  309. if (gsb_file_util_get_contents (filename, &file_content, &length))
  310. {
  311. GMarkupParser *markup_parser = g_malloc0 (sizeof (GMarkupParser));
  312. GMarkupParseContext *context;
  313. gsb_plugin *plugin;
  314. /* first, we check if the file is crypted, if it is, we decrypt it */
  315. if ( !strncmp ( file_content, "Grisbi encrypted file ", 22 ) ||
  316. !strncmp ( file_content, "Grisbi encryption v2: ", 22 ) )
  317. {
  318. plugin = gsb_plugin_find ( "openssl" );
  319. if ( plugin )
  320. {
  321. gint (*crypt_function) ( gchar *, gchar **, gboolean, gulong );
  322. crypt_function = (gpointer) plugin -> plugin_run;
  323. length = crypt_function ( filename, &file_content, FALSE, length );
  324. if ( ! length )
  325. return FALSE;
  326. }
  327. else
  328. {
  329. dialogue_error_hint ( _("Grisbi was unable to load required plugin to "
  330. "handle that file.\n\n"
  331. "Please make sure if is installed (i.e. check "
  332. "that 'grisbi-ssl' package is installed) and "
  333. "try again."),
  334. _("Encryption plugin not found." ) );
  335. return FALSE;
  336. }
  337. }
  338. /* we begin to check if we are in a version under 0.6 or 0.6 and above,
  339. * because the xml structure changes after 0.6 */
  340. if ( gsb_file_load_check_new_structure (file_content))
  341. {
  342. /* fill the GMarkupParser for a new xml structure */
  343. markup_parser -> start_element = (void *) gsb_file_load_start_element;
  344. markup_parser -> error = (void *) gsb_file_load_error;
  345. }
  346. else
  347. {
  348. /* copy of an old file grisbi */
  349. gsb_file_load_copy_old_file ( filename, file_content );
  350. /* fill the GMarkupParser for the last xml structure */
  351. markup_parser -> start_element = (void *) gsb_file_load_start_element_before_0_6;
  352. markup_parser -> end_element = (void *) gsb_file_load_end_element_before_0_6;
  353. markup_parser -> text = (void *) gsb_file_load_text_element_before_0_6;
  354. /* we will have to convert the method of payments numbers */
  355. payment_conversion_list = NULL;
  356. /* we will have to set the final date and balance in the last reconcile */
  357. reconcile_conversion_list = NULL;
  358. }
  359. context = g_markup_parse_context_new ( markup_parser,
  360. 0,
  361. NULL,
  362. NULL );
  363. download_tmp_values.download_ok = FALSE;
  364. g_markup_parse_context_parse ( context,
  365. file_content,
  366. strlen (file_content),
  367. NULL );
  368. if ( !download_tmp_values.download_ok )
  369. {
  370. g_markup_parse_context_free (context);
  371. g_free (markup_parser);
  372. g_free (file_content);
  373. return FALSE;
  374. }
  375. g_markup_parse_context_free (context);
  376. g_free (markup_parser);
  377. g_free (file_content);
  378. }
  379. else
  380. {
  381. gchar* tmpstr1 = g_strdup_printf (_("Cannot open file '%s': %s"),
  382. filename,
  383. g_strerror(errno));
  384. gchar* tmpstr2 = g_strdup_printf ( _("Error loading file '%s'"), filename);
  385. dialogue_error_hint (tmpstr1, tmpstr2);
  386. g_free ( tmpstr1 );
  387. g_free ( tmpstr2 );
  388. gsb_file_remove_name_from_opened_list (filename);
  389. return FALSE;
  390. }
  391. return gsb_file_load_update_previous_version();
  392. }
  393. /**
  394. * check if the xml file is the last structure (before 0.6) or
  395. * the new structure (after 0.6)
  396. *
  397. * \param file_content the grisbi file
  398. *
  399. * \return TRUE if the version is after 0.6
  400. * */
  401. gboolean gsb_file_load_check_new_structure ( gchar *file_content )
  402. {
  403. if ( strstr ( file_content, "Generalites" ) )
  404. return FALSE;
  405. return TRUE;
  406. }
  407. void gsb_file_load_start_element ( GMarkupParseContext *context,
  408. const gchar *element_name,
  409. const gchar **attribute_names,
  410. const gchar **attribute_values,
  411. gpointer user_data,
  412. GError **error)
  413. {
  414. /* the first time we come here, we check if it's a grisbi file */
  415. if ( !download_tmp_values.download_ok )
  416. {
  417. if ( strcmp ( element_name,
  418. "Grisbi" ))
  419. {
  420. dialogue_error ( _("This is not a Grisbi file... Loading aborted.") );
  421. g_markup_parse_context_end_parse (context,
  422. NULL);
  423. return;
  424. }
  425. download_tmp_values.download_ok = TRUE;
  426. return;
  427. }
  428. if ( !strcmp ( element_name,
  429. "General" ))
  430. {
  431. gsb_file_load_general_part ( attribute_names,
  432. attribute_values );
  433. return;
  434. }
  435. if ( !strcmp ( element_name,
  436. "Color" ))
  437. {
  438. gsb_file_load_color_part ( attribute_names,
  439. attribute_values );
  440. return;
  441. }
  442. if ( !strcmp ( element_name,
  443. "Print" ))
  444. {
  445. gsb_file_load_print_part ( attribute_names,
  446. attribute_values );
  447. return;
  448. }
  449. if ( !strcmp ( element_name,
  450. "Account" ))
  451. {
  452. gsb_file_load_account_part ( attribute_names,
  453. attribute_values );
  454. return;
  455. }
  456. if ( !strcmp ( element_name,
  457. "Payment" ))
  458. {
  459. gsb_file_load_payment_part ( attribute_names,
  460. attribute_values );
  461. return;
  462. }
  463. if ( !strcmp ( element_name,
  464. "Transaction" ))
  465. {
  466. gsb_file_load_transactions ( attribute_names,
  467. attribute_values );
  468. return;
  469. }
  470. if ( !strcmp ( element_name,
  471. "Scheduled" ))
  472. {
  473. gsb_file_load_scheduled_transactions ( attribute_names,
  474. attribute_values );
  475. return;
  476. }
  477. if ( !strcmp ( element_name,
  478. "Party" ))
  479. {
  480. gsb_file_load_party ( attribute_names,
  481. attribute_values );
  482. return;
  483. }
  484. if ( !strcmp ( element_name,
  485. "Category" ))
  486. {
  487. gsb_file_load_category ( attribute_names,
  488. attribute_values );
  489. return;
  490. }
  491. if ( !strcmp ( element_name,
  492. "Sub_category" ))
  493. {
  494. gsb_file_load_sub_category ( attribute_names,
  495. attribute_values );
  496. return;
  497. }
  498. if ( !strcmp ( element_name,
  499. "Budgetary" ))
  500. {
  501. gsb_file_load_budgetary ( attribute_names,
  502. attribute_values );
  503. return;
  504. }
  505. if ( !strcmp ( element_name,
  506. "Sub_budgetary" ))
  507. {
  508. gsb_file_load_sub_budgetary ( attribute_names,
  509. attribute_values );
  510. return;
  511. }
  512. if ( !strcmp ( element_name,
  513. "Currency" ))
  514. {
  515. gsb_file_load_currency ( attribute_names,
  516. attribute_values );
  517. return;
  518. }
  519. if ( !strcmp ( element_name,
  520. "Currency_link" ))
  521. {
  522. gsb_file_load_currency_link ( attribute_names,
  523. attribute_values );
  524. return;
  525. }
  526. if ( !strcmp ( element_name,
  527. "Bank" ))
  528. {
  529. gsb_file_load_bank ( attribute_names,
  530. attribute_values );
  531. return;
  532. }
  533. if ( !strcmp ( element_name,
  534. "Financial_year" ))
  535. {
  536. gsb_file_load_financial_year ( attribute_names,
  537. attribute_values );
  538. return;
  539. }
  540. if ( !strcmp ( element_name,
  541. "Archive" ))
  542. {
  543. gsb_file_load_archive ( attribute_names,
  544. attribute_values );
  545. return;
  546. }
  547. if ( !strcmp ( element_name,
  548. "Reconcile" ))
  549. {
  550. gsb_file_load_reconcile ( attribute_names,
  551. attribute_values );
  552. return;
  553. }
  554. if ( !strcmp ( element_name,
  555. "Import_rule" ))
  556. {
  557. gsb_file_load_import_rule ( attribute_names,
  558. attribute_values );
  559. return;
  560. }
  561. if ( !strcmp ( element_name,
  562. "Partial_balance" ))
  563. {
  564. gsb_file_load_partial_balance ( attribute_names,
  565. attribute_values );
  566. return;
  567. }
  568. if ( !strcmp ( element_name, "Bet" ) )
  569. {
  570. gsb_file_load_bet_part ( attribute_names, attribute_values );
  571. return;
  572. }
  573. if ( !strcmp ( element_name, "Bet_historical" ) )
  574. {
  575. gsb_file_load_bet_historical ( attribute_names, attribute_values );
  576. return;
  577. }
  578. if ( !strcmp ( element_name, "Bet_future" ) )
  579. {
  580. gsb_file_load_bet_future_data ( attribute_names, attribute_values );
  581. return;
  582. }
  583. if ( !strcmp ( element_name, "Bet_transfert" ) )
  584. {
  585. gsb_file_load_bet_transfert_part ( attribute_names, attribute_values );
  586. return;
  587. }
  588. if ( !strcmp ( element_name,
  589. "Report" ))
  590. {
  591. gsb_file_load_report ( attribute_names,
  592. attribute_values );
  593. return;
  594. }
  595. if ( !strcmp ( element_name,
  596. "Text_comparison" ))
  597. {
  598. gsb_file_load_text_comparison ( attribute_names,
  599. attribute_values);
  600. return;
  601. }
  602. if ( !strcmp ( element_name,
  603. "Amount_comparison" ))
  604. {
  605. gsb_file_load_amount_comparison ( attribute_names,
  606. attribute_values);
  607. return;
  608. }
  609. if ( !strcmp ( element_name, "Logo" ) )
  610. {
  611. if ( etat.utilise_logo )
  612. gsb_file_load_logo_accueil ( attribute_names, attribute_values );
  613. return;
  614. }
  615. if ( !strcmp ( element_name, "Account_icon" ) )
  616. {
  617. gsb_file_load_account_icon_part ( attribute_names, attribute_values );
  618. return;
  619. }
  620. /* the first time we come here, we check if it's a grisbi file */
  621. }
  622. void gsb_file_load_error ( GMarkupParseContext *context,
  623. GError *error,
  624. gpointer user_data )
  625. {
  626. /* the first time we come here, we check if it's a grisbi file */
  627. gchar* tmpstr = g_strdup_printf (
  628. _("An error occured while parsing the file :\nError number : %d\n%s"),
  629. error -> code,
  630. error -> message );
  631. dialogue_error ( tmpstr );
  632. g_free ( tmpstr );
  633. }
  634. /**
  635. * load the general part in the grisbi file
  636. *
  637. * \param attribute_names
  638. * \param attribute_values
  639. *
  640. * */
  641. void gsb_file_load_general_part ( const gchar **attribute_names,
  642. const gchar **attribute_values )
  643. {
  644. gint i=0;
  645. if ( !attribute_names[i] )
  646. return;
  647. do
  648. {
  649. /* we test at the beginning if the attribute_value is NULL, if yes, */
  650. /* go to the next */
  651. if ( !strcmp (attribute_values[i],
  652. "(null)"))
  653. {
  654. /* Nothing */
  655. }
  656. else if ( !strcmp ( attribute_names[i],
  657. "File_version" ))
  658. {
  659. if ( download_tmp_values.file_version )
  660. g_free ( download_tmp_values.file_version );
  661. download_tmp_values.file_version = my_strdup (attribute_values[i]);
  662. }
  663. else if ( !strcmp ( attribute_names[i],
  664. "Grisbi_version" ))
  665. {
  666. if ( download_tmp_values.grisbi_version )
  667. g_free ( download_tmp_values.grisbi_version );
  668. download_tmp_values.grisbi_version = my_strdup (attribute_values[i]);
  669. }
  670. else if ( !strcmp ( attribute_names[i],
  671. "Crypt_file" ))
  672. {
  673. etat.crypt_file = utils_str_atoi (attribute_values[i]);
  674. }
  675. else if ( !strcmp ( attribute_names[i],
  676. "Archive_file" ))
  677. {
  678. etat.is_archive = utils_str_atoi (attribute_values[i]);
  679. }
  680. else if ( !strcmp ( attribute_names[i],
  681. "File_title" ) && strlen (attribute_values[i]))
  682. {
  683. titre_fichier = my_strdup (attribute_values[i]);
  684. }
  685. else if ( !strcmp ( attribute_names[i],
  686. "General_address" ))
  687. {
  688. if ( adresse_commune )
  689. g_free ( adresse_commune );
  690. adresse_commune = my_strdup (attribute_values[i]);
  691. }
  692. else if ( !strcmp ( attribute_names[i],
  693. "Second_general_address" ))
  694. {
  695. if ( adresse_secondaire )
  696. g_free ( adresse_secondaire );
  697. adresse_secondaire = my_strdup (attribute_values[i]);
  698. }
  699. else if ( !strcmp ( attribute_names[i], "Date_format" ) )
  700. {
  701. gsb_date_set_format_date ( attribute_values[i] );
  702. }
  703. else if ( !strcmp ( attribute_names[i], "Decimal_point" ) )
  704. {
  705. gsb_real_set_decimal_point ( attribute_values[i] );
  706. }
  707. else if ( !strcmp ( attribute_names[i], "Thousands_separator" ) )
  708. {
  709. if ( !strcmp ( attribute_values[i], "empty" ) )
  710. gsb_real_set_thousands_sep ( NULL );
  711. else
  712. gsb_real_set_thousands_sep ( attribute_values[i] );
  713. }
  714. else if ( !strcmp ( attribute_names[i],
  715. "Party_list_currency_number" ))
  716. {
  717. no_devise_totaux_tiers = utils_str_atoi ( attribute_values[i]);
  718. }
  719. else if ( !strcmp ( attribute_names[i],
  720. "Category_list_currency_number" ))
  721. {
  722. no_devise_totaux_categ = utils_str_atoi ( attribute_values[i]);
  723. }
  724. else if ( !strcmp ( attribute_names[i],
  725. "Budget_list_currency_number" ))
  726. {
  727. no_devise_totaux_ib = utils_str_atoi ( attribute_values[i]);
  728. }
  729. else if ( !strcmp ( attribute_names[i],
  730. "Scheduler_view" ))
  731. {
  732. affichage_echeances = utils_str_atoi ( attribute_values[i]);
  733. }
  734. else if ( !strcmp ( attribute_names[i],
  735. "Scheduler_custom_number" ))
  736. {
  737. affichage_echeances_perso_nb_libre = utils_str_atoi ( attribute_values[i]);
  738. }
  739. else if ( !strcmp ( attribute_names[i],
  740. "Scheduler_custom_menu" ))
  741. {
  742. affichage_echeances_perso_j_m_a = utils_str_atoi ( attribute_values[i]);
  743. }
  744. else if ( !strcmp ( attribute_names[i],
  745. "Import_interval_search" ))
  746. {
  747. valeur_echelle_recherche_date_import = utils_str_atoi ( attribute_values[i]);
  748. }
  749. else if ( !strcmp ( attribute_names[i],
  750. "Import_extract_number_for_check" ))
  751. {
  752. etat.get_extract_number_for_check = utils_str_atoi ( attribute_values[i]);
  753. }
  754. else if ( !strcmp ( attribute_names[i],
  755. "Import_fusion_transactions" ))
  756. {
  757. etat.get_fusion_import_transactions = utils_str_atoi ( attribute_values[i]);
  758. }
  759. else if ( !strcmp ( attribute_names[i],
  760. "Import_categorie_for_payee" ))
  761. {
  762. etat.get_categorie_for_payee = utils_str_atoi ( attribute_values[i]);
  763. }
  764. else if ( !strcmp ( attribute_names[i],
  765. "Import_fyear_by_value_date" ))
  766. {
  767. etat.get_fyear_by_value_date = utils_str_atoi ( attribute_values[i]);
  768. }
  769. else if ( !strcmp ( attribute_names[i], "Reconcile_end_date" ) )
  770. {
  771. etat.reconcile_end_date = utils_str_atoi ( attribute_values[i] );
  772. }
  773. else if ( !strcmp ( attribute_names[i],
  774. "Use_logo" ))
  775. {
  776. etat.utilise_logo = utils_str_atoi ( attribute_values[i]);
  777. }
  778. else if ( !strcmp ( attribute_names[i], "Name_logo" ) )
  779. {
  780. GdkPixbuf *pixbuf = NULL;
  781. etat.name_logo = my_strdup ( attribute_values[i] );
  782. if ( etat.is_pixmaps_dir )
  783. {
  784. gchar *chemin_logo = NULL;
  785. if ( etat.name_logo )
  786. chemin_logo = g_build_filename ( GRISBI_PIXMAPS_DIR, etat.name_logo, NULL );
  787. else
  788. chemin_logo = g_build_filename ( GRISBI_PIXMAPS_DIR, "grisbi-logo.png", NULL );
  789. if ( chemin_logo )
  790. pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
  791. if ( chemin_logo && strlen ( chemin_logo ) > 0 )
  792. g_free ( chemin_logo );
  793. }
  794. if ( pixbuf )
  795. {
  796. gtk_window_set_default_icon ( pixbuf );
  797. gsb_select_icon_set_logo_pixbuf ( pixbuf );
  798. }
  799. }
  800. else if ( !strcmp ( attribute_names[i], "Is_pixmaps_dir" ) )
  801. {
  802. etat.is_pixmaps_dir = utils_str_atoi ( attribute_values[i] );
  803. if ( etat.is_pixmaps_dir && etat.name_logo == NULL )
  804. {
  805. GdkPixbuf *pixbuf = NULL;
  806. gchar *chemin_logo = NULL;
  807. chemin_logo = g_build_filename ( GRISBI_PIXMAPS_DIR, "grisbi-logo.png", NULL );
  808. pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
  809. gtk_window_set_default_icon ( pixbuf );
  810. gsb_select_icon_set_logo_pixbuf ( pixbuf );
  811. g_free ( chemin_logo );
  812. }
  813. }
  814. else if ( !strcmp ( attribute_names[i],
  815. "Remind_display_per_account" ))
  816. {
  817. etat.retient_affichage_par_compte = utils_str_atoi( attribute_values[i]);
  818. }
  819. else if ( !strcmp ( attribute_names[i],
  820. "Transactions_view" ))
  821. {
  822. gchar **pointeur_char;
  823. gint j, k;
  824. pointeur_char = g_strsplit ( attribute_values[i],
  825. "-",
  826. 0 );
  827. for ( j = 0 ; j<TRANSACTION_LIST_ROWS_NB ; j++ )
  828. for ( k = 0 ; k<CUSTOM_MODEL_VISIBLE_COLUMNS ; k++ )
  829. tab_affichage_ope[j][k] = utils_str_atoi (
  830. pointeur_char[k + j*CUSTOM_MODEL_VISIBLE_COLUMNS]);
  831. g_strfreev ( pointeur_char );
  832. }
  833. else if ( !strcmp ( attribute_names[i],
  834. "One_line_showed" ))
  835. {
  836. display_one_line = utils_str_atoi ( attribute_values[i]);
  837. }
  838. else if ( !strcmp ( attribute_names[i],
  839. "Two_lines_showed" ))
  840. {
  841. display_two_lines = utils_str_atoi ( attribute_values[i]);
  842. }
  843. else if ( !strcmp ( attribute_names[i],
  844. "Three_lines_showed" ))
  845. {
  846. display_three_lines = utils_str_atoi ( attribute_values[i]);
  847. }
  848. else if ( !strcmp ( attribute_names[i], "Transaction_column_width" ) )
  849. {
  850. /* initialise la réinitialisation des colonnes */
  851. run.transaction_column_width = my_strdup ( attribute_values[i] );
  852. initialise_largeur_colonnes_tab_affichage_ope ( GSB_ACCOUNT_PAGE,
  853. run.transaction_column_width );
  854. }
  855. else if ( !strcmp ( attribute_names[i], "Transaction_column_align" ) )
  856. {
  857. gchar **pointeur_char;
  858. gint j;
  859. /* the transactions columns are xx-xx-xx-xx and we want to set in transaction_col_width[1-2-3...] */
  860. pointeur_char = g_strsplit ( attribute_values[i], "-", 0 );
  861. for ( j = 0 ; j < CUSTOM_MODEL_VISIBLE_COLUMNS ; j++ )
  862. transaction_col_align[j] = utils_str_atoi ( pointeur_char[j] );
  863. g_strfreev ( pointeur_char );
  864. }
  865. else if ( !strcmp ( attribute_names[i], "Scheduler_column_width" ) )
  866. {
  867. /* initialise la réinitialisation des colonnes */
  868. run.scheduler_column_width = my_strdup ( attribute_values[i] );
  869. initialise_largeur_colonnes_tab_affichage_ope ( GSB_SCHEDULER_PAGE,
  870. run.scheduler_column_width );
  871. }
  872. else if ( !strcmp ( attribute_names[i],
  873. "Combofix_mixed_sort" ))
  874. {
  875. etat.combofix_mixed_sort = utils_str_atoi( attribute_values[i]);
  876. }
  877. else if ( !strcmp ( attribute_names[i],
  878. "Combofix_max_item" ))
  879. {
  880. etat.combofix_max_item = utils_str_atoi( attribute_values[i]);
  881. }
  882. else if ( !strcmp ( attribute_names[i],
  883. "Combofix_case_sensitive" ))
  884. {
  885. etat.combofix_case_sensitive = utils_str_atoi( attribute_values[i]);
  886. }
  887. else if ( !strcmp ( attribute_names[i],
  888. "Combofix_force_payee" ))
  889. {
  890. etat.combofix_force_payee = utils_str_atoi( attribute_values[i]);
  891. }
  892. else if ( !strcmp ( attribute_names[i],
  893. "Combofix_force_category" ))
  894. {
  895. etat.combofix_force_category = utils_str_atoi( attribute_values[i]);
  896. }
  897. else if ( !strcmp ( attribute_names[i],
  898. "Automatic_amount_separator" ))
  899. {
  900. etat.automatic_separator = utils_str_atoi( attribute_values[i]);
  901. }
  902. else if ( !strcmp ( attribute_names[i],
  903. "CSV_separator" ))
  904. {
  905. if ( etat.csv_separator )
  906. g_free ( etat.csv_separator );
  907. etat.csv_separator = my_strdup ( attribute_values[i] );
  908. }
  909. else if ( !strcmp ( attribute_names[i],
  910. "CSV_skipped_lines" ))
  911. {
  912. if ( attribute_values[i] && strlen ( attribute_values[i] ) )
  913. {
  914. gchar ** pointeur_char = g_strsplit ( attribute_values[i], "-", 0 );
  915. gint line = 0;
  916. while ( pointeur_char[line] )
  917. {
  918. etat.csv_skipped_lines[line] = utils_str_atoi ( pointeur_char[line] );
  919. line ++;
  920. }
  921. g_strfreev ( pointeur_char );
  922. }
  923. }
  924. else if ( !strcmp ( attribute_names[i],
  925. "Metatree_sort_transactions" ))
  926. {
  927. etat.metatree_sort_transactions = utils_str_atoi( attribute_values[i]);
  928. }
  929. else if ( !strcmp ( attribute_names[i],
  930. "Add_archive_in_total_balance" ))
  931. {
  932. etat.add_archive_in_total_balance = utils_str_atoi( attribute_values[i]);
  933. }
  934. else if ( !strcmp ( attribute_names[i], "Bet_array_column_width" ))
  935. {
  936. gchar **pointeur_char;
  937. gint j;
  938. /* the bet_array columns are xx-xx-xx-xx-xx and we want to set in bet_array_col_width[1-2-3...] */
  939. pointeur_char = g_strsplit ( attribute_values[i], "-", 0 );
  940. for ( j = 0; j < BET_ARRAY_COLUMNS; j++ )
  941. bet_array_col_width[j] = utils_str_atoi ( pointeur_char[j] );
  942. g_strfreev ( pointeur_char );
  943. }
  944. else if ( !strcmp ( attribute_names[i], "Bet_capital" ) )
  945. {
  946. etat.bet_capital = utils_str_safe_strtod ( attribute_values[i], NULL );
  947. }
  948. else if ( !strcmp ( attribute_names[i], "Bet_currency" ) )
  949. {
  950. etat.bet_currency = utils_str_atoi ( attribute_values[i] );
  951. }
  952. else if ( !strcmp ( attribute_names[i], "Bet_taux_annuel" ) )
  953. {
  954. etat.bet_taux_annuel = utils_str_safe_strtod ( attribute_values[i], NULL );
  955. }
  956. else if ( !strcmp ( attribute_names[i], "Bet_index_duree" ) )
  957. {
  958. etat.bet_index_duree = utils_str_atoi ( attribute_values[i] );
  959. }
  960. else if ( !strcmp ( attribute_names[i], "Bet_frais" ) )
  961. {
  962. etat.bet_frais = utils_str_safe_strtod ( attribute_values[i], NULL );
  963. }
  964. else if ( !strcmp ( attribute_names[i], "Bet_type_taux" ) )
  965. {
  966. etat.bet_type_taux = utils_str_atoi ( attribute_values[i] );
  967. }
  968. i++;
  969. }
  970. while ( attribute_names[i] );
  971. }
  972. /**
  973. * load the color part in the grisbi file
  974. *
  975. * \param attribute_names
  976. * \param attribute_values
  977. *
  978. * */
  979. void gsb_file_load_color_part ( const gchar **attribute_names,
  980. const gchar **attribute_values )
  981. {
  982. gint i=0;
  983. if ( !attribute_names[i] )
  984. return;
  985. do
  986. {
  987. /* we test at the beginning if the attribute_value is NULL, if yes, */
  988. /* go to the next */
  989. if ( !strcmp (attribute_values[i],
  990. "(null)"))
  991. {
  992. /* Nothing */
  993. }
  994. else if ( !strcmp ( attribute_names[i],
  995. "Background_color_0_red" ))
  996. {
  997. couleur_fond[0].red = utils_str_atoi (attribute_values[i]);
  998. }
  999. else if ( !strcmp ( attribute_names[i],
  1000. "Background_color_0_green" ))
  1001. {
  1002. couleur_fond[0].green = utils_str_atoi (attribute_values[i]);
  1003. }
  1004. else if ( !strcmp ( attribute_names[i],
  1005. "Background_color_0_blue" ))
  1006. {
  1007. couleur_fond[0].blue = utils_str_atoi (attribute_values[i]);
  1008. }
  1009. else if ( !strcmp ( attribute_names[i],
  1010. "Background_color_1_red" ))
  1011. {
  1012. couleur_fond[1].red = utils_str_atoi (attribute_values[i]);
  1013. }
  1014. else if ( !strcmp ( attribute_names[i],
  1015. "Background_color_1_green" ))
  1016. {
  1017. couleur_fond[1].green = utils_str_atoi (attribute_values[i]);
  1018. }
  1019. else if ( !strcmp ( attribute_names[i],
  1020. "Background_color_1_blue" ))
  1021. {
  1022. couleur_fond[1].blue = utils_str_atoi (attribute_values[i]);
  1023. }
  1024. else if ( !strcmp ( attribute_names[i],
  1025. "Couleur_jour_red" ))
  1026. {
  1027. couleur_jour.red = utils_str_atoi (attribute_values[i]);
  1028. }
  1029. else if ( !strcmp ( attribute_names[i],
  1030. "Couleur_jour_green" ))
  1031. {
  1032. couleur_jour.green = utils_str_atoi (attribute_values[i]);
  1033. }
  1034. else if ( !strcmp ( attribute_names[i],
  1035. "Couleur_jour_blue" ))
  1036. {
  1037. couleur_jour.blue = utils_str_atoi (attribute_values[i]);
  1038. }
  1039. else if ( !strcmp ( attribute_names[i],
  1040. "Background_scheduled_red" ))
  1041. {
  1042. couleur_grise.red = utils_str_atoi (attribute_values[i]);
  1043. }
  1044. else if ( !strcmp ( attribute_names[i],
  1045. "Background_scheduled_green" ))
  1046. {
  1047. couleur_grise.green = utils_str_atoi (attribute_values[i]);
  1048. }
  1049. else if ( !strcmp ( attribute_names[i],
  1050. "Background_scheduled_blue" ))
  1051. {
  1052. couleur_grise.blue = utils_str_atoi (attribute_values[i]);
  1053. }
  1054. else if ( !strcmp ( attribute_names[i],
  1055. "Background_archive_red" ))
  1056. {
  1057. archive_background_color.red = utils_str_atoi (attribute_values[i]);
  1058. }
  1059. else if ( !strcmp ( attribute_names[i],
  1060. "Background_archive_green" ))
  1061. {
  1062. archive_background_color.green = utils_str_atoi (attribute_values[i]);
  1063. }
  1064. else if ( !strcmp ( attribute_names[i],
  1065. "Background_archive_blue" ))
  1066. {
  1067. archive_background_color.blue = utils_str_atoi (attribute_values[i]);
  1068. }
  1069. else if ( !strcmp ( attribute_names[i],
  1070. "Selection_red" ))
  1071. {
  1072. couleur_selection.red = utils_str_atoi (attribute_values[i]);
  1073. }
  1074. else if ( !strcmp ( attribute_names[i],
  1075. "Selection_green" ))
  1076. {
  1077. couleur_selection.green = utils_str_atoi (attribute_values[i]);
  1078. }
  1079. else if ( !strcmp ( attribute_names[i],
  1080. "Selection_blue" ))
  1081. {
  1082. couleur_selection.blue = utils_str_atoi (attribute_values[i]);
  1083. }
  1084. else if ( !strcmp ( attribute_names[i],
  1085. "Background_split_red" ))
  1086. {
  1087. split_background.red = utils_str_atoi (attribute_values[i]);
  1088. }
  1089. else if ( !strcmp ( attribute_names[i],
  1090. "Background_split_green" ))
  1091. {
  1092. split_background.green = utils_str_atoi (attribute_values[i]);
  1093. }
  1094. else if ( !strcmp ( attribute_names[i],
  1095. "Background_split_blue" ))
  1096. {
  1097. split_background.blue = utils_str_atoi (attribute_values[i]);
  1098. }
  1099. else if ( !strcmp ( attribute_names[i],
  1100. "Text_color_0_red" ))
  1101. {
  1102. text_color[0].red = utils_str_atoi (attribute_values[i]);
  1103. }
  1104. else if ( !strcmp ( attribute_names[i],
  1105. "Text_color_0_green" ))
  1106. {
  1107. text_color[0].green = utils_str_atoi (attribute_values[i]);
  1108. }
  1109. else if ( !strcmp ( attribute_names[i],
  1110. "Text_color_0_blue" ))
  1111. {
  1112. text_color[0].blue = utils_str_atoi (attribute_values[i]);
  1113. }
  1114. else if ( !strcmp ( attribute_names[i],
  1115. "Text_color_1_red" ))
  1116. {
  1117. text_color[1].red = utils_str_atoi (attribute_values[i]);
  1118. }
  1119. else if ( !strcmp ( attribute_names[i],
  1120. "Text_color_1_green" ))
  1121. {
  1122. text_color[1].green = utils_str_atoi (attribute_values[i]);
  1123. }
  1124. else if ( !strcmp ( attribute_names[i],
  1125. "Text_color_1_blue" ))
  1126. {
  1127. text_color[1].blue = utils_str_atoi (attribute_values[i]);
  1128. }
  1129. else if ( !strcmp ( attribute_names[i],
  1130. "Calendar_entry_red" ))
  1131. {
  1132. calendar_entry_color.red = utils_str_atoi (attribute_values[i]);
  1133. }
  1134. else if ( !strcmp ( attribute_names[i],
  1135. "Calendar_entry_green" ))
  1136. {
  1137. calendar_entry_color.green = utils_str_atoi (attribute_values[i]);
  1138. }
  1139. else if ( !strcmp ( attribute_names[i],
  1140. "Calendar_entry_blue" ))
  1141. {
  1142. calendar_entry_color.blue = utils_str_atoi (attribute_values[i]);
  1143. }
  1144. else if ( !strcmp ( attribute_names[i],
  1145. "Couleur_bet_division_red" ))
  1146. {
  1147. couleur_bet_division.red = utils_str_atoi (attribute_values[i]);
  1148. }
  1149. else if ( !strcmp ( attribute_names[i],
  1150. "Couleur_bet_division_green" ))
  1151. {
  1152. couleur_bet_division.green = utils_str_atoi (attribute_values[i]);
  1153. }
  1154. else if ( !strcmp ( attribute_names[i],
  1155. "Couleur_bet_division_blue" ))
  1156. {
  1157. couleur_bet_division.blue = utils_str_atoi (attribute_values[i]);
  1158. }
  1159. else if ( !strcmp ( attribute_names[i],
  1160. "Couleur_bet_future_red" ))
  1161. {
  1162. couleur_bet_future.red = utils_str_atoi (attribute_values[i]);
  1163. }
  1164. else if ( !strcmp ( attribute_names[i],
  1165. "Couleur_bet_future_green" ))
  1166. {
  1167. couleur_bet_future.green = utils_str_atoi (attribute_values[i]);
  1168. }
  1169. else if ( !strcmp ( attribute_names[i],
  1170. "Couleur_bet_future_blue" ))
  1171. {
  1172. couleur_bet_future.blue = utils_str_atoi (attribute_values[i]);
  1173. }
  1174. else if ( !strcmp ( attribute_names[i],
  1175. "Couleur_bet_solde_red" ))
  1176. {
  1177. couleur_bet_solde.red = utils_str_atoi (attribute_values[i]);
  1178. }
  1179. else if ( !strcmp ( attribute_names[i],
  1180. "Couleur_bet_solde_green" ))
  1181. {
  1182. couleur_bet_solde.green = utils_str_atoi (attribute_values[i]);
  1183. }
  1184. else if ( !strcmp ( attribute_names[i],
  1185. "Couleur_bet_solde_blue" ))
  1186. {
  1187. couleur_bet_solde.blue = utils_str_atoi (attribute_values[i]);
  1188. }
  1189. else if ( !strcmp ( attribute_names[i],
  1190. "Couleur_bet_transfert_red" ))
  1191. {
  1192. couleur_bet_transfert.red = utils_str_atoi (attribute_values[i]);
  1193. }
  1194. else if ( !strcmp ( attribute_names[i],
  1195. "Couleur_bet_transfert_green" ))
  1196. {
  1197. couleur_bet_transfert.green = utils_str_atoi (attribute_values[i]);
  1198. }
  1199. else if ( !strcmp ( attribute_names[i],
  1200. "Couleur_bet_transfert_blue" ))
  1201. {
  1202. couleur_bet_transfert.blue = utils_str_atoi (attribute_values[i]);
  1203. }
  1204. i++;
  1205. }
  1206. while ( attribute_names[i] );
  1207. }
  1208. /**
  1209. * load the print part in the grisbi file
  1210. *
  1211. * \param attribute_names
  1212. * \param attribute_values
  1213. *
  1214. * */
  1215. void gsb_file_load_print_part ( const gchar **attribute_names,
  1216. const gchar **attribute_values )
  1217. {
  1218. gint i=0;
  1219. if ( !attribute_names[i] )
  1220. return;
  1221. do
  1222. {
  1223. /* we test at the beginning if the attribute_value is NULL, if yes, */
  1224. /* go to the next */
  1225. if ( !strcmp (attribute_values[i],
  1226. "(null)"))
  1227. {
  1228. /* Nothing */
  1229. }
  1230. else if ( !strcmp ( attribute_names[i],
  1231. "Draw_lines" ))
  1232. {
  1233. gsb_data_print_config_set_draw_lines (0, utils_str_atoi (attribute_values[i]));
  1234. }
  1235. else if ( !strcmp ( attribute_names[i],
  1236. "Draw_column" ))
  1237. {
  1238. gsb_data_print_config_set_draw_column (0, utils_str_atoi (attribute_values[i]));
  1239. }
  1240. else if ( !strcmp ( attribute_names[i],
  1241. "Draw_background" ))
  1242. {
  1243. gsb_data_print_config_set_draw_background (0, utils_str_atoi (attribute_values[i]));
  1244. }
  1245. else if ( !strcmp ( attribute_names[i],
  1246. "Draw_archives" ))
  1247. {
  1248. gsb_data_print_config_set_draw_archives (0, utils_str_atoi (attribute_values[i]));
  1249. }
  1250. else if ( !strcmp ( attribute_names[i],
  1251. "Draw_columns_name" ))
  1252. {
  1253. gsb_data_print_config_set_draw_columns_name (0, utils_str_atoi (attribute_values[i]));
  1254. }
  1255. else if ( !strcmp ( attribute_names[i],
  1256. "Draw_title" ))
  1257. {
  1258. gsb_data_print_config_set_draw_title (0, utils_str_atoi (attribute_values[i]));
  1259. }
  1260. else if ( !strcmp ( attribute_names[i],
  1261. "Draw_interval_dates" ))
  1262. {
  1263. gsb_data_print_config_set_draw_interval_dates (
  1264. 0, utils_str_atoi (attribute_values[i]) );
  1265. }
  1266. else if ( !strcmp ( attribute_names[i],
  1267. "Draw_dates_are_value_dates" ))
  1268. {
  1269. gsb_data_print_config_set_draw_dates_are_value_dates (
  1270. 0, utils_str_atoi (attribute_values[i]) );
  1271. }
  1272. else if ( !strcmp ( attribute_names[i],
  1273. "Font_transactions" ))
  1274. {
  1275. gsb_data_print_config_set_font_transaction (
  1276. pango_font_description_from_string (attribute_values[i]) );
  1277. }
  1278. else if ( !strcmp ( attribute_names[i],
  1279. "Font_title" ))
  1280. {
  1281. gsb_data_print_config_set_font_title (
  1282. pango_font_description_from_string (attribute_values[i]) );
  1283. }
  1284. else if ( !strcmp ( attribute_names[i],
  1285. "Report_font_transactions" ) )
  1286. {
  1287. gsb_data_print_config_set_report_font_transaction (
  1288. pango_font_description_from_string (attribute_values[i]) );
  1289. }
  1290. else if ( !strcmp ( attribute_names[i],
  1291. "Report_font_title" ) )
  1292. {
  1293. gsb_data_print_config_set_report_font_title (
  1294. pango_font_description_from_string ( attribute_values[i]) );
  1295. }
  1296. i++;
  1297. }
  1298. while ( attribute_names[i] );
  1299. }
  1300. /**
  1301. * load the account part in the grisbi file
  1302. *
  1303. * \param attribute_names
  1304. * \param attribute_values
  1305. *
  1306. * */
  1307. void gsb_file_load_account_part ( const gchar **attribute_names,
  1308. const gchar **attribute_values )
  1309. {
  1310. gint i=0;
  1311. gint account_number = 0;
  1312. if ( !attribute_names[i] )
  1313. return;
  1314. do
  1315. {
  1316. /* we test at the beginning if the attribute_value is NULL, if yes, */
  1317. /* go to the next */
  1318. if ( !strcmp (attribute_values[i],
  1319. "(null)"))
  1320. {
  1321. i++;
  1322. continue;
  1323. }
  1324. if ( !strcmp ( attribute_names[i],
  1325. "Name" ))
  1326. {
  1327. account_number = gsb_data_account_new ( GSB_TYPE_BANK );
  1328. gsb_data_account_set_name ( account_number,
  1329. attribute_values[i]);
  1330. i++;
  1331. continue;
  1332. }
  1333. if ( !strcmp ( attribute_names[i],
  1334. "Id" ))
  1335. {
  1336. if ( strlen (attribute_values[i]))
  1337. gsb_data_account_set_id (account_number,
  1338. attribute_values[i]);
  1339. i++;
  1340. continue;
  1341. }
  1342. if ( !strcmp ( attribute_names[i],
  1343. "Number" ))
  1344. {
  1345. account_number = gsb_data_account_set_account_number ( account_number,
  1346. utils_str_atoi ( attribute_values[i]));
  1347. i++;
  1348. continue;
  1349. }
  1350. if ( !strcmp ( attribute_names[i],
  1351. "Owner" ))
  1352. {
  1353. gsb_data_account_set_holder_name ( account_number,
  1354. attribute_values[i]);
  1355. i++;
  1356. continue;
  1357. }
  1358. if ( !strcmp ( attribute_names[i],
  1359. "Kind" ))
  1360. {
  1361. gsb_data_account_set_kind (account_number,
  1362. utils_str_atoi ( attribute_values[i]));
  1363. i++;
  1364. continue;
  1365. }
  1366. if ( !strcmp ( attribute_names[i],
  1367. "Currency" ))
  1368. {
  1369. gsb_data_account_set_currency ( account_number,
  1370. utils_str_atoi ( attribute_values[i]));
  1371. i++;
  1372. continue;
  1373. }
  1374. if ( !strcmp ( attribute_names[i], "Path_icon" ) )
  1375. {
  1376. gsb_data_account_set_name_icon ( account_number,
  1377. attribute_values[i] );
  1378. i++;
  1379. continue;
  1380. }
  1381. if ( !strcmp ( attribute_names[i],
  1382. "Bank" ))
  1383. {
  1384. gsb_data_account_set_bank ( account_number,
  1385. utils_str_atoi ( attribute_values[i]));
  1386. i++;
  1387. continue;
  1388. }
  1389. if ( !strcmp ( attribute_names[i],
  1390. "Bank_branch_code" ))
  1391. {
  1392. gsb_data_account_set_bank_branch_code ( account_number,
  1393. attribute_values[i]);
  1394. i++;
  1395. continue;
  1396. }
  1397. if ( !strcmp ( attribute_names[i],
  1398. "Bank_account_number" ))
  1399. {
  1400. gsb_data_account_set_bank_account_number ( account_number,
  1401. attribute_values[i]);
  1402. i++;
  1403. continue;
  1404. }
  1405. if ( !strcmp ( attribute_names[i],
  1406. "Key" ))
  1407. {
  1408. gsb_data_account_set_bank_account_key ( account_number,
  1409. attribute_values[i]);
  1410. i++;
  1411. continue;
  1412. }
  1413. if ( !strcmp ( attribute_names[i],
  1414. "Bank_account_IBAN" ))
  1415. {
  1416. gsb_data_account_set_bank_account_iban ( account_number,
  1417. attribute_values[i]);
  1418. i++;
  1419. continue;
  1420. }
  1421. if ( !strcmp ( attribute_names[i],
  1422. "Initial_balance" ))
  1423. {
  1424. gsb_data_account_set_init_balance ( account_number,
  1425. gsb_real_safe_real_from_string (attribute_values[i]));
  1426. i++;
  1427. continue;
  1428. }
  1429. if ( !strcmp ( attribute_names[i],
  1430. "Minimum_wanted_balance" ))
  1431. {
  1432. gsb_data_account_set_mini_balance_wanted ( account_number,
  1433. gsb_real_safe_real_from_string (attribute_values[i]));
  1434. i++;
  1435. continue;
  1436. }
  1437. if ( !strcmp ( attribute_names[i],
  1438. "Minimum_authorised_balance" ))
  1439. {
  1440. gsb_data_account_set_mini_balance_authorized ( account_number,
  1441. gsb_real_safe_real_from_string (attribute_values[i]));
  1442. i++;
  1443. continue;
  1444. }
  1445. if ( !strcmp ( attribute_names[i],
  1446. "Closed_account" ))
  1447. {
  1448. gsb_data_account_set_closed_account ( account_number,
  1449. utils_str_atoi ( attribute_values[i]));
  1450. i++;
  1451. continue;
  1452. }
  1453. if ( !strcmp ( attribute_names[i],
  1454. "Show_marked" ))
  1455. {
  1456. gsb_data_account_set_r ( account_number,
  1457. utils_str_atoi (attribute_values[i]));
  1458. i++;
  1459. continue;
  1460. }
  1461. if ( !strcmp ( attribute_names[i],
  1462. "Show_archives_lines" ))
  1463. {
  1464. gsb_data_account_set_l ( account_number,
  1465. utils_str_atoi (attribute_values[i]));
  1466. i++;
  1467. continue;
  1468. }
  1469. if ( !strcmp ( attribute_names[i],
  1470. "Lines_per_transaction" ))
  1471. {
  1472. gsb_data_account_set_nb_rows ( account_number,
  1473. utils_str_atoi (attribute_values[i]));
  1474. i++;
  1475. continue;
  1476. }
  1477. if ( !strcmp ( attribute_names[i],
  1478. "Comment" ))
  1479. {
  1480. gsb_data_account_set_comment ( account_number,
  1481. attribute_values[i]);
  1482. i++;
  1483. continue;
  1484. }
  1485. if ( !strcmp ( attribute_names[i],
  1486. "Owner_address" ))
  1487. {
  1488. if ( g_strstr_len ( attribute_values[i], -1, "&#xA;" ) )
  1489. {
  1490. gchar **owner_tab;
  1491. gchar *owner_str;
  1492. owner_tab = g_strsplit ( attribute_values[i], "&#xA;", 0 );
  1493. owner_str = g_strjoinv ( NEW_LINE, owner_tab );
  1494. gsb_data_account_set_holder_address ( account_number, owner_str );
  1495. g_free ( owner_str );
  1496. g_strfreev ( owner_tab );
  1497. }
  1498. else
  1499. gsb_data_account_set_holder_address ( account_number,
  1500. attribute_values[i]);
  1501. i++;
  1502. continue;
  1503. }
  1504. if ( !strcmp ( attribute_names[i],
  1505. "Default_debit_method" ))
  1506. {
  1507. gsb_data_account_set_default_debit ( account_number,
  1508. utils_str_atoi ( attribute_values[i]) );
  1509. i++;
  1510. continue;
  1511. }
  1512. if ( !strcmp ( attribute_names[i],
  1513. "Default_credit_method" ))
  1514. {
  1515. gsb_data_account_set_default_credit ( account_number,
  1516. utils_str_atoi ( attribute_values[i]));
  1517. i++;
  1518. continue;
  1519. }
  1520. if ( !strcmp ( attribute_names[i],
  1521. "Sort_by_method" ))
  1522. {
  1523. gsb_data_account_set_reconcile_sort_type ( account_number,
  1524. utils_str_atoi ( attribute_values[i]));
  1525. i++;
  1526. continue;
  1527. }
  1528. if ( !strcmp ( attribute_names[i],
  1529. "Neutrals_inside_method" ))
  1530. {
  1531. gsb_data_account_set_split_neutral_payment ( account_number,
  1532. utils_str_atoi ( attribute_values[i]) );
  1533. i++;
  1534. continue;
  1535. }
  1536. if ( !strcmp ( attribute_names[i],
  1537. "Sort_order" ))
  1538. {
  1539. if ( strlen (attribute_values[i]))
  1540. {
  1541. gchar **pointeur_char;
  1542. gint j;
  1543. pointeur_char = g_strsplit ( attribute_values[i],
  1544. "/",
  1545. 0 );
  1546. j = 0;
  1547. while ( pointeur_char[j] )
  1548. {
  1549. gsb_data_account_sort_list_add ( account_number,
  1550. utils_str_atoi ( pointeur_char[j] ));
  1551. j++;
  1552. }
  1553. g_strfreev ( pointeur_char );
  1554. }
  1555. i++;
  1556. continue;
  1557. }
  1558. if ( !strcmp ( attribute_names[i],
  1559. "Ascending_sort" ))
  1560. {
  1561. gsb_data_account_set_sort_type ( account_number,
  1562. utils_str_atoi ( attribute_values[i]));
  1563. i++;
  1564. continue;
  1565. }
  1566. if ( !strcmp ( attribute_names[i],
  1567. "Column_sort" ))
  1568. {
  1569. gsb_data_account_set_sort_column ( account_number,
  1570. utils_str_atoi ( attribute_values[i]));
  1571. i++;
  1572. continue;
  1573. }
  1574. if ( !strcmp ( attribute_names[i],
  1575. "Sorting_kind_column" ))
  1576. {
  1577. gint j;
  1578. gchar **pointeur_char;
  1579. pointeur_char = g_strsplit ( attribute_values[i],
  1580. "-",
  1581. 0 );
  1582. for ( j=0 ; j<CUSTOM_MODEL_VISIBLE_COLUMNS ; j++ )
  1583. {
  1584. gsb_data_account_set_element_sort ( account_number,
  1585. j,
  1586. utils_str_atoi ( pointeur_char[j] ));
  1587. }
  1588. g_strfreev ( pointeur_char );
  1589. i++;
  1590. continue;
  1591. }
  1592. if ( !strcmp ( attribute_names[i],
  1593. "Form_columns_number" ))
  1594. {
  1595. gsb_data_form_new_organization (account_number);
  1596. gsb_data_form_set_nb_columns ( account_number,
  1597. utils_str_atoi ( attribute_values[i]));
  1598. i++;
  1599. continue;
  1600. }
  1601. if ( !strcmp ( attribute_names[i],
  1602. "Form_lines_number" ))
  1603. {
  1604. gsb_data_form_set_nb_rows ( account_number,
  1605. utils_str_atoi ( attribute_values[i]));
  1606. i++;
  1607. continue;
  1608. }
  1609. if ( !strcmp ( attribute_names[i],
  1610. "Form_organization" ))
  1611. {
  1612. gchar **pointeur_char;
  1613. gint k, j;
  1614. pointeur_char = g_strsplit ( attribute_values[i],
  1615. "-",
  1616. 0 );
  1617. for ( k=0 ; k<MAX_HEIGHT ; k++ )
  1618. for ( j=0 ; j<MAX_WIDTH ; j++ )
  1619. gsb_data_form_set_value ( account_number,
  1620. j, k,
  1621. utils_str_atoi ( pointeur_char[j + k*MAX_WIDTH]));
  1622. g_strfreev ( pointeur_char );
  1623. i++;
  1624. continue;
  1625. }
  1626. if ( !strcmp ( attribute_names[i],
  1627. "Form_columns_width" ))
  1628. {
  1629. gchar **pointeur_char;
  1630. gint j;
  1631. pointeur_char = g_strsplit ( attribute_values[i],
  1632. "-",
  1633. 0 );
  1634. for ( j=0 ; j<MAX_WIDTH ; j++ )
  1635. gsb_data_form_set_width_column ( account_number,
  1636. j,
  1637. utils_str_atoi ( pointeur_char[j]));
  1638. g_strfreev ( pointeur_char );
  1639. i++;
  1640. continue;
  1641. }
  1642. if ( !strcmp ( attribute_names[i], "Bet_use_budget" ))
  1643. {
  1644. gsb_data_account_set_bet_use_budget ( account_number,
  1645. utils_str_atoi ( attribute_values[i] ) );
  1646. i++;
  1647. continue;
  1648. }
  1649. if ( !strcmp ( attribute_names[i], "Bet_start_date" ))
  1650. {
  1651. gsb_data_account_set_bet_start_date ( account_number,
  1652. gsb_parse_date_string_safe ( attribute_values[i] ) );
  1653. i++;
  1654. continue;
  1655. }
  1656. if ( !strcmp ( attribute_names[i], "Bet_months" ))
  1657. {
  1658. gsb_data_account_set_bet_months ( account_number,
  1659. utils_str_atoi ( attribute_values[i] ) );
  1660. i++;
  1661. continue;
  1662. }
  1663. if ( !strcmp ( attribute_names[i], "Bet_UT" ))
  1664. {
  1665. gsb_data_account_set_bet_spin_range ( account_number,
  1666. utils_str_atoi ( attribute_values[i] ) );
  1667. i++;
  1668. continue;
  1669. }
  1670. if ( !strcmp ( attribute_names[i], "Bet_auto_inc_month" ))
  1671. {
  1672. gboolean auto_inc_month;
  1673. auto_inc_month = utils_str_atoi ( attribute_values[i] );
  1674. gsb_data_account_set_bet_auto_inc_month ( account_number, auto_inc_month );
  1675. if ( auto_inc_month )
  1676. gsb_data_account_bet_update_initial_date_if_necessary ( account_number );
  1677. i++;
  1678. continue;
  1679. }
  1680. if ( !strcmp ( attribute_names[i], "Bet_select_transaction_label" ))
  1681. {
  1682. gsb_data_account_set_bet_select_label ( account_number,
  1683. SPP_ORIGIN_TRANSACTION,
  1684. utils_str_atoi ( attribute_values[i] ) );
  1685. i++;
  1686. continue;
  1687. }
  1688. if ( !strcmp ( attribute_names[i], "Bet_select_scheduled_label" ))
  1689. {
  1690. gsb_data_account_set_bet_select_label ( account_number,
  1691. SPP_ORIGIN_SCHEDULED,
  1692. utils_str_atoi ( attribute_values[i] ) );
  1693. i++;
  1694. continue;
  1695. }
  1696. if ( !strcmp ( attribute_names[i], "Bet_select_futur_label" ))
  1697. {
  1698. gsb_data_account_set_bet_select_label ( account_number,
  1699. SPP_ORIGIN_FUTURE,
  1700. utils_str_atoi ( attribute_values[i] ) );
  1701. i++;
  1702. continue;
  1703. }
  1704. if ( !strcmp ( attribute_names[i], "Bet_SD" ))
  1705. {
  1706. gsb_data_account_set_bet_hist_data ( account_number,
  1707. utils_str_atoi ( attribute_values[i] ) );
  1708. i++;
  1709. continue;
  1710. }
  1711. if ( !strcmp ( attribute_names[i], "Bet_Fi" ))
  1712. {
  1713. gsb_data_account_set_bet_hist_fyear ( account_number,
  1714. utils_str_atoi ( attribute_values[i] ) );
  1715. i++;
  1716. continue;
  1717. }
  1718. if ( !strcmp ( attribute_names[i], "Bet_capital" ))
  1719. {
  1720. gsb_data_account_set_bet_finance_capital ( account_number,
  1721. g_ascii_strtod ( attribute_values[i], NULL ) );
  1722. i++;
  1723. continue;
  1724. }
  1725. if ( !strcmp ( attribute_names[i], "Bet_taux_annuel" ))
  1726. {
  1727. gsb_data_account_set_bet_finance_taux_annuel ( account_number,
  1728. g_ascii_strtod ( attribute_values[i], NULL ) );
  1729. i++;
  1730. continue;
  1731. }
  1732. if ( !strcmp ( attribute_names[i], "Bet_frais" ))
  1733. {
  1734. gsb_data_account_set_bet_finance_frais ( account_number,
  1735. g_ascii_strtod ( attribute_values[i], NULL ) );
  1736. i++;
  1737. continue;
  1738. }
  1739. if ( !strcmp ( attribute_names[i], "Bet_type_taux" ))
  1740. {
  1741. gsb_data_account_set_bet_finance_type_taux ( account_number,
  1742. utils_str_atoi ( attribute_values[i] ) );
  1743. i++;
  1744. continue;
  1745. }
  1746. /* normally, shouldn't come here */
  1747. i++;
  1748. }
  1749. while ( attribute_names[i] );
  1750. }
  1751. /**
  1752. * load the payment part in the grisbi file
  1753. *
  1754. * \param attribute_names
  1755. * \param attribute_values
  1756. *
  1757. * */
  1758. void gsb_file_load_payment_part ( const gchar **attribute_names,
  1759. const gchar **attribute_values )
  1760. {
  1761. gint i=0;
  1762. gint payment_number;
  1763. if ( !attribute_names[i] )
  1764. return;
  1765. payment_number = gsb_data_payment_new (NULL);
  1766. do
  1767. {
  1768. /* we test at the beginning if the attribute_value is NULL, if yes, */
  1769. /* go to the next */
  1770. if ( !strcmp (attribute_values[i],
  1771. "(null)"))
  1772. {
  1773. i++;
  1774. continue;
  1775. }
  1776. if ( !strcmp ( attribute_names[i],
  1777. "Number" ))
  1778. {
  1779. payment_number = gsb_data_payment_set_new_number ( payment_number,
  1780. utils_str_atoi (attribute_values[i]));
  1781. i++;
  1782. continue;
  1783. }
  1784. if ( !strcmp ( attribute_names[i],
  1785. "Name" ))
  1786. {
  1787. gsb_data_payment_set_name ( payment_number,
  1788. attribute_values[i]);
  1789. i++;
  1790. continue;
  1791. }
  1792. if ( !strcmp ( attribute_names[i],
  1793. "Sign" ))
  1794. {
  1795. gsb_data_payment_set_sign ( payment_number,
  1796. utils_str_atoi (attribute_values[i]));
  1797. i++;
  1798. continue;
  1799. }
  1800. if ( !strcmp ( attribute_names[i],
  1801. "Show_entry" ))
  1802. {
  1803. gsb_data_payment_set_show_entry ( payment_number,
  1804. utils_str_atoi (attribute_values[i]));
  1805. i++;
  1806. continue;
  1807. }
  1808. if ( !strcmp ( attribute_names[i],
  1809. "Automatic_number" ))
  1810. {
  1811. gsb_data_payment_set_automatic_numbering ( payment_number,
  1812. utils_str_atoi (attribute_values[i]));
  1813. i++;
  1814. continue;
  1815. }
  1816. if ( !strcmp ( attribute_names[i],
  1817. "Current_number" ))
  1818. {
  1819. gsb_data_payment_set_last_number ( payment_number,
  1820. attribute_values[i] );
  1821. i++;
  1822. continue;
  1823. }
  1824. if ( !strcmp ( attribute_names[i],
  1825. "Account" ))
  1826. {
  1827. gsb_data_payment_set_account_number ( payment_number,
  1828. utils_str_atoi (attribute_values[i]));
  1829. i++;
  1830. continue;
  1831. }
  1832. /* normally, shouldn't come here */
  1833. i++;
  1834. }
  1835. while ( attribute_names[i] );
  1836. }
  1837. /**
  1838. * load the transactions in the grisbi file
  1839. *
  1840. * \param attribute_names
  1841. * \param attribute_values
  1842. *
  1843. * */
  1844. void gsb_file_load_transactions ( const gchar **attribute_names,
  1845. const gchar **attribute_values )
  1846. {
  1847. gint i=0;
  1848. gint transaction_number = 0;
  1849. gint account_number = 0;
  1850. if ( !attribute_names[i] )
  1851. return;
  1852. do
  1853. {
  1854. /* we test at the beginning if the attribute_value is NULL, if yes, */
  1855. /* go to the next */
  1856. if ( !strcmp (attribute_values[i],
  1857. "(null)"))
  1858. {
  1859. i++;
  1860. continue;
  1861. }
  1862. if ( !strcmp ( attribute_names[i],
  1863. "Ac" ))
  1864. {
  1865. account_number = utils_str_atoi (attribute_values[i]);
  1866. i++;
  1867. continue;
  1868. }
  1869. if ( !strcmp ( attribute_names[i],
  1870. "Nb" ))
  1871. {
  1872. transaction_number = gsb_data_transaction_new_transaction_with_number ( account_number,
  1873. utils_str_atoi (attribute_values[i]));
  1874. i++;
  1875. continue;
  1876. }
  1877. if ( !strcmp ( attribute_names[i],
  1878. "Id" ))
  1879. {
  1880. gsb_data_transaction_set_transaction_id ( transaction_number,
  1881. attribute_values[i]);
  1882. i++;
  1883. continue;
  1884. }
  1885. if ( !strcmp ( attribute_names[i],
  1886. "Dt" ))
  1887. {
  1888. gsb_data_transaction_set_date ( transaction_number,
  1889. gsb_parse_date_string_safe (attribute_values[i]));
  1890. i++;
  1891. continue;
  1892. }
  1893. if ( !strcmp ( attribute_names[i],
  1894. "Dv" ))
  1895. {
  1896. gsb_data_transaction_set_value_date ( transaction_number,
  1897. gsb_parse_date_string_safe (attribute_values[i]));
  1898. i++;
  1899. continue;
  1900. }
  1901. if ( !strcmp ( attribute_names[i],
  1902. "Cu" ))
  1903. {
  1904. gsb_data_transaction_set_currency_number ( transaction_number,
  1905. utils_str_atoi (attribute_values[i]));
  1906. i++;
  1907. continue;
  1908. }
  1909. if ( !strcmp ( attribute_names[i],
  1910. "Am" ))
  1911. {
  1912. /* get the entire real, even if the floating point of the currency is less deep */
  1913. gsb_data_transaction_set_amount ( transaction_number,
  1914. gsb_real_safe_real_from_string (attribute_values[i]));
  1915. i++;
  1916. continue;
  1917. }
  1918. if ( !strcmp ( attribute_names[i],
  1919. "Exb" ))
  1920. {
  1921. gsb_data_transaction_set_change_between ( transaction_number,
  1922. utils_str_atoi (attribute_values[i]));
  1923. i++;
  1924. continue;
  1925. }
  1926. if ( !strcmp ( attribute_names[i],
  1927. "Exr" ))
  1928. {
  1929. gsb_data_transaction_set_exchange_rate ( transaction_number,
  1930. gsb_real_safe_real_from_string (attribute_values[i]));
  1931. i++;
  1932. continue;
  1933. }
  1934. if ( !strcmp ( attribute_names[i],
  1935. "Exf" ))
  1936. {
  1937. gsb_data_transaction_set_exchange_fees ( transaction_number,
  1938. gsb_real_safe_real_from_string (attribute_values[i]));
  1939. i++;
  1940. continue;
  1941. }
  1942. if ( !strcmp ( attribute_names[i],
  1943. "Pa" ))
  1944. {
  1945. gsb_data_transaction_set_party_number ( transaction_number,
  1946. utils_str_atoi (attribute_values[i]));
  1947. i++;
  1948. continue;
  1949. }
  1950. if ( !strcmp ( attribute_names[i],
  1951. "Ca" ))
  1952. {
  1953. gsb_data_transaction_set_category_number ( transaction_number,
  1954. utils_str_atoi (attribute_values[i]));
  1955. i++;
  1956. continue;
  1957. }
  1958. if ( !strcmp ( attribute_names[i],
  1959. "Sca" ))
  1960. {
  1961. gsb_data_transaction_set_sub_category_number ( transaction_number,
  1962. utils_str_atoi (attribute_values[i]));
  1963. i++;
  1964. continue;
  1965. }
  1966. if ( !strcmp ( attribute_names[i],
  1967. "Br" ))
  1968. {
  1969. gsb_data_transaction_set_split_of_transaction ( transaction_number,
  1970. utils_str_atoi (attribute_values[i]));
  1971. i++;
  1972. continue;
  1973. }
  1974. if ( !strcmp ( attribute_names[i],
  1975. "No" ))
  1976. {
  1977. gsb_data_transaction_set_notes ( transaction_number,
  1978. attribute_values[i]);
  1979. i++;
  1980. continue;
  1981. }
  1982. if ( !strcmp ( attribute_names[i],
  1983. "Pn" ))
  1984. {
  1985. gsb_data_transaction_set_method_of_payment_number ( transaction_number,
  1986. utils_str_atoi (attribute_values[i]));
  1987. i++;
  1988. continue;
  1989. }
  1990. if ( !strcmp ( attribute_names[i],
  1991. "Pc" ))
  1992. {
  1993. gsb_data_transaction_set_method_of_payment_content ( transaction_number,
  1994. attribute_values[i]);
  1995. i++;
  1996. continue;
  1997. }
  1998. if ( !strcmp ( attribute_names[i],
  1999. "Ma" ))
  2000. {
  2001. gsb_data_transaction_set_marked_transaction ( transaction_number,
  2002. utils_str_atoi (attribute_values[i]));
  2003. i++;
  2004. continue;
  2005. }
  2006. if ( !strcmp ( attribute_names[i],
  2007. "Ar" ))
  2008. {
  2009. gsb_data_transaction_set_archive_number ( transaction_number,
  2010. utils_str_atoi (attribute_values[i]));
  2011. i++;
  2012. continue;
  2013. }
  2014. if ( !strcmp ( attribute_names[i],
  2015. "Au" ))
  2016. {
  2017. gsb_data_transaction_set_automatic_transaction ( transaction_number,
  2018. utils_str_atoi (attribute_values[i]));
  2019. i++;
  2020. continue;
  2021. }
  2022. if ( !strcmp ( attribute_names[i],
  2023. "Re" ))
  2024. {
  2025. gsb_data_transaction_set_reconcile_number ( transaction_number,
  2026. utils_str_atoi (attribute_values[i]));
  2027. i++;
  2028. continue;
  2029. }
  2030. if ( !strcmp ( attribute_names[i],
  2031. "Fi" ))
  2032. {
  2033. gsb_data_transaction_set_financial_year_number ( transaction_number,
  2034. utils_str_atoi (attribute_values[i]));
  2035. i++;
  2036. continue;
  2037. }
  2038. if ( !strcmp ( attribute_names[i],
  2039. "Bu" ))
  2040. {
  2041. gsb_data_transaction_set_budgetary_number ( transaction_number,
  2042. utils_str_atoi (attribute_values[i]));
  2043. i++;
  2044. continue;
  2045. }
  2046. if ( !strcmp ( attribute_names[i],
  2047. "Sbu" ))
  2048. {
  2049. gsb_data_transaction_set_sub_budgetary_number ( transaction_number,
  2050. utils_str_atoi (attribute_values[i]));
  2051. i++;
  2052. continue;
  2053. }
  2054. if ( !strcmp ( attribute_names[i],
  2055. "Vo" ))
  2056. {
  2057. gsb_data_transaction_set_voucher ( transaction_number,
  2058. attribute_values[i]);
  2059. i++;
  2060. continue;
  2061. }
  2062. if ( !strcmp ( attribute_names[i],
  2063. "Ba" ))
  2064. {
  2065. gsb_data_transaction_set_bank_references ( transaction_number,
  2066. attribute_values[i]);
  2067. i++;
  2068. continue;
  2069. }
  2070. if ( !strcmp ( attribute_names[i],
  2071. "Trt" ))
  2072. {
  2073. gsb_data_transaction_set_contra_transaction_number ( transaction_number,
  2074. utils_str_atoi (attribute_values[i]));
  2075. i++;
  2076. continue;
  2077. }
  2078. if ( !strcmp ( attribute_names[i],
  2079. "Mo" ))
  2080. {
  2081. gsb_data_transaction_set_mother_transaction_number ( transaction_number,
  2082. utils_str_atoi (attribute_values[i]));
  2083. i++;
  2084. continue;
  2085. }
  2086. /* normally, shouldn't come here */
  2087. i++;
  2088. }
  2089. while ( attribute_names[i] );
  2090. }
  2091. /**
  2092. * load the scheduled transactions in the grisbi file
  2093. *
  2094. * \param attribute_names
  2095. * \param attribute_values
  2096. *
  2097. * */
  2098. void gsb_file_load_scheduled_transactions ( const gchar **attribute_names,
  2099. const gchar **attribute_values )
  2100. {
  2101. gint i=0;
  2102. gint scheduled_number = 0;
  2103. if ( !attribute_names[i] )
  2104. return;
  2105. do
  2106. {
  2107. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2108. /* go to the next */
  2109. if ( !strcmp (attribute_values[i],
  2110. "(null)"))
  2111. {
  2112. i++;
  2113. continue;
  2114. }
  2115. if ( !strcmp ( attribute_names[i],
  2116. "Nb" ))
  2117. {
  2118. scheduled_number = gsb_data_scheduled_new_scheduled_with_number (utils_str_atoi (attribute_values[i]));
  2119. i++;
  2120. continue;
  2121. }
  2122. if ( !strcmp ( attribute_names[i],
  2123. "Dt" ))
  2124. {
  2125. gsb_data_scheduled_set_date ( scheduled_number,
  2126. gsb_parse_date_string_safe (attribute_values[i]));
  2127. i++;
  2128. continue;
  2129. }
  2130. if ( !strcmp ( attribute_names[i],
  2131. "Ac" ))
  2132. {
  2133. gsb_data_scheduled_set_account_number ( scheduled_number,
  2134. utils_str_atoi (attribute_values[i]));
  2135. i++;
  2136. continue;
  2137. }
  2138. if ( !strcmp ( attribute_names[i],
  2139. "Am" ))
  2140. {
  2141. gsb_data_scheduled_set_amount ( scheduled_number,
  2142. gsb_real_safe_real_from_string (attribute_values[i]));
  2143. i++;
  2144. continue;
  2145. }
  2146. if ( !strcmp ( attribute_names[i],
  2147. "Cu" ))
  2148. {
  2149. gsb_data_scheduled_set_currency_number ( scheduled_number,
  2150. utils_str_atoi (attribute_values[i]));
  2151. i++;
  2152. continue;
  2153. }
  2154. if ( !strcmp ( attribute_names[i],
  2155. "Pa" ))
  2156. {
  2157. gsb_data_scheduled_set_party_number ( scheduled_number,
  2158. utils_str_atoi (attribute_values[i]));
  2159. i++;
  2160. continue;
  2161. }
  2162. if ( !strcmp ( attribute_names[i],
  2163. "Ca" ))
  2164. {
  2165. gsb_data_scheduled_set_category_number ( scheduled_number,
  2166. utils_str_atoi (attribute_values[i]));
  2167. i++;
  2168. continue;
  2169. }
  2170. if ( !strcmp ( attribute_names[i],
  2171. "Sca" ))
  2172. {
  2173. gsb_data_scheduled_set_sub_category_number ( scheduled_number,
  2174. utils_str_atoi (attribute_values[i]));
  2175. i++;
  2176. continue;
  2177. }
  2178. if ( !strcmp ( attribute_names[i],
  2179. "Tra" ))
  2180. {
  2181. gsb_data_scheduled_set_account_number_transfer ( scheduled_number,
  2182. utils_str_atoi (attribute_values[i]));
  2183. i++;
  2184. continue;
  2185. }
  2186. if ( !strcmp ( attribute_names[i],
  2187. "Pn" ))
  2188. {
  2189. gsb_data_scheduled_set_method_of_payment_number ( scheduled_number,
  2190. utils_str_atoi (attribute_values[i]));
  2191. i++;
  2192. continue;
  2193. }
  2194. if ( !strcmp ( attribute_names[i],
  2195. "CPn" ))
  2196. {
  2197. gsb_data_scheduled_set_contra_method_of_payment_number ( scheduled_number,
  2198. utils_str_atoi (attribute_values[i]));
  2199. i++;
  2200. continue;
  2201. }
  2202. if ( !strcmp ( attribute_names[i],
  2203. "Pc" ))
  2204. {
  2205. gsb_data_scheduled_set_method_of_payment_content ( scheduled_number,
  2206. attribute_values[i]);
  2207. i++;
  2208. continue;
  2209. }
  2210. if ( !strcmp ( attribute_names[i],
  2211. "Fi" ))
  2212. {
  2213. gsb_data_scheduled_set_financial_year_number ( scheduled_number,
  2214. utils_str_atoi (attribute_values[i]));
  2215. i++;
  2216. continue;
  2217. }
  2218. if ( !strcmp ( attribute_names[i],
  2219. "Bu" ))
  2220. {
  2221. gsb_data_scheduled_set_budgetary_number ( scheduled_number,
  2222. utils_str_atoi (attribute_values[i]));
  2223. i++;
  2224. continue;
  2225. }
  2226. if ( !strcmp ( attribute_names[i],
  2227. "Sbu" ))
  2228. {
  2229. gsb_data_scheduled_set_sub_budgetary_number ( scheduled_number,
  2230. utils_str_atoi (attribute_values[i]));
  2231. i++;
  2232. continue;
  2233. }
  2234. if ( !strcmp ( attribute_names[i],
  2235. "No" ))
  2236. {
  2237. gsb_data_scheduled_set_notes ( scheduled_number,
  2238. attribute_values[i]);
  2239. i++;
  2240. continue;
  2241. }
  2242. if ( !strcmp ( attribute_names[i],
  2243. "Au" ))
  2244. {
  2245. gsb_data_scheduled_set_automatic_scheduled ( scheduled_number,
  2246. utils_str_atoi (attribute_values[i]));
  2247. i++;
  2248. continue;
  2249. }
  2250. if ( !strcmp ( attribute_names[i],
  2251. "Pe" ))
  2252. {
  2253. gsb_data_scheduled_set_frequency ( scheduled_number,
  2254. utils_str_atoi (attribute_values[i]));
  2255. i++;
  2256. continue;
  2257. }
  2258. if ( !strcmp ( attribute_names[i],
  2259. "Pei" ))
  2260. {
  2261. gsb_data_scheduled_set_user_interval ( scheduled_number,
  2262. utils_str_atoi (attribute_values[i]));
  2263. i++;
  2264. continue;
  2265. }
  2266. if ( !strcmp ( attribute_names[i],
  2267. "Pep" ))
  2268. {
  2269. gsb_data_scheduled_set_user_entry ( scheduled_number,
  2270. utils_str_atoi (attribute_values[i]));
  2271. i++;
  2272. continue;
  2273. }
  2274. if ( !strcmp ( attribute_names[i],
  2275. "Dtl" ))
  2276. {
  2277. GDate *date;
  2278. date = gsb_parse_date_string_safe (attribute_values[i]);
  2279. gsb_data_scheduled_set_limit_date ( scheduled_number,
  2280. date);
  2281. if (date)
  2282. g_date_free (date);
  2283. i++;
  2284. continue;
  2285. }
  2286. if ( !strcmp ( attribute_names[i],
  2287. "Br" ))
  2288. {
  2289. gsb_data_scheduled_set_split_of_scheduled ( scheduled_number,
  2290. utils_str_atoi (attribute_values[i]));
  2291. i++;
  2292. continue;
  2293. }
  2294. if ( !strcmp ( attribute_names[i],
  2295. "Mo" ))
  2296. {
  2297. gsb_data_scheduled_set_mother_scheduled_number ( scheduled_number,
  2298. utils_str_atoi (attribute_values[i]));
  2299. i++;
  2300. continue;
  2301. }
  2302. /* normally, shouldn't come here */
  2303. i++;
  2304. }
  2305. while ( attribute_names[i] );
  2306. }
  2307. /**
  2308. * load the parties in the grisbi file
  2309. *
  2310. * \param attribute_names
  2311. * \param attribute_values
  2312. *
  2313. * */
  2314. void gsb_file_load_party ( const gchar **attribute_names,
  2315. const gchar **attribute_values )
  2316. {
  2317. gint i=0;
  2318. gint payee_number;
  2319. if ( !attribute_names[i] )
  2320. return;
  2321. payee_number = gsb_data_payee_new (NULL);
  2322. do
  2323. {
  2324. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2325. /* go to the next */
  2326. if ( !strcmp (attribute_values[i],
  2327. "(null)"))
  2328. {
  2329. i++;
  2330. continue;
  2331. }
  2332. if ( !strcmp ( attribute_names[i],
  2333. "Nb" ))
  2334. {
  2335. payee_number = gsb_data_payee_set_new_number ( payee_number,
  2336. utils_str_atoi (attribute_values[i]));
  2337. i++;
  2338. continue;
  2339. }
  2340. if ( !strcmp ( attribute_names[i],
  2341. "Na" ))
  2342. {
  2343. gsb_data_payee_set_name ( payee_number,
  2344. attribute_values[i]);
  2345. i++;
  2346. continue;
  2347. }
  2348. if ( !strcmp ( attribute_names[i],
  2349. "Txt" ))
  2350. {
  2351. gsb_data_payee_set_description ( payee_number,
  2352. attribute_values[i]);
  2353. i++;
  2354. continue;
  2355. }
  2356. if ( !strcmp ( attribute_names[i],
  2357. "Search" ))
  2358. {
  2359. if ( attribute_values[i] && strlen (attribute_values[i]) > 0 )
  2360. {
  2361. gsb_data_payee_set_search_string ( payee_number,
  2362. attribute_values[i]);
  2363. gsb_import_associations_list_append_assoc ( payee_number,
  2364. attribute_values[i] );
  2365. }
  2366. i++;
  2367. continue;
  2368. }
  2369. /* normally, shouldn't come here */
  2370. i++;
  2371. }
  2372. while ( attribute_names[i] );
  2373. }
  2374. /**
  2375. * load the categories in the grisbi file
  2376. *
  2377. * \param attribute_names
  2378. * \param attribute_values
  2379. *
  2380. * */
  2381. void gsb_file_load_category ( const gchar **attribute_names,
  2382. const gchar **attribute_values )
  2383. {
  2384. gint i=0;
  2385. if ( buffer_new_div_sous_div )
  2386. g_free ( buffer_new_div_sous_div );
  2387. buffer_new_div_sous_div = g_malloc0 ( sizeof ( struct new_div_sous_div_struct ) );
  2388. if ( !attribute_names[i] )
  2389. return;
  2390. do
  2391. {
  2392. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2393. /* go to the next */
  2394. if ( !strcmp (attribute_values[i],
  2395. "(null)"))
  2396. {
  2397. i++;
  2398. continue;
  2399. }
  2400. if ( !strcmp ( attribute_names[i],
  2401. "Nb" ))
  2402. {
  2403. buffer_new_div_sous_div -> no_div = utils_str_atoi ( attribute_values[i] );
  2404. i++;
  2405. continue;
  2406. }
  2407. if ( !strcmp ( attribute_names[i],
  2408. "Na" ))
  2409. {
  2410. buffer_new_div_sous_div -> name = g_strdup ( attribute_values[i] );
  2411. i++;
  2412. continue;
  2413. }
  2414. if ( !strcmp ( attribute_names[i],
  2415. "Kd" ))
  2416. {
  2417. buffer_new_div_sous_div -> type = utils_str_atoi ( attribute_values[i] );
  2418. i++;
  2419. continue;
  2420. }
  2421. /* normally, shouldn't come here */
  2422. i++;
  2423. }
  2424. while ( attribute_names[i] );
  2425. buffer_new_div_sous_div -> new_no_div = gsb_data_category_test_create_category (
  2426. buffer_new_div_sous_div -> no_div,
  2427. buffer_new_div_sous_div -> name,
  2428. buffer_new_div_sous_div -> type );
  2429. }
  2430. /**
  2431. * load the sub-categories in the grisbi file
  2432. *
  2433. * \param attribute_names
  2434. * \param attribute_values
  2435. *
  2436. * */
  2437. void gsb_file_load_sub_category ( const gchar **attribute_names,
  2438. const gchar **attribute_values)
  2439. {
  2440. gint i=0;
  2441. gint category_number = 0;
  2442. if ( !attribute_names[i] )
  2443. return;
  2444. do
  2445. {
  2446. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2447. /* go to the next */
  2448. if ( !strcmp (attribute_values[i],
  2449. "(null)"))
  2450. {
  2451. i++;
  2452. continue;
  2453. }
  2454. if ( !strcmp ( attribute_names[i],
  2455. "Nbc" ))
  2456. {
  2457. category_number = utils_str_atoi (attribute_values[i]);
  2458. i++;
  2459. continue;
  2460. }
  2461. if ( !strcmp ( attribute_names[i],
  2462. "Nb" ))
  2463. {
  2464. if ( category_number == buffer_new_div_sous_div -> no_div )
  2465. buffer_new_div_sous_div -> no_sub_div = utils_str_atoi ( attribute_values[i] );
  2466. i++;
  2467. continue;
  2468. }
  2469. if ( !strcmp ( attribute_names[i],
  2470. "Na" ))
  2471. {
  2472. if ( category_number == buffer_new_div_sous_div -> no_div )
  2473. buffer_new_div_sous_div -> name = g_strdup ( attribute_values[i] );
  2474. i++;
  2475. continue;
  2476. }
  2477. /* normally, shouldn't come here */
  2478. i++;
  2479. }
  2480. while ( attribute_names[i] );
  2481. if ( !gsb_data_category_test_create_sub_category (
  2482. buffer_new_div_sous_div -> new_no_div,
  2483. buffer_new_div_sous_div -> no_sub_div,
  2484. buffer_new_div_sous_div -> name ) )
  2485. {
  2486. gchar *tmpstr = g_strdup_printf ( "no_category = %d no_sub_category = %d nom = %s\n",
  2487. buffer_new_div_sous_div -> new_no_div,
  2488. buffer_new_div_sous_div -> no_sub_div,
  2489. buffer_new_div_sous_div -> name );
  2490. devel_debug ( tmpstr );
  2491. }
  2492. }
  2493. /**
  2494. * load the budgetaries in the grisbi file
  2495. *
  2496. * \param attribute_names
  2497. * \param attribute_values
  2498. *
  2499. * */
  2500. void gsb_file_load_budgetary ( const gchar **attribute_names,
  2501. const gchar **attribute_values )
  2502. {
  2503. gint i=0;
  2504. gint budget_number = 0;
  2505. if ( !attribute_names[i] )
  2506. return;
  2507. do
  2508. {
  2509. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2510. /* go to the next */
  2511. if ( !strcmp (attribute_values[i],
  2512. "(null)"))
  2513. {
  2514. i++;
  2515. continue;
  2516. }
  2517. if ( !strcmp ( attribute_names[i],
  2518. "Nb" ))
  2519. {
  2520. budget_number = gsb_data_budget_new_with_number ( utils_str_atoi (attribute_values[i]));
  2521. i++;
  2522. continue;
  2523. }
  2524. if ( !strcmp ( attribute_names[i],
  2525. "Na" ))
  2526. {
  2527. gsb_data_budget_set_name ( budget_number,
  2528. attribute_values[i]);
  2529. i++;
  2530. continue;
  2531. }
  2532. if ( !strcmp ( attribute_names[i],
  2533. "Kd" ))
  2534. {
  2535. gsb_data_budget_set_type ( budget_number,
  2536. utils_str_atoi (attribute_values[i]));
  2537. i++;
  2538. continue;
  2539. }
  2540. /* normally, shouldn't come here */
  2541. i++;
  2542. }
  2543. while ( attribute_names[i] );
  2544. }
  2545. /**
  2546. * load the sub-budgetaries in the grisbi file
  2547. *
  2548. * \param attribute_names
  2549. * \param attribute_values
  2550. *
  2551. * */
  2552. void gsb_file_load_sub_budgetary ( const gchar **attribute_names,
  2553. const gchar **attribute_values)
  2554. {
  2555. gint i=0;
  2556. gint budget_number = 0;
  2557. gint sub_budget_number = 0;
  2558. if ( !attribute_names[i] )
  2559. return;
  2560. do
  2561. {
  2562. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2563. /* go to the next */
  2564. if ( !strcmp (attribute_values[i],
  2565. "(null)"))
  2566. {
  2567. i++;
  2568. continue;
  2569. }
  2570. if ( !strcmp ( attribute_names[i], "Nbb" )
  2571. ||
  2572. !strcmp ( attribute_names[i], "Nbc" ) )
  2573. {
  2574. budget_number = utils_str_atoi (attribute_values[i]);
  2575. i++;
  2576. continue;
  2577. }
  2578. if ( !strcmp ( attribute_names[i],
  2579. "Nb" ))
  2580. {
  2581. sub_budget_number = gsb_data_budget_new_sub_budget_with_number ( utils_str_atoi (attribute_values[i]),
  2582. budget_number );
  2583. i++;
  2584. continue;
  2585. }
  2586. if ( !strcmp ( attribute_names[i],
  2587. "Na" ))
  2588. {
  2589. gsb_data_budget_set_sub_budget_name ( budget_number,
  2590. sub_budget_number,
  2591. attribute_values[i] );
  2592. i++;
  2593. continue;
  2594. }
  2595. /* normally, shouldn't come here */
  2596. i++;
  2597. }
  2598. while ( attribute_names[i] );
  2599. }
  2600. /**
  2601. * load the currencies in the grisbi file
  2602. *
  2603. * \param attribute_names
  2604. * \param attribute_values
  2605. *
  2606. * */
  2607. void gsb_file_load_currency ( const gchar **attribute_names,
  2608. const gchar **attribute_values )
  2609. {
  2610. gint i=0;
  2611. gint currency_number;
  2612. if ( !attribute_names[i] )
  2613. return;
  2614. currency_number = gsb_data_currency_new (NULL);
  2615. /* Default */
  2616. gsb_data_currency_set_floating_point ( currency_number, 2 );
  2617. do
  2618. {
  2619. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2620. /* go to the next */
  2621. if ( !strcmp (attribute_values[i],
  2622. "(null)"))
  2623. {
  2624. i++;
  2625. continue;
  2626. }
  2627. if ( !strcmp ( attribute_names[i],
  2628. "Nb" ))
  2629. {
  2630. currency_number = gsb_data_currency_set_new_number ( currency_number,
  2631. utils_str_atoi (attribute_values[i]));
  2632. i++;
  2633. continue;
  2634. }
  2635. if ( !strcmp ( attribute_names[i],
  2636. "Na" ))
  2637. {
  2638. gsb_data_currency_set_name ( currency_number,
  2639. attribute_values[i]);
  2640. i++;
  2641. continue;
  2642. }
  2643. if ( !strcmp ( attribute_names[i],
  2644. "Co" ))
  2645. {
  2646. struct iso_4217_currency * currency = iso_4217_currencies;
  2647. gsb_data_currency_set_code ( currency_number, attribute_values[i]);
  2648. /* Check if a iso code is the same as currency code (old import). */
  2649. while ( currency -> country_name )
  2650. {
  2651. if ( !strcmp ( currency -> currency_code, attribute_values[i] ) )
  2652. {
  2653. gsb_data_currency_set_code_iso4217 ( currency_number,
  2654. attribute_values[i]);
  2655. }
  2656. currency++;
  2657. }
  2658. i++;
  2659. continue;
  2660. }
  2661. if ( !strcmp ( attribute_names[i],
  2662. "Ico" ))
  2663. {
  2664. gsb_data_currency_set_code_iso4217 ( currency_number,
  2665. attribute_values[i]);
  2666. i++;
  2667. continue;
  2668. }
  2669. if ( !strcmp ( attribute_names[i],
  2670. "Fl" ))
  2671. {
  2672. gsb_data_currency_set_floating_point ( currency_number,
  2673. utils_str_atoi (attribute_values[i]));
  2674. i++;
  2675. continue;
  2676. }
  2677. /* normally, shouldn't come here */
  2678. i++;
  2679. }
  2680. while ( attribute_names[i] );
  2681. /* initialization of the currency for the payees, categories and
  2682. * budgetary lines in case of need */
  2683. if ( no_devise_totaux_tiers == 0 )
  2684. {
  2685. GSList *tmp_list;
  2686. tmp_list = gsb_data_currency_get_currency_list ( );
  2687. if ( g_slist_length ( tmp_list ) > 0 )
  2688. no_devise_totaux_tiers = gsb_data_currency_get_no_currency (
  2689. g_slist_nth_data ( tmp_list, 0 ) );
  2690. }
  2691. if ( no_devise_totaux_categ == 0 )
  2692. {
  2693. GSList *tmp_list;
  2694. tmp_list = gsb_data_currency_get_currency_list ( );
  2695. if ( g_slist_length ( tmp_list ) > 0 )
  2696. no_devise_totaux_categ = gsb_data_currency_get_no_currency (
  2697. g_slist_nth_data ( tmp_list, 0 ) );
  2698. }
  2699. if ( no_devise_totaux_ib == 0 )
  2700. {
  2701. GSList *tmp_list;
  2702. tmp_list = gsb_data_currency_get_currency_list ( );
  2703. if ( g_slist_length ( tmp_list ) > 0 )
  2704. no_devise_totaux_ib = gsb_data_currency_get_no_currency (
  2705. g_slist_nth_data ( tmp_list, 0 ) );
  2706. }
  2707. }
  2708. /**
  2709. * load the currency_links in the grisbi file
  2710. *
  2711. * \param attribute_names
  2712. * \param attribute_values
  2713. *
  2714. * */
  2715. void gsb_file_load_currency_link ( const gchar **attribute_names,
  2716. const gchar **attribute_values )
  2717. {
  2718. gint i=0;
  2719. gint link_number;
  2720. if ( !attribute_names[i] )
  2721. return;
  2722. link_number = gsb_data_currency_link_new (0);
  2723. do
  2724. {
  2725. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2726. /* go to the next */
  2727. if ( !strcmp (attribute_values[i],
  2728. "(null)"))
  2729. {
  2730. i++;
  2731. continue;
  2732. }
  2733. if ( !strcmp ( attribute_names[i],
  2734. "Nb" ))
  2735. {
  2736. link_number = gsb_data_currency_link_set_new_number ( link_number,
  2737. utils_str_atoi (attribute_values[i]));
  2738. i++;
  2739. continue;
  2740. }
  2741. if ( !strcmp ( attribute_names[i],
  2742. "Cu1" ))
  2743. {
  2744. gsb_data_currency_link_set_first_currency ( link_number,
  2745. utils_str_atoi (attribute_values[i]));
  2746. i++;
  2747. continue;
  2748. }
  2749. if ( !strcmp ( attribute_names[i],
  2750. "Cu2" ))
  2751. {
  2752. gsb_data_currency_link_set_second_currency ( link_number,
  2753. utils_str_atoi (attribute_values[i]));
  2754. i++;
  2755. continue;
  2756. }
  2757. if ( !strcmp ( attribute_names[i],
  2758. "Ex" ))
  2759. {
  2760. gsb_data_currency_link_set_change_rate ( link_number,
  2761. gsb_real_safe_real_from_string (attribute_values[i]));
  2762. i++;
  2763. continue;
  2764. }
  2765. if ( !strcmp ( attribute_names[i], "Modified_date" ) )
  2766. {
  2767. gsb_data_currency_link_set_modified_date ( link_number,
  2768. gsb_parse_date_string_safe (attribute_values[i] ) );
  2769. i++;
  2770. continue;
  2771. }
  2772. if ( !strcmp ( attribute_names[i], "Fl" ))
  2773. {
  2774. gsb_data_currency_link_set_fixed_link ( link_number,
  2775. utils_str_atoi ( attribute_values[i] ) );
  2776. i++;
  2777. continue;
  2778. }
  2779. /* normally, shouldn't come here */
  2780. i++;
  2781. }
  2782. while ( attribute_names[i] );
  2783. }
  2784. /**
  2785. * load the banks in the grisbi file
  2786. *
  2787. * \param attribute_names
  2788. * \param attribute_values
  2789. *
  2790. * */
  2791. void gsb_file_load_bank ( const gchar **attribute_names,
  2792. const gchar **attribute_values )
  2793. {
  2794. gint i=0;
  2795. gint bank_number = 0;
  2796. if ( !attribute_names[i] )
  2797. return;
  2798. do
  2799. {
  2800. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2801. /* go to the next */
  2802. if ( !strcmp (attribute_values[i],
  2803. "(null)"))
  2804. {
  2805. i++;
  2806. continue;
  2807. }
  2808. if ( !strcmp ( attribute_names[i],
  2809. "Nb" ))
  2810. {
  2811. bank_number = gsb_data_bank_set_new_number ( gsb_data_bank_new (NULL),
  2812. utils_str_atoi (attribute_values[i]));
  2813. i++;
  2814. continue;
  2815. }
  2816. if ( !strcmp ( attribute_names[i],
  2817. "Na" ))
  2818. {
  2819. gsb_data_bank_set_name ( bank_number,
  2820. attribute_values[i] );
  2821. i++;
  2822. continue;
  2823. }
  2824. if ( !strcmp ( attribute_names[i],
  2825. "Co" ))
  2826. {
  2827. gsb_data_bank_set_code ( bank_number,
  2828. attribute_values[i] );
  2829. i++;
  2830. continue;
  2831. }
  2832. if ( !strcmp ( attribute_names[i],
  2833. "BIC" ))
  2834. {
  2835. gsb_data_bank_set_bic ( bank_number,
  2836. attribute_values[i] );
  2837. i++;
  2838. continue;
  2839. }
  2840. if ( !strcmp ( attribute_names[i],
  2841. "Adr" ))
  2842. {
  2843. gsb_data_bank_set_bank_address ( bank_number,
  2844. attribute_values[i] );
  2845. i++;
  2846. continue;
  2847. }
  2848. if ( !strcmp ( attribute_names[i],
  2849. "Tel" ))
  2850. {
  2851. gsb_data_bank_set_bank_tel ( bank_number,
  2852. attribute_values[i] );
  2853. i++;
  2854. continue;
  2855. }
  2856. if ( !strcmp ( attribute_names[i],
  2857. "Mail" ))
  2858. {
  2859. gsb_data_bank_set_bank_mail ( bank_number,
  2860. attribute_values[i] );
  2861. i++;
  2862. continue;
  2863. }
  2864. if ( !strcmp ( attribute_names[i],
  2865. "Web" ))
  2866. {
  2867. gsb_data_bank_set_bank_web ( bank_number,
  2868. attribute_values[i] );
  2869. i++;
  2870. continue;
  2871. }
  2872. if ( !strcmp ( attribute_names[i],
  2873. "Nac" ))
  2874. {
  2875. gsb_data_bank_set_correspondent_name ( bank_number,
  2876. attribute_values[i] );
  2877. i++;
  2878. continue;
  2879. }
  2880. if ( !strcmp ( attribute_names[i],
  2881. "Faxc" ))
  2882. {
  2883. gsb_data_bank_set_correspondent_fax ( bank_number,
  2884. attribute_values[i] );
  2885. i++;
  2886. continue;
  2887. }
  2888. if ( !strcmp ( attribute_names[i],
  2889. "Telc" ))
  2890. {
  2891. gsb_data_bank_set_correspondent_tel ( bank_number,
  2892. attribute_values[i] );
  2893. i++;
  2894. continue;
  2895. }
  2896. if ( !strcmp ( attribute_names[i],
  2897. "Mailc" ))
  2898. {
  2899. gsb_data_bank_set_correspondent_mail ( bank_number,
  2900. attribute_values[i] );
  2901. i++;
  2902. continue;
  2903. }
  2904. if ( !strcmp ( attribute_names[i],
  2905. "Rem" ))
  2906. {
  2907. gsb_data_bank_set_bank_note ( bank_number,
  2908. attribute_values[i] );
  2909. i++;
  2910. continue;
  2911. }
  2912. /* normally, shouldn't come here */
  2913. i++;
  2914. }
  2915. while ( attribute_names[i] );
  2916. }
  2917. /**
  2918. * load the financials years in the grisbi file
  2919. *
  2920. * \param attribute_names
  2921. * \param attribute_values
  2922. *
  2923. * */
  2924. void gsb_file_load_financial_year ( const gchar **attribute_names,
  2925. const gchar **attribute_values )
  2926. {
  2927. gint i=0;
  2928. gint fyear_number;
  2929. GDate *date;
  2930. if ( !attribute_names[i] )
  2931. return;
  2932. fyear_number = gsb_data_fyear_new (NULL);
  2933. do
  2934. {
  2935. /* we test at the beginning if the attribute_value is NULL, if yes, */
  2936. /* go to the next */
  2937. if ( !strcmp (attribute_values[i],
  2938. "(null)"))
  2939. {
  2940. i++;
  2941. continue;
  2942. }
  2943. if ( !strcmp ( attribute_names[i],
  2944. "Nb" ))
  2945. {
  2946. fyear_number = gsb_data_fyear_set_new_number (fyear_number,
  2947. utils_str_atoi (attribute_values[i]));
  2948. i++;
  2949. continue;
  2950. }
  2951. if ( !strcmp ( attribute_names[i],
  2952. "Na" ))
  2953. {
  2954. gsb_data_fyear_set_name ( fyear_number,
  2955. attribute_values[i]);
  2956. i++;
  2957. continue;
  2958. }
  2959. if ( !strcmp ( attribute_names[i],
  2960. "Bdte" ))
  2961. {
  2962. date = gsb_parse_date_string_safe (attribute_values[i]);
  2963. gsb_data_fyear_set_beginning_date ( fyear_number,
  2964. date );
  2965. if ( date )
  2966. {
  2967. g_date_free (date);
  2968. }
  2969. i++;
  2970. continue;
  2971. }
  2972. if ( !strcmp ( attribute_names[i],
  2973. "Edte" ))
  2974. {
  2975. date = gsb_parse_date_string_safe (attribute_values[i]);
  2976. gsb_data_fyear_set_end_date ( fyear_number,
  2977. date );
  2978. if ( date )
  2979. {
  2980. g_date_free (date);
  2981. }
  2982. i++;
  2983. continue;
  2984. }
  2985. if ( !strcmp ( attribute_names[i],
  2986. "Sho" ))
  2987. {
  2988. gsb_data_fyear_set_form_show ( fyear_number,
  2989. utils_str_atoi (attribute_values[i]));
  2990. i++;
  2991. continue;
  2992. }
  2993. /* normally, shouldn't come here */
  2994. i++;
  2995. }
  2996. while ( attribute_names[i] );
  2997. gsb_data_fyear_check_for_invalid (fyear_number);
  2998. }
  2999. /**
  3000. * load the archives in the grisbi file
  3001. *
  3002. * \param attribute_names
  3003. * \param attribute_values
  3004. *
  3005. * */
  3006. void gsb_file_load_archive ( const gchar **attribute_names,
  3007. const gchar **attribute_values )
  3008. {
  3009. gint i=0;
  3010. gint archive_number;
  3011. GDate *date;
  3012. if ( !attribute_names[i] )
  3013. return;
  3014. archive_number = gsb_data_archive_new (NULL);
  3015. do
  3016. {
  3017. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3018. /* go to the next */
  3019. if ( !strcmp (attribute_values[i],
  3020. "(null)"))
  3021. {
  3022. i++;
  3023. continue;
  3024. }
  3025. if ( !strcmp ( attribute_names[i],
  3026. "Nb" ))
  3027. {
  3028. archive_number = gsb_data_archive_set_new_number (archive_number,
  3029. utils_str_atoi (attribute_values[i]));
  3030. i++;
  3031. continue;
  3032. }
  3033. if ( !strcmp ( attribute_names[i],
  3034. "Na" ))
  3035. {
  3036. gsb_data_archive_set_name ( archive_number,
  3037. attribute_values[i]);
  3038. i++;
  3039. continue;
  3040. }
  3041. if ( !strcmp ( attribute_names[i],
  3042. "Bdte" ))
  3043. {
  3044. date = gsb_parse_date_string_safe (attribute_values[i]);
  3045. gsb_data_archive_set_beginning_date ( archive_number,
  3046. date );
  3047. if ( date )
  3048. g_date_free (date);
  3049. i++;
  3050. continue;
  3051. }
  3052. if ( !strcmp ( attribute_names[i],
  3053. "Edte" ))
  3054. {
  3055. date = gsb_parse_date_string_safe (attribute_values[i]);
  3056. gsb_data_archive_set_end_date ( archive_number,
  3057. date );
  3058. if ( date )
  3059. g_date_free (date);
  3060. i++;
  3061. continue;
  3062. }
  3063. if ( !strcmp ( attribute_names[i],
  3064. "Fye" ))
  3065. {
  3066. gsb_data_archive_set_fyear ( archive_number,
  3067. utils_str_atoi (attribute_values[i]));
  3068. i++;
  3069. continue;
  3070. }
  3071. if ( !strcmp ( attribute_names[i],
  3072. "Rep" ))
  3073. {
  3074. gsb_data_archive_set_report_title ( archive_number,
  3075. attribute_values[i]);
  3076. i++;
  3077. continue;
  3078. }
  3079. /* normally, shouldn't come here */
  3080. i++;
  3081. }
  3082. while ( attribute_names[i] );
  3083. }
  3084. /**
  3085. * load the reconcile structure in the grisbi file
  3086. *
  3087. * \param attribute_names
  3088. * \param attribute_values
  3089. *
  3090. * */
  3091. void gsb_file_load_reconcile ( const gchar **attribute_names,
  3092. const gchar **attribute_values )
  3093. {
  3094. gint i=0;
  3095. gint reconcile_number = 0;
  3096. if ( !attribute_names[i] )
  3097. return;
  3098. reconcile_number = gsb_data_reconcile_new (NULL);
  3099. do
  3100. {
  3101. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3102. /* go to the next */
  3103. if ( !strcmp (attribute_values[i],
  3104. "(null)"))
  3105. {
  3106. i++;
  3107. continue;
  3108. }
  3109. if ( !strcmp ( attribute_names[i],
  3110. "Nb" ))
  3111. {
  3112. reconcile_number = gsb_data_reconcile_set_new_number ( reconcile_number,
  3113. utils_str_atoi (attribute_values[i]));
  3114. i++;
  3115. continue;
  3116. }
  3117. if ( !strcmp ( attribute_names[i],
  3118. "Na" ))
  3119. {
  3120. gsb_data_reconcile_set_name ( reconcile_number,
  3121. attribute_values[i]);
  3122. i++;
  3123. continue;
  3124. }
  3125. if ( !strcmp ( attribute_names[i],
  3126. "Acc" ))
  3127. {
  3128. gsb_data_reconcile_set_account ( reconcile_number,
  3129. utils_str_atoi (attribute_values[i]));
  3130. i++;
  3131. continue;
  3132. }
  3133. if ( !strcmp ( attribute_names[i],
  3134. "Idate" ))
  3135. {
  3136. gsb_data_reconcile_set_init_date ( reconcile_number,
  3137. gsb_parse_date_string_safe (attribute_values[i]));
  3138. i++;
  3139. continue;
  3140. }
  3141. if ( !strcmp ( attribute_names[i],
  3142. "Fdate" ))
  3143. {
  3144. gsb_data_reconcile_set_final_date ( reconcile_number,
  3145. gsb_parse_date_string_safe (attribute_values[i]));
  3146. i++;
  3147. continue;
  3148. }
  3149. if ( !strcmp ( attribute_names[i],
  3150. "Ibal" ))
  3151. {
  3152. gsb_data_reconcile_set_init_balance ( reconcile_number,
  3153. gsb_real_safe_real_from_string (attribute_values[i]));
  3154. i++;
  3155. continue;
  3156. }
  3157. if ( !strcmp ( attribute_names[i],
  3158. "Fbal" ))
  3159. {
  3160. gsb_data_reconcile_set_final_balance ( reconcile_number,
  3161. gsb_real_safe_real_from_string (attribute_values[i]));
  3162. i++;
  3163. continue;
  3164. }
  3165. /* normally, shouldn't come here */
  3166. i++;
  3167. }
  3168. while ( attribute_names[i] );
  3169. }
  3170. /**
  3171. * load the import rules structure in the grisbi file
  3172. *
  3173. * \param attribute_names
  3174. * \param attribute_values
  3175. *
  3176. * */
  3177. void gsb_file_load_import_rule ( const gchar **attribute_names,
  3178. const gchar **attribute_values )
  3179. {
  3180. gint i=0;
  3181. gint import_rule_number = 0;
  3182. if ( !attribute_names[i] )
  3183. return;
  3184. import_rule_number = gsb_data_import_rule_new (NULL);
  3185. do
  3186. {
  3187. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3188. /* go to the next */
  3189. if ( !strcmp (attribute_values[i],
  3190. "(null)"))
  3191. {
  3192. i++;
  3193. continue;
  3194. }
  3195. if ( !strcmp ( attribute_names[i],
  3196. "Nb" ))
  3197. {
  3198. import_rule_number = gsb_data_import_rule_set_new_number ( import_rule_number,
  3199. utils_str_atoi (attribute_values[i]));
  3200. i++;
  3201. continue;
  3202. }
  3203. if ( !strcmp ( attribute_names[i],
  3204. "Na" ))
  3205. {
  3206. gsb_data_import_rule_set_name ( import_rule_number,
  3207. attribute_values[i]);
  3208. i++;
  3209. continue;
  3210. }
  3211. if ( !strcmp ( attribute_names[i],
  3212. "Acc" ))
  3213. {
  3214. gsb_data_import_rule_set_account ( import_rule_number,
  3215. utils_str_atoi (attribute_values[i]));
  3216. i++;
  3217. continue;
  3218. }
  3219. if ( !strcmp ( attribute_names[i],
  3220. "Cur" ))
  3221. {
  3222. gsb_data_import_rule_set_currency ( import_rule_number,
  3223. utils_str_atoi (attribute_values[i]));
  3224. i++;
  3225. continue;
  3226. }
  3227. if ( !strcmp ( attribute_names[i],
  3228. "Inv" ))
  3229. {
  3230. gsb_data_import_rule_set_invert ( import_rule_number,
  3231. utils_str_atoi (attribute_values[i]));
  3232. i++;
  3233. continue;
  3234. }
  3235. if ( !strcmp ( attribute_names[i],
  3236. "Enc" ))
  3237. {
  3238. gsb_data_import_rule_set_charmap ( import_rule_number,
  3239. attribute_values[i]);
  3240. i++;
  3241. continue;
  3242. }
  3243. if ( !strcmp ( attribute_names[i],
  3244. "Fil" ))
  3245. {
  3246. gsb_data_import_rule_set_last_file_name ( import_rule_number,
  3247. attribute_values[i]);
  3248. i++;
  3249. continue;
  3250. }
  3251. if ( !strcmp ( attribute_names[i],
  3252. "Act" ))
  3253. {
  3254. gsb_data_import_rule_set_action ( import_rule_number,
  3255. utils_str_atoi (attribute_values[i]));
  3256. i++;
  3257. continue;
  3258. }
  3259. /* normally, shouldn't come here */
  3260. i++;
  3261. }
  3262. while ( attribute_names[i] );
  3263. }
  3264. /**
  3265. * load the partial balance structure in the grisbi file
  3266. *
  3267. * \param attribute_names
  3268. * \param attribute_values
  3269. *
  3270. * */
  3271. void gsb_file_load_partial_balance ( const gchar **attribute_names,
  3272. const gchar **attribute_values )
  3273. {
  3274. gint i=0;
  3275. gint partial_balance_number = 0;
  3276. if ( !attribute_names[i] )
  3277. return;
  3278. do
  3279. {
  3280. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3281. /* go to the next */
  3282. if ( !strcmp ( attribute_values[i],
  3283. "(null)") )
  3284. {
  3285. i++;
  3286. continue;
  3287. }
  3288. if ( !strcmp ( attribute_names[i],
  3289. "Nb" ) )
  3290. {
  3291. partial_balance_number = gsb_partial_balance_new_at_position (
  3292. NULL,
  3293. utils_str_atoi ( attribute_values[i] ) );
  3294. i++;
  3295. continue;
  3296. }
  3297. if ( !strcmp ( attribute_names[i],
  3298. "Na" ) )
  3299. {
  3300. gsb_data_partial_balance_set_name ( partial_balance_number,
  3301. attribute_values[i] );
  3302. i++;
  3303. continue;
  3304. }
  3305. if ( !strcmp ( attribute_names[i],
  3306. "Acc" ) )
  3307. {
  3308. gsb_data_partial_balance_set_liste_cptes ( partial_balance_number,
  3309. attribute_values[i] );
  3310. i++;
  3311. continue;
  3312. }
  3313. if ( !strcmp ( attribute_names[i],
  3314. "Kind" ) )
  3315. {
  3316. gsb_data_partial_balance_set_kind ( partial_balance_number,
  3317. utils_str_atoi ( attribute_values[i] ) );
  3318. i++;
  3319. continue;
  3320. }
  3321. if ( !strcmp ( attribute_names[i],
  3322. "Currency" ) )
  3323. {
  3324. gsb_data_partial_balance_set_currency ( partial_balance_number,
  3325. utils_str_atoi ( attribute_values[i] ) );
  3326. i++;
  3327. continue;
  3328. }
  3329. if ( !strcmp ( attribute_names[i],
  3330. "Colorise" ) )
  3331. {
  3332. gsb_data_partial_balance_set_colorise ( partial_balance_number,
  3333. utils_str_atoi ( attribute_values[i] ) );
  3334. i++;
  3335. continue;
  3336. }
  3337. /* normally, shouldn't come here */
  3338. i++;
  3339. }
  3340. while ( attribute_names[i] );
  3341. }
  3342. /**
  3343. * load the balance estimate part in the grisbi file
  3344. *
  3345. * \param attribute_names
  3346. * \param attribute_values
  3347. *
  3348. * */
  3349. void gsb_file_load_bet_part ( const gchar **attribute_names,
  3350. const gchar **attribute_values )
  3351. {
  3352. gint i=0;
  3353. if ( !attribute_names[i] )
  3354. return;
  3355. do
  3356. {
  3357. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3358. /* go to the next */
  3359. if ( !strcmp ( attribute_values[i], "(null)") )
  3360. {
  3361. i++;
  3362. continue;
  3363. }
  3364. if ( !strcmp ( attribute_names[i], "Ddte" ) )
  3365. {
  3366. etat.bet_deb_period = utils_str_atoi ( attribute_values[i] );
  3367. i++;
  3368. continue;
  3369. }
  3370. if ( !strcmp ( attribute_names[i], "Bet_deb_cash_account_option" ) )
  3371. {
  3372. etat.bet_deb_cash_account_option = utils_str_atoi ( attribute_values[i] );
  3373. i++;
  3374. continue;
  3375. }
  3376. /* normally, shouldn't come here */
  3377. i++;
  3378. }
  3379. while ( attribute_names[i] );
  3380. }
  3381. /**
  3382. * load the historical balance part in the grisbi file
  3383. *
  3384. * \param attribute_names
  3385. * \param attribute_values
  3386. *
  3387. * */
  3388. void gsb_file_load_bet_historical ( const gchar **attribute_names,
  3389. const gchar **attribute_values )
  3390. {
  3391. struct_hist_div *shd;
  3392. struct_hist_div *sub_shd = NULL;
  3393. gint i=0;
  3394. gint sub_div_nb;
  3395. if ( !attribute_names[i] )
  3396. return;
  3397. /* create the structure */
  3398. shd = struct_initialise_hist_div ( );
  3399. do
  3400. {
  3401. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3402. /* go to the next */
  3403. if ( !strcmp ( attribute_values[i], "(null)") )
  3404. {
  3405. i++;
  3406. continue;
  3407. }
  3408. if ( !strcmp ( attribute_names[i], "Ac" ) )
  3409. {
  3410. shd -> account_nb = utils_str_atoi ( attribute_values[i] );
  3411. i++;
  3412. continue;
  3413. }
  3414. if ( !strcmp ( attribute_names[i], "Ori" ) )
  3415. {
  3416. shd -> origin = utils_str_atoi ( attribute_values[i] );
  3417. i++;
  3418. continue;
  3419. }
  3420. if ( !strcmp ( attribute_names[i], "Div" ) )
  3421. {
  3422. shd -> div_number = utils_str_atoi ( attribute_values[i] );
  3423. i++;
  3424. continue;
  3425. }
  3426. if ( !strcmp ( attribute_names[i], "Edit" ) )
  3427. {
  3428. shd -> div_edited = utils_str_atoi ( attribute_values[i] );
  3429. i++;
  3430. continue;
  3431. }
  3432. if ( !strcmp ( attribute_names[i], "Damount" ) )
  3433. {
  3434. shd -> amount = gsb_real_safe_real_from_string ( attribute_values[i] );
  3435. i++;
  3436. continue;
  3437. }
  3438. if ( !strcmp ( attribute_names[i], "SDiv" ) )
  3439. {
  3440. sub_div_nb = utils_str_atoi ( attribute_values[i] );
  3441. if ( sub_div_nb > 0 )
  3442. {
  3443. sub_shd = struct_initialise_hist_div ( );
  3444. sub_shd -> div_number = sub_div_nb;
  3445. i++;
  3446. continue;
  3447. }
  3448. else
  3449. break;
  3450. }
  3451. if ( !strcmp ( attribute_names[i], "SEdit" ) )
  3452. {
  3453. sub_shd -> div_edited = utils_str_atoi ( attribute_values[i] );
  3454. i++;
  3455. continue;
  3456. }
  3457. if ( !strcmp ( attribute_names[i], "SDamount" ) )
  3458. {
  3459. sub_shd -> amount = gsb_real_safe_real_from_string ( attribute_values[i] );
  3460. i++;
  3461. continue;
  3462. }
  3463. /* normally, shouldn't come here */
  3464. i++;
  3465. }
  3466. while ( attribute_names[i] );
  3467. bet_data_insert_div_hist ( shd, sub_shd );
  3468. }
  3469. /**
  3470. * load the bet future data
  3471. *
  3472. * \param attribute_names
  3473. * \param attribute_values
  3474. *
  3475. * */
  3476. void gsb_file_load_bet_future_data ( const gchar **attribute_names,
  3477. const gchar **attribute_values )
  3478. {
  3479. gint i=0;
  3480. struct_futur_data *scheduled;
  3481. if ( !attribute_names[i] )
  3482. return;
  3483. scheduled = struct_initialise_bet_future ( );
  3484. if ( !scheduled )
  3485. {
  3486. dialogue_error_memory ();
  3487. return;
  3488. }
  3489. do
  3490. {
  3491. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3492. /* go to the next */
  3493. if ( !strcmp (attribute_values[i], "(null)") )
  3494. {
  3495. i++;
  3496. continue;
  3497. }
  3498. if ( !strcmp ( attribute_names[i], "Nb" ) )
  3499. {
  3500. scheduled -> number = utils_str_atoi ( attribute_values[i] );
  3501. i++;
  3502. continue;
  3503. }
  3504. if ( !strcmp ( attribute_names[i], "Dt" ) )
  3505. {
  3506. scheduled -> date = gsb_parse_date_string_safe ( attribute_values[i] );
  3507. i++;
  3508. continue;
  3509. }
  3510. if ( !strcmp ( attribute_names[i], "Ac" ) )
  3511. {
  3512. scheduled -> account_number = utils_str_atoi ( attribute_values[i] );
  3513. i++;
  3514. continue;
  3515. }
  3516. if ( !strcmp ( attribute_names[i], "Am" ) )
  3517. {
  3518. scheduled -> amount = gsb_real_safe_real_from_string ( attribute_values[i] );
  3519. i++;
  3520. continue;
  3521. }
  3522. if ( !strcmp ( attribute_names[i], "Pa" ) )
  3523. {
  3524. scheduled -> party_number = utils_str_atoi ( attribute_values[i] );
  3525. i++;
  3526. continue;
  3527. }
  3528. if ( !strcmp ( attribute_names[i], "IsT" ) )
  3529. {
  3530. scheduled -> is_transfert = utils_str_atoi ( attribute_values[i] );
  3531. i++;
  3532. continue;
  3533. }
  3534. if ( !strcmp ( attribute_names[i], "Tra" ) )
  3535. {
  3536. scheduled -> account_transfert = utils_str_atoi ( attribute_values[i] );
  3537. i++;
  3538. continue;
  3539. }
  3540. if ( !strcmp ( attribute_names[i], "Ca" ) )
  3541. {
  3542. scheduled -> category_number = utils_str_atoi ( attribute_values[i] );
  3543. i++;
  3544. continue;
  3545. }
  3546. if ( !strcmp ( attribute_names[i], "Sca" ) )
  3547. {
  3548. scheduled -> sub_category_number = utils_str_atoi ( attribute_values[i] );
  3549. i++;
  3550. continue;
  3551. }
  3552. if ( !strcmp ( attribute_names[i], "Pn" ) )
  3553. {
  3554. scheduled -> payment_number = utils_str_atoi ( attribute_values[i] );
  3555. i++;
  3556. continue;
  3557. }
  3558. if ( !strcmp ( attribute_names[i], "Fi" ) )
  3559. {
  3560. scheduled -> fyear_number = utils_str_atoi ( attribute_values[i] );
  3561. i++;
  3562. continue;
  3563. }
  3564. if ( !strcmp ( attribute_names[i], "Bu" ) )
  3565. {
  3566. scheduled -> budgetary_number = utils_str_atoi ( attribute_values[i] );
  3567. i++;
  3568. continue;
  3569. }
  3570. if ( !strcmp ( attribute_names[i], "Sbu" ) )
  3571. {
  3572. scheduled -> sub_budgetary_number = utils_str_atoi ( attribute_values[i] );
  3573. i++;
  3574. continue;
  3575. }
  3576. if ( !strcmp ( attribute_names[i], "No" ) )
  3577. {
  3578. scheduled -> notes = g_strdup ( attribute_values[i] );
  3579. i++;
  3580. continue;
  3581. }
  3582. if ( !strcmp ( attribute_names[i], "Pe" ) )
  3583. {
  3584. scheduled -> frequency = utils_str_atoi ( attribute_values[i] );
  3585. i++;
  3586. continue;
  3587. }
  3588. if ( !strcmp ( attribute_names[i], "Pei" ) )
  3589. {
  3590. scheduled -> user_interval = utils_str_atoi ( attribute_values[i] );
  3591. i++;
  3592. continue;
  3593. }
  3594. if ( !strcmp ( attribute_names[i], "Pep" ) )
  3595. {
  3596. scheduled -> user_entry = utils_str_atoi ( attribute_values[i] );
  3597. i++;
  3598. continue;
  3599. }
  3600. if ( !strcmp ( attribute_names[i], "Dtl" ) )
  3601. {
  3602. GDate *date;
  3603. date = gsb_parse_date_string_safe ( attribute_values[i] );
  3604. if ( g_date_valid ( date ) )
  3605. scheduled -> limit_date = date;
  3606. else
  3607. scheduled -> limit_date = NULL;
  3608. i++;
  3609. continue;
  3610. }
  3611. if ( !strcmp ( attribute_names[i], "Mo" ) )
  3612. {
  3613. scheduled -> mother_row = utils_str_atoi ( attribute_values[i] );
  3614. i++;
  3615. continue;
  3616. }
  3617. /* normally, shouldn't come here */
  3618. i++;
  3619. }
  3620. while ( attribute_names[i] );
  3621. bet_data_future_set_lines_from_file ( scheduled );
  3622. }
  3623. /**
  3624. * load the bet transfert line
  3625. *
  3626. * \param attribute_names
  3627. * \param attribute_values
  3628. *
  3629. * */
  3630. void gsb_file_load_bet_transfert_part ( const gchar **attribute_names,
  3631. const gchar **attribute_values )
  3632. {
  3633. gint i=0;
  3634. struct_transfert_data *transfert;
  3635. if ( !attribute_names[i] )
  3636. return;
  3637. transfert = struct_initialise_bet_transfert ( );
  3638. if ( !transfert )
  3639. {
  3640. dialogue_error_memory ();
  3641. return;
  3642. }
  3643. do
  3644. {
  3645. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3646. /* go to the next */
  3647. if ( !strcmp (attribute_values[i], "(null)") )
  3648. {
  3649. i++;
  3650. continue;
  3651. }
  3652. if ( !strcmp ( attribute_names[i], "Nb" ) )
  3653. {
  3654. transfert -> number = utils_str_atoi ( attribute_values[i] );
  3655. i++;
  3656. continue;
  3657. }
  3658. if ( !strcmp ( attribute_names[i], "Dt" ) )
  3659. {
  3660. transfert -> date = gsb_parse_date_string_safe ( attribute_values[i] );
  3661. i++;
  3662. continue;
  3663. }
  3664. if ( !strcmp ( attribute_names[i], "Ac" ) )
  3665. {
  3666. transfert -> account_number = utils_str_atoi ( attribute_values[i] );
  3667. i++;
  3668. continue;
  3669. }
  3670. if ( !strcmp ( attribute_names[i], "Ty" ) )
  3671. {
  3672. transfert -> type = utils_str_atoi ( attribute_values[i] );
  3673. i++;
  3674. continue;
  3675. }
  3676. if ( !strcmp ( attribute_names[i], "Ra" ) )
  3677. {
  3678. transfert -> replace_account = utils_str_atoi ( attribute_values[i] );
  3679. i++;
  3680. continue;
  3681. }
  3682. if ( !strcmp ( attribute_names[i], "Rt" ) )
  3683. {
  3684. transfert -> replace_transaction = utils_str_atoi ( attribute_values[i] );
  3685. i++;
  3686. continue;
  3687. }
  3688. if ( !strcmp ( attribute_names[i], "Aim" ) )
  3689. {
  3690. transfert -> auto_inc_month = utils_str_atoi ( attribute_values[i] );
  3691. i++;
  3692. continue;
  3693. }
  3694. if ( !strcmp ( attribute_names[i], "Ca" ) )
  3695. {
  3696. transfert -> category_number = utils_str_atoi ( attribute_values[i] );
  3697. i++;
  3698. continue;
  3699. }
  3700. if ( !strcmp ( attribute_names[i], "Sca" ) )
  3701. {
  3702. transfert -> sub_category_number = utils_str_atoi ( attribute_values[i] );
  3703. i++;
  3704. continue;
  3705. }
  3706. if ( !strcmp ( attribute_names[i], "Bu" ) )
  3707. {
  3708. transfert -> budgetary_number = utils_str_atoi ( attribute_values[i] );
  3709. i++;
  3710. continue;
  3711. }
  3712. if ( !strcmp ( attribute_names[i], "Sbu" ) )
  3713. {
  3714. transfert -> sub_budgetary_number = utils_str_atoi ( attribute_values[i] );
  3715. i++;
  3716. continue;
  3717. }
  3718. /* normally, shouldn't come here */
  3719. i++;
  3720. }
  3721. while ( attribute_names[i] );
  3722. bet_data_transfert_set_line_from_file ( transfert );
  3723. }
  3724. /**
  3725. * load the report structure in the grisbi file
  3726. *
  3727. * \param attribute_names
  3728. * \param attribute_values
  3729. *
  3730. * */
  3731. void gsb_file_load_report ( const gchar **attribute_names,
  3732. const gchar **attribute_values )
  3733. {
  3734. gint i=0;
  3735. gint report_number = 0;
  3736. if ( !attribute_names[i] )
  3737. return;
  3738. do
  3739. {
  3740. /* we test at the beginning if the attribute_value is NULL, if yes, */
  3741. /* go to the next */
  3742. if ( !strcmp (attribute_values[i],
  3743. "(null)"))
  3744. {
  3745. i++;
  3746. continue;
  3747. }
  3748. if ( !strcmp ( attribute_names[i],
  3749. "Nb" ))
  3750. {
  3751. /* if the number is -1, it means we are importing a report, so let grisbi choose the
  3752. * report number */
  3753. if (utils_str_atoi (attribute_values[i]) == -1)
  3754. report_number = gsb_data_report_new (NULL);
  3755. else
  3756. report_number = gsb_data_report_new_with_number (utils_str_atoi (attribute_values[i]));
  3757. i++;
  3758. continue;
  3759. }
  3760. if ( !strcmp ( attribute_names[i],
  3761. "Name" ))
  3762. {
  3763. gsb_data_report_set_report_name ( report_number,
  3764. attribute_values[i]);
  3765. i++;
  3766. continue;
  3767. }
  3768. if ( !strcmp ( attribute_names[i],
  3769. "General_sort_type" ))
  3770. {
  3771. gsb_data_report_set_sorting_type ( report_number,
  3772. gsb_string_get_int_list_from_string (attribute_values[i],
  3773. "/-/" ));
  3774. i++;
  3775. continue;
  3776. }
  3777. if ( !strcmp ( attribute_names[i],
  3778. "Show_r" ))
  3779. {
  3780. gsb_data_report_set_show_r ( report_number,
  3781. utils_str_atoi (attribute_values[i]));
  3782. i++;
  3783. continue;
  3784. }
  3785. if ( !strcmp ( attribute_names[i],
  3786. "Show_transaction" ))
  3787. {
  3788. gsb_data_report_set_show_report_transactions ( report_number,
  3789. utils_str_atoi (attribute_values[i]));
  3790. i++;
  3791. continue;
  3792. }
  3793. if ( !strcmp ( attribute_names[i],
  3794. "Show_transaction_amount" ))
  3795. {
  3796. gsb_data_report_set_show_report_transaction_amount ( report_number,
  3797. utils_str_atoi (attribute_values[i] ));
  3798. i++;
  3799. continue;
  3800. }
  3801. if ( !strcmp ( attribute_names[i],
  3802. "Show_transaction_nb" ))
  3803. {
  3804. gsb_data_report_set_show_report_transaction_number ( report_number,
  3805. utils_str_atoi (attribute_values[i]));
  3806. i++;
  3807. continue;
  3808. }
  3809. if ( !strcmp ( attribute_names[i],
  3810. "Show_transaction_date" ))
  3811. {
  3812. gsb_data_report_set_show_report_date ( report_number,
  3813. utils_str_atoi (attribute_values[i]));
  3814. i++;
  3815. continue;
  3816. }
  3817. if ( !strcmp ( attribute_names[i],
  3818. "Show_transaction_value_date" ))
  3819. {
  3820. gsb_data_report_set_show_report_value_date ( report_number,
  3821. utils_str_atoi (attribute_values[i]));
  3822. i++;
  3823. continue;
  3824. }
  3825. if ( !strcmp ( attribute_names[i],
  3826. "Show_transaction_payee" ))
  3827. {
  3828. gsb_data_report_set_show_report_payee ( report_number,
  3829. utils_str_atoi (attribute_values[i]));
  3830. i++;
  3831. continue;
  3832. }
  3833. if ( !strcmp ( attribute_names[i],
  3834. "Show_transaction_categ" ))
  3835. {
  3836. gsb_data_report_set_show_report_category ( report_number,
  3837. utils_str_atoi (attribute_values[i]));
  3838. i++;
  3839. continue;
  3840. }
  3841. if ( !strcmp ( attribute_names[i],
  3842. "Show_transaction_sub_categ" ))
  3843. {
  3844. gsb_data_report_set_show_report_sub_category ( report_number,
  3845. utils_str_atoi (attribute_values[i]));
  3846. i++;
  3847. continue;
  3848. }
  3849. if ( !strcmp ( attribute_names[i],
  3850. "Show_transaction_payment" ))
  3851. {
  3852. gsb_data_report_set_show_report_method_of_payment ( report_number,
  3853. utils_str_atoi (attribute_values[i]));
  3854. i++;
  3855. continue;
  3856. }
  3857. if ( !strcmp ( attribute_names[i],
  3858. "Show_transaction_budget" ))
  3859. {
  3860. gsb_data_report_set_show_report_budget ( report_number,
  3861. utils_str_atoi (attribute_values[i]));
  3862. i++;
  3863. continue;
  3864. }
  3865. if ( !strcmp ( attribute_names[i],
  3866. "Show_transaction_sub_budget" ))
  3867. {
  3868. gsb_data_report_set_show_report_sub_budget ( report_number,
  3869. utils_str_atoi (attribute_values[i]));
  3870. i++;
  3871. continue;
  3872. }
  3873. if ( !strcmp ( attribute_names[i],
  3874. "Show_transaction_chq" ))
  3875. {
  3876. gsb_data_report_set_show_report_method_of_payment_content ( report_number,
  3877. utils_str_atoi (attribute_values[i]));
  3878. i++;
  3879. continue;
  3880. }
  3881. if ( !strcmp ( attribute_names[i],
  3882. "Show_transaction_note" ))
  3883. {
  3884. gsb_data_report_set_show_report_note ( report_number,
  3885. utils_str_atoi (attribute_values[i]));
  3886. i++;
  3887. continue;
  3888. }
  3889. if ( !strcmp ( attribute_names[i],
  3890. "Show_transaction_voucher" ))
  3891. {
  3892. gsb_data_report_set_show_report_voucher ( report_number,
  3893. utils_str_atoi (attribute_values[i]));
  3894. i++;
  3895. continue;
  3896. }
  3897. if ( !strcmp ( attribute_names[i],
  3898. "Show_transaction_reconcile" ))
  3899. {
  3900. gsb_data_report_set_show_report_marked ( report_number,
  3901. utils_str_atoi (attribute_values[i]));
  3902. i++;
  3903. continue;
  3904. }
  3905. if ( !strcmp ( attribute_names[i],
  3906. "Show_transaction_bank" ))
  3907. {
  3908. gsb_data_report_set_show_report_bank_references ( report_number,
  3909. utils_str_atoi (attribute_values[i]));
  3910. i++;
  3911. continue;
  3912. }
  3913. if ( !strcmp ( attribute_names[i],
  3914. "Show_transaction_fin_year" ))
  3915. {
  3916. gsb_data_report_set_show_report_financial_year ( report_number,
  3917. utils_str_atoi (attribute_values[i]));
  3918. i++;
  3919. continue;
  3920. }
  3921. if ( !strcmp ( attribute_names[i],
  3922. "Show_transaction_sort_type" ))
  3923. {
  3924. gsb_data_report_set_sorting_report ( report_number,
  3925. utils_str_atoi (attribute_values[i]));
  3926. i++;
  3927. continue;
  3928. }
  3929. if ( !strcmp ( attribute_names[i],
  3930. "Show_columns_titles" ))
  3931. {
  3932. gsb_data_report_set_column_title_show ( report_number,
  3933. utils_str_atoi (attribute_values[i]));
  3934. i++;
  3935. continue;
  3936. }
  3937. if ( !strcmp ( attribute_names[i],
  3938. "Show_title_column_kind" ))
  3939. {
  3940. gsb_data_report_set_column_title_type ( report_number,
  3941. utils_str_atoi (attribute_values[i]));
  3942. i++;
  3943. continue;
  3944. }
  3945. if ( !strcmp ( attribute_names[i],
  3946. "Show_exclude_split_child" ))
  3947. {
  3948. gsb_data_report_set_not_detail_split ( report_number,
  3949. utils_str_atoi (attribute_values[i]));
  3950. i++;
  3951. continue;
  3952. }
  3953. if ( !strcmp ( attribute_names[i],
  3954. "Show_split_amounts" ))
  3955. {
  3956. gsb_data_report_set_split_credit_debit ( report_number,
  3957. utils_str_atoi (attribute_values[i]));
  3958. i++;
  3959. continue;
  3960. }
  3961. if ( !strcmp ( attribute_names[i],
  3962. "Currency_general" ))
  3963. {
  3964. gsb_data_report_set_currency_general ( report_number,
  3965. utils_str_atoi (attribute_values[i]));
  3966. i++;
  3967. continue;
  3968. }
  3969. if ( !strcmp ( attribute_names[i],
  3970. "Report_in_payees" ))
  3971. {
  3972. gsb_data_report_set_append_in_payee ( report_number,
  3973. utils_str_atoi (attribute_values[i]));
  3974. i++;
  3975. continue;
  3976. }
  3977. if ( !strcmp ( attribute_names[i],
  3978. "Report_can_click" ))
  3979. {
  3980. gsb_data_report_set_report_can_click ( report_number,
  3981. utils_str_atoi (attribute_values[i]));
  3982. i++;
  3983. continue;
  3984. }
  3985. if ( !strcmp ( attribute_names[i],
  3986. "Financial_year_used" ))
  3987. {
  3988. gsb_data_report_set_use_financial_year ( report_number,
  3989. utils_str_atoi (attribute_values[i]));
  3990. i++;
  3991. continue;
  3992. }
  3993. if ( !strcmp ( attribute_names[i],
  3994. "Financial_year_kind" ))
  3995. {
  3996. gsb_data_report_set_financial_year_type ( report_number,
  3997. utils_str_atoi (attribute_values[i]));
  3998. i++;
  3999. continue;
  4000. }
  4001. if ( !strcmp ( attribute_names[i],
  4002. "Financial_year_select" ))
  4003. {
  4004. gsb_data_report_set_financial_year_list ( report_number,
  4005. gsb_string_get_int_list_from_string (attribute_values[i],
  4006. "/-/" ));
  4007. i++;
  4008. continue;
  4009. }
  4010. if ( !strcmp ( attribute_names[i],
  4011. "Date_kind" ))
  4012. {
  4013. gsb_data_report_set_date_type ( report_number,
  4014. utils_str_atoi (attribute_values[i]));
  4015. i++;
  4016. continue;
  4017. }
  4018. if ( !strcmp ( attribute_names[i],
  4019. "Date_beginning" ))
  4020. {
  4021. gsb_data_report_set_personal_date_start ( report_number,
  4022. gsb_parse_date_string_safe (attribute_values[i]));
  4023. i++;
  4024. continue;
  4025. }
  4026. if ( !strcmp ( attribute_names[i],
  4027. "Date_end" ))
  4028. {
  4029. gsb_data_report_set_personal_date_end ( report_number,
  4030. gsb_parse_date_string_safe (attribute_values[i]));
  4031. i++;
  4032. continue;
  4033. }
  4034. if ( !strcmp ( attribute_names[i],
  4035. "Split_by_date" ))
  4036. {
  4037. gsb_data_report_set_period_split ( report_number,
  4038. utils_str_atoi (attribute_values[i]));
  4039. i++;
  4040. continue;
  4041. }
  4042. if ( !strcmp ( attribute_names[i],
  4043. "Split_date_period" ))
  4044. {
  4045. gsb_data_report_set_period_split_type ( report_number,
  4046. utils_str_atoi (attribute_values[i]));
  4047. i++;
  4048. continue;
  4049. }
  4050. if ( !strcmp ( attribute_names[i],
  4051. "Split_by_fin_year" ))
  4052. {
  4053. gsb_data_report_set_financial_year_split ( report_number,
  4054. utils_str_atoi (attribute_values[i]));
  4055. i++;
  4056. continue;
  4057. }
  4058. if ( !strcmp ( attribute_names[i],
  4059. "Split_day_beginning" ))
  4060. {
  4061. gsb_data_report_set_period_split_day ( report_number,
  4062. utils_str_atoi (attribute_values[i]));
  4063. i++;
  4064. continue;
  4065. }
  4066. if ( !strcmp ( attribute_names[i],
  4067. "Account_use_selection" ))
  4068. {
  4069. gsb_data_report_set_account_use_chosen ( report_number,
  4070. utils_str_atoi (attribute_values[i]));
  4071. i++;
  4072. continue;
  4073. }
  4074. if ( !strcmp ( attribute_names[i],
  4075. "Account_selected" ))
  4076. {
  4077. gsb_data_report_set_account_numbers ( report_number,
  4078. gsb_string_get_int_list_from_string (attribute_values[i],
  4079. "/-/" ));
  4080. i++;
  4081. continue;
  4082. }
  4083. if ( !strcmp ( attribute_names[i],
  4084. "Account_group_transactions" ))
  4085. {
  4086. gsb_data_report_set_account_group_reports ( report_number,
  4087. utils_str_atoi (attribute_values[i]));
  4088. i++;
  4089. continue;
  4090. }
  4091. if ( !strcmp ( attribute_names[i],
  4092. "Account_show_amount" ))
  4093. {
  4094. gsb_data_report_set_account_show_amount ( report_number,
  4095. utils_str_atoi (attribute_values[i]));
  4096. i++;
  4097. continue;
  4098. }
  4099. if ( !strcmp ( attribute_names[i],
  4100. "Account_show_name" ))
  4101. {
  4102. gsb_data_report_set_account_show_name ( report_number,
  4103. utils_str_atoi (attribute_values[i]));
  4104. i++;
  4105. continue;
  4106. }
  4107. if ( !strcmp ( attribute_names[i],
  4108. "Transfer_kind" ))
  4109. {
  4110. gsb_data_report_set_transfer_choice ( report_number,
  4111. utils_str_atoi (attribute_values[i]));
  4112. i++;
  4113. continue;
  4114. }
  4115. if ( !strcmp ( attribute_names[i],
  4116. "Transfer_selected_accounts" ))
  4117. {
  4118. gsb_data_report_set_transfer_account_numbers ( report_number,
  4119. gsb_string_get_int_list_from_string (attribute_values[i],
  4120. "/-/" ));
  4121. i++;
  4122. continue;
  4123. }
  4124. if ( !strcmp ( attribute_names[i],
  4125. "Transfer_exclude_transactions" ))
  4126. {
  4127. gsb_data_report_set_transfer_reports_only ( report_number,
  4128. utils_str_atoi (attribute_values[i]));
  4129. i++;
  4130. continue;
  4131. }
  4132. if ( !strcmp ( attribute_names[i],
  4133. "Categ_use" ))
  4134. {
  4135. gsb_data_report_set_category_used ( report_number,
  4136. utils_str_atoi (attribute_values[i]));
  4137. i++;
  4138. continue;
  4139. }
  4140. if ( !strcmp ( attribute_names[i],
  4141. "Categ_use_selection" ))
  4142. {
  4143. gsb_data_report_set_category_detail_used ( report_number,
  4144. utils_str_atoi (attribute_values[i]));
  4145. i++;
  4146. continue;
  4147. }
  4148. if ( !strcmp ( attribute_names[i],
  4149. "Categ_selected" ))
  4150. {
  4151. gsb_data_report_set_category_struct ( report_number,
  4152. gsb_string_get_categ_budget_struct_list_from_string ((attribute_values[i])));
  4153. i++;
  4154. continue;
  4155. }
  4156. if ( !strcmp ( attribute_names[i],
  4157. "Categ_show_amount" ))
  4158. {
  4159. gsb_data_report_set_category_show_category_amount ( report_number,
  4160. utils_str_atoi (attribute_values[i]));
  4161. i++;
  4162. continue;
  4163. }
  4164. if ( !strcmp ( attribute_names[i],
  4165. "Categ_show_sub_categ" ))
  4166. {
  4167. gsb_data_report_set_category_show_sub_category ( report_number,
  4168. utils_str_atoi (attribute_values[i]));
  4169. i++;
  4170. continue;
  4171. }
  4172. if ( !strcmp ( attribute_names[i],
  4173. "Categ_show_without_sub_categ" ))
  4174. {
  4175. gsb_data_report_set_category_show_without_category ( report_number,
  4176. utils_str_atoi (attribute_values[i]));
  4177. i++;
  4178. continue;
  4179. }
  4180. if ( !strcmp ( attribute_names[i],
  4181. "Categ_show_sub_categ_amount" ))
  4182. {
  4183. gsb_data_report_set_category_show_sub_category_amount ( report_number,
  4184. utils_str_atoi (attribute_values[i]));
  4185. i++;
  4186. continue;
  4187. }
  4188. if ( !strcmp ( attribute_names[i],
  4189. "Categ_currency" ))
  4190. {
  4191. gsb_data_report_set_category_currency ( report_number,
  4192. utils_str_atoi (attribute_values[i]));
  4193. i++;
  4194. continue;
  4195. }
  4196. if ( !strcmp ( attribute_names[i],
  4197. "Categ_show_name" ))
  4198. {
  4199. gsb_data_report_set_category_show_name ( report_number,
  4200. utils_str_atoi (attribute_values[i]));
  4201. i++;
  4202. continue;
  4203. }
  4204. if ( !strcmp ( attribute_names[i],
  4205. "Budget_use" ))
  4206. {
  4207. gsb_data_report_set_budget_used ( report_number,
  4208. utils_str_atoi (attribute_values[i]));
  4209. i++;
  4210. continue;
  4211. }
  4212. if ( !strcmp ( attribute_names[i],
  4213. "Budget_use_selection" ))
  4214. {
  4215. gsb_data_report_set_budget_detail_used ( report_number,
  4216. utils_str_atoi (attribute_values[i]));
  4217. i++;
  4218. continue;
  4219. }
  4220. if ( !strcmp ( attribute_names[i],
  4221. "Budget_selected" ))
  4222. {
  4223. gsb_data_report_set_budget_struct ( report_number,
  4224. gsb_string_get_categ_budget_struct_list_from_string ((attribute_values[i])));
  4225. i++;
  4226. continue;
  4227. }
  4228. if ( !strcmp ( attribute_names[i],
  4229. "Budget_show_amount" ))
  4230. {
  4231. gsb_data_report_set_budget_show_budget_amount ( report_number,
  4232. utils_str_atoi (attribute_values[i]));
  4233. i++;
  4234. continue;
  4235. }
  4236. if ( !strcmp ( attribute_names[i],
  4237. "Budget_show_sub_budget" ))
  4238. {
  4239. gsb_data_report_set_budget_show_sub_budget ( report_number,
  4240. utils_str_atoi (attribute_values[i]));
  4241. i++;
  4242. continue;
  4243. }
  4244. if ( !strcmp ( attribute_names[i],
  4245. "Budget_show_without_sub_budget" ))
  4246. {
  4247. gsb_data_report_set_budget_show_without_budget ( report_number,
  4248. utils_str_atoi (attribute_values[i]));
  4249. i++;
  4250. continue;
  4251. }
  4252. if ( !strcmp ( attribute_names[i],
  4253. "Budget_show_sub_budget_amount" ))
  4254. {
  4255. gsb_data_report_set_budget_show_sub_budget_amount ( report_number,
  4256. utils_str_atoi (attribute_values[i]));
  4257. i++;
  4258. continue;
  4259. }
  4260. if ( !strcmp ( attribute_names[i],
  4261. "Budget_currency" ))
  4262. {
  4263. gsb_data_report_set_budget_currency ( report_number,
  4264. utils_str_atoi (attribute_values[i]));
  4265. i++;
  4266. continue;
  4267. }
  4268. if ( !strcmp ( attribute_names[i],
  4269. "Budget_show_name" ))
  4270. {
  4271. gsb_data_report_set_budget_show_name ( report_number,
  4272. utils_str_atoi (attribute_values[i]));
  4273. i++;
  4274. continue;
  4275. }
  4276. if ( !strcmp ( attribute_names[i],
  4277. "Payee_use" ))
  4278. {
  4279. gsb_data_report_set_payee_used ( report_number,
  4280. utils_str_atoi (attribute_values[i]));
  4281. i++;
  4282. continue;
  4283. }
  4284. if ( !strcmp ( attribute_names[i],
  4285. "Payee_use_selection" ))
  4286. {
  4287. gsb_data_report_set_payee_detail_used ( report_number,
  4288. utils_str_atoi (attribute_values[i]));
  4289. i++;
  4290. continue;
  4291. }
  4292. if ( !strcmp ( attribute_names[i],
  4293. "Payee_selected" ))
  4294. {
  4295. gsb_data_report_set_payee_numbers ( report_number,
  4296. gsb_string_get_int_list_from_string (attribute_values[i],
  4297. "/-/" ));
  4298. i++;
  4299. continue;
  4300. }
  4301. if ( !strcmp ( attribute_names[i],
  4302. "Payee_show_amount" ))
  4303. {
  4304. gsb_data_report_set_payee_show_payee_amount ( report_number,
  4305. utils_str_atoi (attribute_values[i]));
  4306. i++;
  4307. continue;
  4308. }
  4309. if ( !strcmp ( attribute_names[i],
  4310. "Payee_currency" ))
  4311. {
  4312. gsb_data_report_set_payee_currency ( report_number,
  4313. utils_str_atoi (attribute_values[i]));
  4314. i++;
  4315. continue;
  4316. }
  4317. if ( !strcmp ( attribute_names[i],
  4318. "Payee_show_name" ))
  4319. {
  4320. gsb_data_report_set_payee_show_name ( report_number,
  4321. utils_str_atoi (attribute_values[i]));
  4322. i++;
  4323. continue;
  4324. }
  4325. if ( !strcmp ( attribute_names[i],
  4326. "Amount_currency" ))
  4327. {
  4328. gsb_data_report_set_amount_comparison_currency ( report_number,
  4329. utils_str_atoi (attribute_values[i]));
  4330. i++;
  4331. continue;
  4332. }
  4333. if ( !strcmp ( attribute_names[i],
  4334. "Amount_exclude_null" ))
  4335. {
  4336. gsb_data_report_set_amount_comparison_only_report_non_null ( report_number,
  4337. utils_str_atoi (attribute_values[i]));
  4338. i++;
  4339. continue;
  4340. }
  4341. if ( !strcmp ( attribute_names[i],
  4342. "Payment_method_use" ))
  4343. {
  4344. gsb_data_report_set_method_of_payment_used ( report_number,
  4345. utils_str_atoi (attribute_values[i]));
  4346. i++;
  4347. continue;
  4348. }
  4349. if ( !strcmp ( attribute_names[i],
  4350. "Payment_method_list" ))
  4351. {
  4352. gsb_data_report_set_method_of_payment_list ( report_number,
  4353. gsb_string_get_string_list_from_string (attribute_values[i],
  4354. "/-/" ));
  4355. i++;
  4356. continue;
  4357. }
  4358. if ( !strcmp ( attribute_names[i],
  4359. "Use_text" ))
  4360. {
  4361. gsb_data_report_set_text_comparison_used ( report_number,
  4362. utils_str_atoi (attribute_values[i]));
  4363. i++;
  4364. continue;
  4365. }
  4366. if ( !strcmp ( attribute_names[i],
  4367. "Use_amount" ))
  4368. {
  4369. gsb_data_report_set_amount_comparison_used ( report_number,
  4370. utils_str_atoi (attribute_values[i]));
  4371. i++;
  4372. continue;
  4373. }
  4374. /* normally, shouldn't come here */
  4375. i++;
  4376. }
  4377. while ( attribute_names[i] );
  4378. }
  4379. /**
  4380. * load the text comparison structure in the grisbi file
  4381. *
  4382. * \param attribute_names
  4383. * \param attribute_values
  4384. *
  4385. * */
  4386. void gsb_file_load_text_comparison ( const gchar **attribute_names,
  4387. const gchar **attribute_values )
  4388. {
  4389. gint text_comparison_number = 0;
  4390. gint i=0;
  4391. gint report_number = 0;
  4392. if ( !attribute_names[i] )
  4393. return;
  4394. do
  4395. {
  4396. /* we test at the beginning if the attribute_value is NULL, if yes, */
  4397. /* go to the next */
  4398. if ( !strcmp (attribute_values[i],
  4399. "(null)"))
  4400. {
  4401. i++;
  4402. continue;
  4403. }
  4404. if ( !strcmp ( attribute_names[i],
  4405. "Comparison_number" ))
  4406. {
  4407. /* if comparison number is -1, it's an import of report,
  4408. * so let grisbi choose the good number */
  4409. if (utils_str_atoi (attribute_values[i]) == -1)
  4410. text_comparison_number = gsb_data_report_text_comparison_new (0);
  4411. else
  4412. text_comparison_number = gsb_data_report_text_comparison_new (utils_str_atoi (attribute_values[i]));
  4413. i++;
  4414. continue;
  4415. }
  4416. if ( !strcmp ( attribute_names[i],
  4417. "Report_nb" ))
  4418. {
  4419. report_number = utils_str_atoi (attribute_values[i]);
  4420. /* if report_number = -1, it's an import of report,
  4421. * so that comparison structure must be associated to the last report_number saved */
  4422. if (report_number == -1)
  4423. {
  4424. report_number = gsb_data_report_max_number ();
  4425. gsb_data_report_text_comparison_set_report_number ( text_comparison_number,
  4426. report_number);
  4427. }
  4428. else
  4429. gsb_data_report_text_comparison_set_report_number ( text_comparison_number,
  4430. report_number );
  4431. i++;
  4432. continue;
  4433. }
  4434. if ( !strcmp ( attribute_names[i],
  4435. "Last_comparison" ))
  4436. {
  4437. gsb_data_report_text_comparison_set_link_to_last_text_comparison ( text_comparison_number,
  4438. utils_str_atoi (attribute_values[i]));
  4439. i++;
  4440. continue;
  4441. }
  4442. if ( !strcmp ( attribute_names[i],
  4443. "Object" ))
  4444. {
  4445. gsb_data_report_text_comparison_set_field ( text_comparison_number,
  4446. utils_str_atoi (attribute_values[i]));
  4447. i++;
  4448. continue;
  4449. }
  4450. if ( !strcmp ( attribute_names[i],
  4451. "Operator" ))
  4452. {
  4453. gsb_data_report_text_comparison_set_operator ( text_comparison_number,
  4454. utils_str_atoi (attribute_values[i]));
  4455. i++;
  4456. continue;
  4457. }
  4458. if ( !strcmp ( attribute_names[i],
  4459. "Text" ))
  4460. {
  4461. gsb_data_report_text_comparison_set_text ( text_comparison_number,
  4462. attribute_values[i]);
  4463. i++;
  4464. continue;
  4465. }
  4466. if ( !strcmp ( attribute_names[i],
  4467. "Use_text" ))
  4468. {
  4469. gsb_data_report_text_comparison_set_use_text ( text_comparison_number,
  4470. utils_str_atoi (attribute_values[i]));
  4471. i++;
  4472. continue;
  4473. }
  4474. if ( !strcmp ( attribute_names[i],
  4475. "Comparison_1" ))
  4476. {
  4477. gsb_data_report_text_comparison_set_first_comparison ( text_comparison_number,
  4478. utils_str_atoi (attribute_values[i]));
  4479. i++;
  4480. continue;
  4481. }
  4482. if ( !strcmp ( attribute_names[i],
  4483. "Link_1_2" ))
  4484. {
  4485. gsb_data_report_text_comparison_set_link_first_to_second_part ( text_comparison_number,
  4486. utils_str_atoi (attribute_values[i]));
  4487. i++;
  4488. continue;
  4489. }
  4490. if ( !strcmp ( attribute_names[i],
  4491. "Comparison_2" ))
  4492. {
  4493. gsb_data_report_text_comparison_set_second_comparison ( text_comparison_number,
  4494. utils_str_atoi (attribute_values[i]));
  4495. i++;
  4496. continue;
  4497. }
  4498. if ( !strcmp ( attribute_names[i],
  4499. "Amount_1" ))
  4500. {
  4501. gsb_data_report_text_comparison_set_first_amount ( text_comparison_number,
  4502. utils_str_atoi (attribute_values[i]));
  4503. i++;
  4504. continue;
  4505. }
  4506. if ( !strcmp ( attribute_names[i],
  4507. "Amount_2" ))
  4508. {
  4509. gsb_data_report_text_comparison_set_second_amount ( text_comparison_number,
  4510. utils_str_atoi (attribute_values[i]));
  4511. i++;
  4512. continue;
  4513. }
  4514. /* normally, shouldn't come here */
  4515. i++;
  4516. }
  4517. while ( attribute_names[i] );
  4518. gsb_data_report_set_text_comparison_list ( report_number,
  4519. g_slist_append ( gsb_data_report_get_text_comparison_list (report_number),
  4520. GINT_TO_POINTER (text_comparison_number)));
  4521. }
  4522. /**
  4523. * load the amount comparaison structure in the grisbi file
  4524. *
  4525. * \param attribute_names
  4526. * \param attribute_values
  4527. *
  4528. * */
  4529. void gsb_file_load_amount_comparison ( const gchar **attribute_names,
  4530. const gchar **attribute_values )
  4531. {
  4532. gint i=0;
  4533. gint amount_comparison_number = 0;
  4534. gint report_number = 0;
  4535. if ( !attribute_names[i] )
  4536. return;
  4537. do
  4538. {
  4539. /* we test at the beginning if the attribute_value is NULL, if yes, */
  4540. /* go to the next */
  4541. if ( !strcmp (attribute_values[i],
  4542. "(null)"))
  4543. {
  4544. i++;
  4545. continue;
  4546. }
  4547. if ( !strcmp ( attribute_names[i],
  4548. "Comparison_number" ))
  4549. {
  4550. /* if comparison number is -1, it's an import of report,
  4551. * so let grisbi choose the good number */
  4552. if (utils_str_atoi (attribute_values[i]) == -1)
  4553. amount_comparison_number = gsb_data_report_amount_comparison_new (0);
  4554. else
  4555. amount_comparison_number = gsb_data_report_amount_comparison_new (utils_str_atoi (attribute_values[i]));
  4556. i++;
  4557. continue;
  4558. }
  4559. if ( !strcmp ( attribute_names[i],
  4560. "Report_nb" ))
  4561. {
  4562. report_number = utils_str_atoi (attribute_values[i]);
  4563. /* if report_number = -1, it's an import of report,
  4564. * so that comparison structure must be associated to the last report_number saved */
  4565. if (report_number == -1)
  4566. {
  4567. report_number = gsb_data_report_max_number ();
  4568. gsb_data_report_amount_comparison_set_report_number ( amount_comparison_number,
  4569. report_number);
  4570. }
  4571. else
  4572. gsb_data_report_amount_comparison_set_report_number ( amount_comparison_number,
  4573. report_number);
  4574. i++;
  4575. continue;
  4576. }
  4577. if ( !strcmp ( attribute_names[i],
  4578. "Last_comparison" ))
  4579. {
  4580. gsb_data_report_amount_comparison_set_link_to_last_amount_comparison ( amount_comparison_number,
  4581. utils_str_atoi (attribute_values[i]));
  4582. i++;
  4583. continue;
  4584. }
  4585. if ( !strcmp ( attribute_names[i],
  4586. "Comparison_1" ))
  4587. {
  4588. gsb_data_report_amount_comparison_set_first_comparison ( amount_comparison_number,
  4589. utils_str_atoi (attribute_values[i]));
  4590. i++;
  4591. continue;
  4592. }
  4593. if ( !strcmp ( attribute_names[i],
  4594. "Link_1_2" ))
  4595. {
  4596. gsb_data_report_amount_comparison_set_link_first_to_second_part ( amount_comparison_number,
  4597. utils_str_atoi (attribute_values[i]));
  4598. i++;
  4599. continue;
  4600. }
  4601. if ( !strcmp ( attribute_names[i],
  4602. "Comparison_2" ))
  4603. {
  4604. gsb_data_report_amount_comparison_set_second_comparison ( amount_comparison_number,
  4605. utils_str_atoi (attribute_values[i]));
  4606. i++;
  4607. continue;
  4608. }
  4609. if ( !strcmp ( attribute_names[i],
  4610. "Amount_1" ))
  4611. {
  4612. gsb_data_report_amount_comparison_set_first_amount ( amount_comparison_number,
  4613. gsb_real_safe_real_from_string (attribute_values[i]));
  4614. i++;
  4615. continue;
  4616. }
  4617. if ( !strcmp ( attribute_names[i],
  4618. "Amount_2" ))
  4619. {
  4620. gsb_data_report_amount_comparison_set_second_amount ( amount_comparison_number,
  4621. gsb_real_safe_real_from_string (attribute_values[i]));
  4622. i++;
  4623. continue;
  4624. }
  4625. /* normally, shouldn't come here */
  4626. i++;
  4627. }
  4628. while ( attribute_names[i] );
  4629. gsb_data_report_set_amount_comparison_list ( report_number,
  4630. g_slist_append ( gsb_data_report_get_amount_comparison_list (report_number),
  4631. GINT_TO_POINTER (amount_comparison_number)));
  4632. }
  4633. /**
  4634. * load the logo_accueil in the grisbi file
  4635. *
  4636. * \param attribute_names
  4637. * \param attribute_values
  4638. *
  4639. * */
  4640. void gsb_file_load_logo_accueil ( const gchar **attribute_names,
  4641. const gchar **attribute_values )
  4642. {
  4643. gint i=0;
  4644. do
  4645. {
  4646. /* we test at the beginning if the attribute_value is NULL, if yes, */
  4647. /* go to the next */
  4648. if ( !strcmp (attribute_values[i],
  4649. "(null)"))
  4650. {
  4651. i++;
  4652. continue;
  4653. }
  4654. if ( !strcmp ( attribute_names[i], "Image" ) )
  4655. {
  4656. GdkPixbuf *pixbuf = NULL;
  4657. pixbuf = gsb_select_icon_create_pixbuf_from_chaine_base64 (
  4658. (gchar *) attribute_values[i] );
  4659. etat.is_pixmaps_dir = FALSE;
  4660. gtk_window_set_default_icon ( pixbuf );
  4661. gsb_select_icon_set_logo_pixbuf ( pixbuf );
  4662. i++;
  4663. continue;
  4664. }
  4665. }
  4666. while ( attribute_names[i] );
  4667. }
  4668. /**
  4669. * charge les icones pour les comptes
  4670. *
  4671. * \param attribute_names
  4672. * \param attribute_values
  4673. *
  4674. * */
  4675. void gsb_file_load_account_icon_part ( const gchar **attribute_names,
  4676. const gchar **attribute_values )
  4677. {
  4678. gint i=0;
  4679. gint account_number = -1;
  4680. GdkPixbuf *pixbuf = NULL;
  4681. do
  4682. {
  4683. /* we test at the beginning if the attribute_value is NULL, if yes, */
  4684. /* go to the next */
  4685. if ( !strcmp (attribute_values[i], "(null)"))
  4686. {
  4687. i++;
  4688. continue;
  4689. }
  4690. if ( !strcmp ( attribute_names[i], "Account_number" ) )
  4691. {
  4692. account_number = utils_str_atoi ( attribute_values[i] );
  4693. i++;
  4694. continue;
  4695. }
  4696. if ( !strcmp ( attribute_names[i], "Image" ) )
  4697. {
  4698. pixbuf = gsb_select_icon_create_pixbuf_from_chaine_base64 (
  4699. (gchar *) attribute_values[i] );
  4700. i++;
  4701. continue;
  4702. }
  4703. }
  4704. while ( attribute_names[i] );
  4705. if ( account_number != -1 && pixbuf )
  4706. {
  4707. gsb_select_icon_new_account_icon ( account_number, pixbuf );
  4708. gsb_data_account_set_account_icon_pixbuf ( account_number, pixbuf );
  4709. }
  4710. }
  4711. void gsb_file_load_start_element_before_0_6 ( GMarkupParseContext *context,
  4712. const gchar *element_name,
  4713. const gchar **attribute_names,
  4714. const gchar **attribute_values,
  4715. gpointer user_data,
  4716. GError **error)
  4717. {
  4718. /* the first time we come here, we check if it's a grisbi file */
  4719. gchar **pointeur_char;
  4720. if ( !download_tmp_values.download_ok )
  4721. {
  4722. if ( strcmp ( element_name,
  4723. "Grisbi" ))
  4724. {
  4725. dialogue_error ( _("This is not a Grisbi file... Loading aborted.") );
  4726. g_markup_parse_context_end_parse (context,
  4727. NULL);
  4728. return;
  4729. }
  4730. download_tmp_values.download_ok = TRUE;
  4731. return;
  4732. }
  4733. /* to split the functions, we will set to 1 each time we begin a new part */
  4734. if ( !strcmp ( element_name,
  4735. "Generalites" )
  4736. &&
  4737. !download_tmp_values.account_part
  4738. &&
  4739. !download_tmp_values.report_part )
  4740. {
  4741. download_tmp_values.general_part = TRUE;
  4742. return;
  4743. }
  4744. if ( !strcmp ( element_name,
  4745. "Comptes" ))
  4746. {
  4747. download_tmp_values.account_part = TRUE;
  4748. return;
  4749. }
  4750. if ( !strcmp ( element_name,
  4751. "Etats" ))
  4752. {
  4753. download_tmp_values.report_part = TRUE;
  4754. return;
  4755. }
  4756. if ( !strcmp ( element_name,
  4757. "Type" ))
  4758. {
  4759. gint i;
  4760. i = 0;
  4761. if ( attribute_names[i] )
  4762. {
  4763. gint payment_number;
  4764. gint last_number = 0;
  4765. struct payment_conversion_struct *conversion;
  4766. payment_number = gsb_data_payment_new (NULL);
  4767. do
  4768. {
  4769. if ( !strcmp ( attribute_names[i],
  4770. "No" ))
  4771. /* we just save the last number to do the conversion later */
  4772. last_number = utils_str_atoi (attribute_values[i]);
  4773. if ( !strcmp ( attribute_names[i],
  4774. "Nom" ))
  4775. gsb_data_payment_set_name ( payment_number,
  4776. attribute_values[i]);
  4777. if ( !strcmp ( attribute_names[i],
  4778. "Signe" ))
  4779. gsb_data_payment_set_sign ( payment_number,
  4780. utils_str_atoi (attribute_values[i]));
  4781. if ( !strcmp ( attribute_names[i],
  4782. "Affiche_entree" ))
  4783. gsb_data_payment_set_show_entry ( payment_number,
  4784. utils_str_atoi (attribute_values[i]));
  4785. if ( !strcmp ( attribute_names[i],
  4786. "Numerotation_auto" ))
  4787. gsb_data_payment_set_automatic_numbering ( payment_number,
  4788. utils_str_atoi (attribute_values[i]));
  4789. if ( !strcmp ( attribute_names[i],
  4790. "No_en_cours" ))
  4791. gsb_data_payment_set_last_number ( payment_number,
  4792. attribute_values[i] );
  4793. i++;
  4794. }
  4795. while ( attribute_names[i] );
  4796. /* before 0.6, account_number was not saved in the method of payment */
  4797. gsb_data_payment_set_account_number ( payment_number,
  4798. account_number );
  4799. /* append a conversion structure */
  4800. conversion = g_malloc0 (sizeof (struct payment_conversion_struct));
  4801. conversion -> account_number = account_number;
  4802. conversion -> last_payment_number = last_number;
  4803. conversion -> new_payment_number = payment_number;
  4804. payment_conversion_list = g_slist_append ( payment_conversion_list,
  4805. conversion );
  4806. return;
  4807. }
  4808. }
  4809. if ( !strcmp ( element_name,
  4810. "Operation" ))
  4811. {
  4812. gint i;
  4813. i = 0;
  4814. if ( attribute_names[i] )
  4815. {
  4816. gint transaction_number = 0;
  4817. do
  4818. {
  4819. gchar **pointeur_char;
  4820. if ( !strcmp ( attribute_names[i],
  4821. "No" ))
  4822. transaction_number = gsb_data_transaction_new_transaction_with_number ( account_number,
  4823. utils_str_atoi ( attribute_values[i]));
  4824. if ( !strcmp ( attribute_names[i],
  4825. "Id" ))
  4826. gsb_data_transaction_set_transaction_id ( transaction_number,
  4827. attribute_values[i] );
  4828. if ( !strcmp ( attribute_names[i],
  4829. "D" ))
  4830. {
  4831. GDate *date;
  4832. pointeur_char = g_strsplit ( attribute_values[i], "/", 0 );
  4833. date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  4834. utils_str_atoi ( pointeur_char[1] ),
  4835. utils_str_atoi ( pointeur_char[2] ));
  4836. gsb_data_transaction_set_date ( transaction_number,
  4837. date);
  4838. g_strfreev ( pointeur_char );
  4839. if (date)
  4840. g_date_free (date);
  4841. }
  4842. if ( !strcmp ( attribute_names[i],
  4843. "Db" )
  4844. && attribute_values[i]
  4845. && strlen (attribute_values[i]) )
  4846. {
  4847. pointeur_char = g_strsplit ( attribute_values[i],
  4848. "/",
  4849. 0 );
  4850. /* sometimes we had 0/0/0 */
  4851. if(utils_str_atoi (pointeur_char[0]))
  4852. {
  4853. GDate *date;
  4854. date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  4855. utils_str_atoi ( pointeur_char[1] ),
  4856. utils_str_atoi ( pointeur_char[2] ));
  4857. gsb_data_transaction_set_value_date ( transaction_number,
  4858. date );
  4859. if (date)
  4860. g_date_free (date);
  4861. }
  4862. g_strfreev (pointeur_char);
  4863. }
  4864. if ( !strcmp ( attribute_names[i],
  4865. "M" ))
  4866. {
  4867. /* to go to the 0.6.0 we need to change the amount string
  4868. * from 12.340000 to 12.34 before doing the conversion */
  4869. gchar *tmp_string;
  4870. gsb_real number;
  4871. tmp_string = utils_str_reduce_exponant_from_string ( attribute_values[i], 2 );
  4872. number = gsb_real_get_from_string (tmp_string);
  4873. /* printf ("tmp_string = %s number.mantissa = %ld number.exponent = %d\n", tmp_string,
  4874. number.mantissa, number.exponent); */
  4875. gsb_data_transaction_set_amount ( transaction_number,
  4876. gsb_real_get_from_string (tmp_string));
  4877. if (tmp_string) g_free (tmp_string);
  4878. }
  4879. if ( !strcmp ( attribute_names[i],
  4880. "De" ))
  4881. gsb_data_transaction_set_currency_number ( transaction_number,
  4882. utils_str_atoi ( attribute_values[i]));
  4883. if ( !strcmp ( attribute_names[i],
  4884. "Rdc" ))
  4885. gsb_data_transaction_set_change_between ( transaction_number,
  4886. utils_str_atoi ( attribute_values[i]));
  4887. if ( !strcmp ( attribute_names[i],
  4888. "Tc" ))
  4889. gsb_data_transaction_set_exchange_rate ( transaction_number,
  4890. gsb_real_get_from_string (attribute_values[i]));
  4891. if ( !strcmp ( attribute_names[i],
  4892. "Fc" ))
  4893. gsb_data_transaction_set_exchange_fees ( transaction_number,
  4894. gsb_real_get_from_string (attribute_values[i]));
  4895. if ( !strcmp ( attribute_names[i],
  4896. "T" ))
  4897. gsb_data_transaction_set_party_number ( transaction_number,
  4898. utils_str_atoi ( attribute_values[i]) );
  4899. if ( !strcmp ( attribute_names[i],
  4900. "C" ))
  4901. gsb_data_transaction_set_category_number ( transaction_number,
  4902. utils_str_atoi ( attribute_values[i]));
  4903. if ( !strcmp ( attribute_names[i],
  4904. "Sc" ))
  4905. gsb_data_transaction_set_sub_category_number ( transaction_number,
  4906. utils_str_atoi ( attribute_values[i]));
  4907. if ( !strcmp ( attribute_names[i],
  4908. "Ov" ))
  4909. gsb_data_transaction_set_split_of_transaction ( transaction_number,
  4910. utils_str_atoi ( attribute_values[i]) );
  4911. if ( !strcmp ( attribute_names[i],
  4912. "N" ))
  4913. gsb_data_transaction_set_notes ( transaction_number,
  4914. attribute_values[i]);
  4915. if ( !strcmp ( attribute_names[i],
  4916. "Ty" ))
  4917. gsb_data_transaction_set_method_of_payment_number ( transaction_number,
  4918. utils_str_atoi ( attribute_values[i]) );
  4919. if ( !strcmp ( attribute_names[i],
  4920. "Ct" ))
  4921. gsb_data_transaction_set_method_of_payment_content ( transaction_number,
  4922. attribute_values[i] );
  4923. if ( !strcmp ( attribute_names[i],
  4924. "P" ))
  4925. gsb_data_transaction_set_marked_transaction ( transaction_number,
  4926. utils_str_atoi ( attribute_values[i]));
  4927. if ( !strcmp ( attribute_names[i],
  4928. "A" ))
  4929. gsb_data_transaction_set_automatic_transaction ( transaction_number,
  4930. utils_str_atoi ( attribute_values[i]));
  4931. if ( !strcmp ( attribute_names[i],
  4932. "R" ))
  4933. gsb_data_transaction_set_reconcile_number ( transaction_number,
  4934. utils_str_atoi ( attribute_values[i]));
  4935. if ( !strcmp ( attribute_names[i],
  4936. "E" ))
  4937. gsb_data_transaction_set_financial_year_number ( transaction_number,
  4938. utils_str_atoi ( attribute_values[i]));
  4939. if ( !strcmp ( attribute_names[i],
  4940. "I" ))
  4941. gsb_data_transaction_set_budgetary_number ( transaction_number,
  4942. utils_str_atoi ( attribute_values[i]));
  4943. if ( !strcmp ( attribute_names[i],
  4944. "Si" ))
  4945. gsb_data_transaction_set_sub_budgetary_number ( transaction_number,
  4946. utils_str_atoi ( attribute_values[i]));
  4947. if ( !strcmp ( attribute_names[i],
  4948. "Pc" ))
  4949. gsb_data_transaction_set_voucher ( transaction_number,
  4950. attribute_values[i]);
  4951. if ( !strcmp ( attribute_names[i],
  4952. "Ibg" ))
  4953. gsb_data_transaction_set_bank_references ( transaction_number,
  4954. attribute_values[i]);
  4955. if ( !strcmp ( attribute_names[i],
  4956. "Ro" ))
  4957. gsb_data_transaction_set_contra_transaction_number ( transaction_number,
  4958. utils_str_atoi ( attribute_values[i]));
  4959. /* new in grisbi 0.6, no contra account number, so if it was -1,
  4960. * set contra transaction to -1 to set deleted account,
  4961. * else, do nothing with that value */
  4962. if ( !strcmp ( attribute_names[i],
  4963. "Rc" ))
  4964. {
  4965. if (utils_str_atoi (attribute_values[i]) == -1)
  4966. gsb_data_transaction_set_contra_transaction_number ( transaction_number,
  4967. -1 );
  4968. }
  4969. if ( !strcmp ( attribute_names[i],
  4970. "Va" ))
  4971. gsb_data_transaction_set_mother_transaction_number ( transaction_number,
  4972. utils_str_atoi ( attribute_values[i]));
  4973. i++;
  4974. }
  4975. while ( attribute_names[i] );
  4976. }
  4977. }
  4978. if ( !strcmp ( element_name,
  4979. "Echeance" ))
  4980. {
  4981. gint i;
  4982. i = 0;
  4983. if ( attribute_names[i] )
  4984. {
  4985. gint scheduled_number = 0;
  4986. do
  4987. {
  4988. if ( !strcmp ( attribute_names[i],
  4989. "No" ))
  4990. scheduled_number = gsb_data_scheduled_new_scheduled_with_number (utils_str_atoi (attribute_values[i]));
  4991. if ( !strcmp ( attribute_names[i],
  4992. "Date" ))
  4993. {
  4994. /* cannot use gsb_parse_date_string here because before, all date were dd/mm/yyyy */
  4995. GDate *date;
  4996. pointeur_char = g_strsplit ( attribute_values[i], "/", 0 );
  4997. date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  4998. utils_str_atoi ( pointeur_char[1] ),
  4999. utils_str_atoi ( pointeur_char[2] ));
  5000. gsb_data_scheduled_set_date ( scheduled_number, date);
  5001. g_strfreev ( pointeur_char );
  5002. if (date)
  5003. g_date_free ( date );
  5004. }
  5005. if ( !strcmp ( attribute_names[i],
  5006. "Compte" ))
  5007. gsb_data_scheduled_set_account_number ( scheduled_number,
  5008. utils_str_atoi (attribute_values[i]));
  5009. if ( !strcmp ( attribute_names[i],
  5010. "Montant" ))
  5011. {
  5012. /* to go to the 0.6.0 we need to change the amount string
  5013. * from 12.340000 to 12.34 before doing the conversion */
  5014. gchar *tmp_string;
  5015. tmp_string = utils_str_reduce_exponant_from_string ( attribute_values[i], 2 );
  5016. gsb_data_scheduled_set_amount ( scheduled_number,
  5017. gsb_real_get_from_string (tmp_string));
  5018. if (tmp_string) g_free (tmp_string);
  5019. }
  5020. if ( !strcmp ( attribute_names[i],
  5021. "Devise" ))
  5022. gsb_data_scheduled_set_currency_number ( scheduled_number,
  5023. utils_str_atoi (attribute_values[i]));
  5024. if ( !strcmp ( attribute_names[i],
  5025. "Tiers" ))
  5026. gsb_data_scheduled_set_party_number ( scheduled_number,
  5027. utils_str_atoi (attribute_values[i]));
  5028. if ( !strcmp ( attribute_names[i],
  5029. "Categorie" ))
  5030. gsb_data_scheduled_set_category_number ( scheduled_number,
  5031. utils_str_atoi (attribute_values[i]));
  5032. if ( !strcmp ( attribute_names[i],
  5033. "Sous-categorie" ))
  5034. gsb_data_scheduled_set_sub_category_number ( scheduled_number,
  5035. utils_str_atoi (attribute_values[i]));
  5036. if ( !strcmp ( attribute_names[i],
  5037. "Virement_compte" ))
  5038. gsb_data_scheduled_set_account_number_transfer ( scheduled_number,
  5039. utils_str_atoi (attribute_values[i]));
  5040. if ( !strcmp ( attribute_names[i],
  5041. "Type" ))
  5042. gsb_data_scheduled_set_method_of_payment_number ( scheduled_number,
  5043. utils_str_atoi (attribute_values[i]));
  5044. if ( !strcmp ( attribute_names[i],
  5045. "Type_contre_ope" ))
  5046. gsb_data_scheduled_set_contra_method_of_payment_number ( scheduled_number,
  5047. utils_str_atoi (attribute_values[i]));
  5048. if ( !strcmp ( attribute_names[i],
  5049. "Contenu_du_type" ))
  5050. gsb_data_scheduled_set_method_of_payment_content ( scheduled_number,
  5051. attribute_values[i]);
  5052. if ( !strcmp ( attribute_names[i],
  5053. "Exercice" ))
  5054. gsb_data_scheduled_set_financial_year_number ( scheduled_number,
  5055. utils_str_atoi (attribute_values[i]));
  5056. if ( !strcmp ( attribute_names[i],
  5057. "Imputation" ))
  5058. gsb_data_scheduled_set_budgetary_number ( scheduled_number,
  5059. utils_str_atoi (attribute_values[i]));
  5060. if ( !strcmp ( attribute_names[i],
  5061. "Sous-imputation" ))
  5062. gsb_data_scheduled_set_sub_budgetary_number ( scheduled_number,
  5063. utils_str_atoi (attribute_values[i]));
  5064. if ( !strcmp ( attribute_names[i],
  5065. "Notes" ))
  5066. gsb_data_scheduled_set_notes ( scheduled_number,
  5067. attribute_values[i]);
  5068. if ( !strcmp ( attribute_names[i],
  5069. "Automatique" ))
  5070. gsb_data_scheduled_set_automatic_scheduled ( scheduled_number,
  5071. utils_str_atoi (attribute_values[i]));
  5072. if ( !strcmp ( attribute_names[i],
  5073. "Periodicite" ))
  5074. gsb_data_scheduled_set_frequency ( scheduled_number,
  5075. utils_str_atoi (attribute_values[i]));
  5076. if ( !strcmp ( attribute_names[i],
  5077. "Intervalle_periodicite" ))
  5078. gsb_data_scheduled_set_user_interval ( scheduled_number,
  5079. utils_str_atoi (attribute_values[i]));
  5080. if ( !strcmp ( attribute_names[i],
  5081. "Periodicite_personnalisee" ))
  5082. gsb_data_scheduled_set_user_entry ( scheduled_number,
  5083. utils_str_atoi (attribute_values[i]));
  5084. if ( !strcmp ( attribute_names[i],
  5085. "Date_limite" )
  5086. &&
  5087. strlen (attribute_values[i]))
  5088. {
  5089. GDate *date;
  5090. pointeur_char = g_strsplit ( attribute_values[i], "/", 0 );
  5091. date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  5092. utils_str_atoi ( pointeur_char[1] ),
  5093. utils_str_atoi ( pointeur_char[2] ));
  5094. gsb_data_scheduled_set_limit_date ( scheduled_number, date);
  5095. g_strfreev ( pointeur_char );
  5096. if (date)
  5097. g_date_free ( date );
  5098. }
  5099. if ( !strcmp ( attribute_names[i],
  5100. "Ech_ventilee" ))
  5101. gsb_data_scheduled_set_split_of_scheduled ( scheduled_number,
  5102. utils_str_atoi (attribute_values[i]));
  5103. if ( !strcmp ( attribute_names[i],
  5104. "No_ech_associee" ))
  5105. gsb_data_scheduled_set_mother_scheduled_number ( scheduled_number,
  5106. utils_str_atoi (attribute_values[i]));
  5107. i++;
  5108. }
  5109. while ( attribute_names[i] );
  5110. }
  5111. }
  5112. if ( !strcmp ( element_name,
  5113. "Tiers" ))
  5114. {
  5115. gint i;
  5116. i = 0;
  5117. if ( attribute_names[i] )
  5118. {
  5119. gint payee_number;
  5120. payee_number = gsb_data_payee_new (NULL);
  5121. do
  5122. {
  5123. /* we test at the beginning if the attribute_value is NULL, if yes, */
  5124. /* go to the next */
  5125. if ( !strcmp (attribute_values[i],
  5126. "(null)"))
  5127. {
  5128. i++;
  5129. continue;
  5130. }
  5131. if ( !strcmp ( attribute_names[i],
  5132. "No" ))
  5133. {
  5134. payee_number = gsb_data_payee_set_new_number ( payee_number,
  5135. utils_str_atoi (attribute_values[i]));
  5136. i++;
  5137. continue;
  5138. }
  5139. if ( !strcmp ( attribute_names[i],
  5140. "Nom" ))
  5141. {
  5142. gsb_data_payee_set_name ( payee_number,
  5143. attribute_values[i]);
  5144. i++;
  5145. continue;
  5146. }
  5147. if ( !strcmp ( attribute_names[i],
  5148. "Informations" ))
  5149. {
  5150. gsb_data_payee_set_description ( payee_number,
  5151. attribute_values[i]);
  5152. i++;
  5153. continue;
  5154. }
  5155. /* normally, shouldn't come here */
  5156. i++;
  5157. }
  5158. while ( attribute_names[i] );
  5159. }
  5160. }
  5161. if ( !strcmp ( element_name,
  5162. "Categorie" ))
  5163. {
  5164. gint i = 0;
  5165. while ( attribute_names[i] )
  5166. {
  5167. if ( !strcmp ( attribute_names[i],
  5168. "No" ))
  5169. last_category = gsb_data_category_new_with_number ( utils_str_atoi (attribute_values[i]));
  5170. if ( !strcmp ( attribute_names[i],
  5171. "Nom" ))
  5172. gsb_data_category_set_name ( last_category,
  5173. attribute_values[i]);
  5174. if ( !strcmp ( attribute_names[i],
  5175. "Type" ))
  5176. gsb_data_category_set_type ( last_category,
  5177. utils_str_atoi (attribute_values[i]));
  5178. i++;
  5179. }
  5180. }
  5181. if ( !strcmp ( element_name,
  5182. "Sous-categorie" ))
  5183. {
  5184. gint i = 0;
  5185. /* each sub-category is stored after a category, so last_category should be filled before */
  5186. while ( attribute_names[i] )
  5187. {
  5188. if ( !strcmp ( attribute_names[i],
  5189. "No" ))
  5190. last_sub_category_number = gsb_data_category_new_sub_category_with_number ( utils_str_atoi (attribute_values[i]),
  5191. last_category);
  5192. if ( !strcmp ( attribute_names[i],
  5193. "Nom" ))
  5194. gsb_data_category_set_sub_category_name ( last_category,
  5195. last_sub_category_number,
  5196. attribute_values[i]);
  5197. i++;
  5198. }
  5199. }
  5200. if ( !strcmp ( element_name,
  5201. "Imputation" ))
  5202. {
  5203. gint i = 0;
  5204. while ( attribute_names[i] )
  5205. {
  5206. if ( !strcmp ( attribute_names[i],
  5207. "No" ))
  5208. last_budget = gsb_data_budget_new_with_number ( utils_str_atoi (attribute_values[i]));
  5209. if ( !strcmp ( attribute_names[i],
  5210. "Nom" ))
  5211. gsb_data_budget_set_name ( last_budget,
  5212. attribute_values[i]);
  5213. if ( !strcmp ( attribute_names[i],
  5214. "Type" ))
  5215. gsb_data_budget_set_type ( last_budget,
  5216. utils_str_atoi (attribute_values[i]));
  5217. i++;
  5218. }
  5219. }
  5220. if ( !strcmp ( element_name,
  5221. "Sous-imputation" ))
  5222. {
  5223. gint i = 0;
  5224. /* each sub-budget is stored after a budget, so last_budget should be filled before */
  5225. while ( attribute_names[i] )
  5226. {
  5227. if ( !strcmp ( attribute_names[i],
  5228. "No" ))
  5229. last_sub_budget_number = gsb_data_budget_new_sub_budget_with_number ( utils_str_atoi (attribute_values[i]),
  5230. last_budget);
  5231. if ( !strcmp ( attribute_names[i],
  5232. "Nom" ))
  5233. gsb_data_budget_set_sub_budget_name ( last_budget,
  5234. last_sub_budget_number,
  5235. attribute_values[i]);
  5236. i++;
  5237. }
  5238. }
  5239. if ( !strcmp ( element_name,
  5240. "Devise" ))
  5241. {
  5242. gint i;
  5243. i = 0;
  5244. if ( attribute_names[i] )
  5245. {
  5246. gint currency_number;
  5247. struct {
  5248. gint one_c1_equal_x_c2;
  5249. gint contra_currency;
  5250. gsb_real exchange;
  5251. } tmp_currency_link;
  5252. GDate *modified_date = NULL;
  5253. tmp_currency_link.one_c1_equal_x_c2 = 0;
  5254. tmp_currency_link.contra_currency = 0;
  5255. tmp_currency_link.exchange = null_real;
  5256. currency_number = gsb_data_currency_new (NULL);
  5257. /* Default */
  5258. gsb_data_currency_set_floating_point ( currency_number, 2 );
  5259. do
  5260. {
  5261. if ( !strcmp ( attribute_names[i],
  5262. "No" ))
  5263. currency_number = gsb_data_currency_set_new_number ( currency_number,
  5264. utils_str_atoi (attribute_values[i]));
  5265. if ( !strcmp ( attribute_names[i],
  5266. "Nom" ))
  5267. gsb_data_currency_set_name ( currency_number,
  5268. attribute_values[i]);
  5269. if ( !strcmp ( attribute_names[i],
  5270. "IsoCode" )
  5271. &&
  5272. strlen (attribute_values[i]))
  5273. gsb_data_currency_set_code_iso4217 ( currency_number,
  5274. attribute_values[i]);
  5275. if ( !strcmp ( attribute_names[i],
  5276. "Code" )
  5277. &&
  5278. strlen (attribute_values[i]))
  5279. {
  5280. struct iso_4217_currency * currency = iso_4217_currencies;
  5281. gsb_data_currency_set_code ( currency_number,
  5282. attribute_values[i]);
  5283. /* Check if a iso code is the same as currency code (old import). */
  5284. while ( currency -> country_name )
  5285. {
  5286. if ( !strcmp ( currency -> currency_code, attribute_values[i] ) )
  5287. {
  5288. gsb_data_currency_set_code_iso4217 ( currency_number,
  5289. attribute_values[i]);
  5290. }
  5291. currency++;
  5292. }
  5293. }
  5294. /* beyond the 0.6, the next part is not anymore in the currencies, but alone
  5295. * and simplified...
  5296. * so we do the transition here */
  5297. if ( !strcmp ( attribute_names[i],
  5298. "Rapport_entre_devises" ))
  5299. tmp_currency_link.one_c1_equal_x_c2 = utils_str_atoi (attribute_values[i]);
  5300. if ( !strcmp ( attribute_names[i],
  5301. "Devise_en_rapport" ))
  5302. tmp_currency_link.contra_currency = utils_str_atoi (attribute_values[i]);
  5303. if ( !strcmp ( attribute_names[i],
  5304. "Change" ))
  5305. tmp_currency_link.exchange = gsb_real_get_from_string (attribute_values[i]);
  5306. if ( !strcmp ( attribute_names[i], "Date_dernier_change" )
  5307. &&
  5308. strlen ( attribute_values[i] ) )
  5309. {
  5310. /* cannot use gsb_parse_date_string here because before, all date were dd/mm/yyyy */
  5311. pointeur_char = g_strsplit ( attribute_values[i], "/", 0 );
  5312. modified_date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  5313. utils_str_atoi ( pointeur_char[1] ),
  5314. utils_str_atoi ( pointeur_char[2] ) );
  5315. g_strfreev ( pointeur_char );
  5316. }
  5317. i++;
  5318. }
  5319. while ( attribute_names[i] );
  5320. /* create now the link between currencies if necessary
  5321. * don't create if the exchange is null event if the link was created before,
  5322. * else we will become very rich in grisbi !!! */
  5323. if (tmp_currency_link.contra_currency && tmp_currency_link.exchange.mantissa != 0)
  5324. {
  5325. gint link_number;
  5326. link_number = gsb_data_currency_link_new ( 0 );
  5327. if (tmp_currency_link.one_c1_equal_x_c2)
  5328. {
  5329. gsb_data_currency_link_set_first_currency ( link_number,
  5330. currency_number );
  5331. gsb_data_currency_link_set_second_currency ( link_number,
  5332. tmp_currency_link.contra_currency);
  5333. }
  5334. else
  5335. {
  5336. gsb_data_currency_link_set_first_currency ( link_number,
  5337. tmp_currency_link.contra_currency );
  5338. gsb_data_currency_link_set_second_currency ( link_number,
  5339. currency_number);
  5340. }
  5341. gsb_data_currency_link_set_change_rate ( link_number,
  5342. tmp_currency_link.exchange );
  5343. if ( modified_date )
  5344. {
  5345. gsb_data_currency_link_set_modified_date ( link_number, modified_date );
  5346. g_date_free ( modified_date );
  5347. }
  5348. }
  5349. }
  5350. }
  5351. if ( !strcmp ( element_name,
  5352. "Banque" ))
  5353. {
  5354. gint i;
  5355. i = 0;
  5356. if ( attribute_names[i] )
  5357. {
  5358. gint bank_number = 0;
  5359. do
  5360. {
  5361. if ( !strcmp ( attribute_names[i],
  5362. "No" ))
  5363. {
  5364. bank_number = gsb_data_bank_set_new_number ( gsb_data_bank_new (NULL),
  5365. utils_str_atoi (attribute_values[i]));
  5366. }
  5367. if ( !strcmp ( attribute_names[i],
  5368. "Nom" ))
  5369. gsb_data_bank_set_name ( bank_number,
  5370. attribute_values[i] );
  5371. if ( !strcmp ( attribute_names[i],
  5372. "Code" ))
  5373. gsb_data_bank_set_code ( bank_number,
  5374. attribute_values[i] );
  5375. if ( !strcmp ( attribute_names[i],
  5376. "Adresse" ))
  5377. gsb_data_bank_set_bank_address ( bank_number,
  5378. attribute_values[i] );
  5379. if ( !strcmp ( attribute_names[i],
  5380. "Tel" ))
  5381. gsb_data_bank_set_bank_tel ( bank_number,
  5382. attribute_values[i] );
  5383. if ( !strcmp ( attribute_names[i],
  5384. "Mail" ))
  5385. gsb_data_bank_set_bank_mail ( bank_number,
  5386. attribute_values[i] );
  5387. if ( !strcmp ( attribute_names[i],
  5388. "Web" ))
  5389. gsb_data_bank_set_bank_web ( bank_number,
  5390. attribute_values[i] );
  5391. if ( !strcmp ( attribute_names[i],
  5392. "Nom_correspondant" ))
  5393. gsb_data_bank_set_correspondent_name ( bank_number,
  5394. attribute_values[i] );
  5395. if ( !strcmp ( attribute_names[i],
  5396. "Fax_correspondant" ))
  5397. gsb_data_bank_set_correspondent_fax ( bank_number,
  5398. attribute_values[i] );
  5399. if ( !strcmp ( attribute_names[i],
  5400. "Tel_correspondant" ))
  5401. gsb_data_bank_set_correspondent_tel ( bank_number,
  5402. attribute_values[i] );
  5403. if ( !strcmp ( attribute_names[i],
  5404. "Mail_correspondant" ))
  5405. gsb_data_bank_set_correspondent_mail ( bank_number,
  5406. attribute_values[i] );
  5407. if ( !strcmp ( attribute_names[i],
  5408. "Remarques" ))
  5409. gsb_data_bank_set_bank_note ( bank_number,
  5410. attribute_values[i] );
  5411. i++;
  5412. }
  5413. while ( attribute_names[i] );
  5414. }
  5415. }
  5416. if ( !strcmp ( element_name,
  5417. "Exercice" ))
  5418. {
  5419. gint i = 0;
  5420. if ( attribute_names[i] )
  5421. {
  5422. gint fyear_number;
  5423. fyear_number = gsb_data_fyear_new (NULL);
  5424. do
  5425. {
  5426. if ( !strcmp ( attribute_names[i],
  5427. "No" ))
  5428. fyear_number = gsb_data_fyear_set_new_number ( fyear_number,
  5429. utils_str_atoi ( attribute_values[i]));
  5430. if ( !strcmp ( attribute_names[i],
  5431. "Nom" ))
  5432. gsb_data_fyear_set_name ( fyear_number,
  5433. attribute_values[i]);
  5434. if ( !strcmp ( attribute_names[i],
  5435. "Date_debut" )
  5436. &&
  5437. strlen (attribute_values[i]))
  5438. {
  5439. GDate *date;
  5440. pointeur_char = g_strsplit ( attribute_values[i], "/", 0 );
  5441. date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  5442. utils_str_atoi ( pointeur_char[1] ),
  5443. utils_str_atoi ( pointeur_char[2] ));
  5444. gsb_data_fyear_set_beginning_date ( fyear_number, date);
  5445. g_strfreev ( pointeur_char );
  5446. if (date)
  5447. g_date_free (date);
  5448. }
  5449. if ( !strcmp ( attribute_names[i],
  5450. "Date_fin" )
  5451. &&
  5452. strlen (attribute_values[i]))
  5453. {
  5454. GDate *date;
  5455. pointeur_char = g_strsplit ( attribute_values[i], "/", 0 );
  5456. date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  5457. utils_str_atoi ( pointeur_char[1] ),
  5458. utils_str_atoi ( pointeur_char[2] ));
  5459. gsb_data_fyear_set_end_date ( fyear_number, date);
  5460. g_strfreev ( pointeur_char );
  5461. if (date)
  5462. g_date_free (date);
  5463. }
  5464. if ( !strcmp ( attribute_names[i],
  5465. "Affiche" ))
  5466. gsb_data_fyear_set_form_show ( fyear_number,
  5467. utils_str_atoi ( attribute_values[i]));
  5468. i++;
  5469. }
  5470. while ( attribute_names[i] );
  5471. gsb_data_fyear_check_for_invalid (fyear_number);
  5472. }
  5473. }
  5474. if ( !strcmp ( element_name,
  5475. "Rapprochement" ))
  5476. {
  5477. gint i;
  5478. i = 0;
  5479. if ( attribute_names[i] )
  5480. {
  5481. gint reconcile_number;
  5482. reconcile_number = gsb_data_reconcile_new (NULL);
  5483. /* before 0.6, reconcile contains only a name so we fill for now
  5484. * with default values the field of the reconcile, and we will
  5485. * try to fill them later */
  5486. gsb_data_reconcile_set_account ( reconcile_number,
  5487. -1 );
  5488. gsb_data_reconcile_set_init_balance ( reconcile_number,
  5489. null_real );
  5490. gsb_data_reconcile_set_final_balance ( reconcile_number,
  5491. null_real );
  5492. do
  5493. {
  5494. if ( !strcmp ( attribute_names[i],
  5495. "No" ))
  5496. reconcile_number = gsb_data_reconcile_set_new_number (reconcile_number,
  5497. utils_str_atoi ( attribute_values[i]));
  5498. if ( !strcmp ( attribute_names[i],
  5499. "Nom" ))
  5500. gsb_data_reconcile_set_name ( reconcile_number,
  5501. attribute_values[i]);
  5502. i++;
  5503. }
  5504. while ( attribute_names[i] );
  5505. }
  5506. }
  5507. if ( !strcmp ( element_name,
  5508. "Comp" )
  5509. &&
  5510. attribute_names[1]
  5511. &&
  5512. !strcmp ( attribute_names[1],
  5513. "Champ" ))
  5514. {
  5515. gint i;
  5516. i = 0;
  5517. if ( attribute_names[i] )
  5518. {
  5519. gint text_comparison_number;
  5520. /* no number for version <0.6 */
  5521. text_comparison_number = gsb_data_report_text_comparison_new (0);
  5522. gsb_data_report_text_comparison_set_report_number ( text_comparison_number,
  5523. last_report_number );
  5524. do
  5525. {
  5526. if ( !strcmp ( attribute_names[i],
  5527. "Lien_struct" ))
  5528. gsb_data_report_text_comparison_set_link_to_last_text_comparison ( text_comparison_number,
  5529. utils_str_atoi ( attribute_values[i]));
  5530. if ( !strcmp ( attribute_names[i],
  5531. "Champ" ))
  5532. gsb_data_report_text_comparison_set_field ( text_comparison_number,
  5533. utils_str_atoi ( attribute_values[i]));
  5534. if ( !strcmp ( attribute_names[i],
  5535. "Op" ))
  5536. gsb_data_report_text_comparison_set_operator ( text_comparison_number,
  5537. utils_str_atoi ( attribute_values[i]));
  5538. if ( !strcmp ( attribute_names[i],
  5539. "Txt" ))
  5540. gsb_data_report_text_comparison_set_text ( text_comparison_number,
  5541. attribute_values[i]);
  5542. if ( !strcmp ( attribute_names[i],
  5543. "Util_txt" ))
  5544. gsb_data_report_text_comparison_set_use_text ( text_comparison_number,
  5545. utils_str_atoi ( attribute_values[i]));
  5546. if ( !strcmp ( attribute_names[i],
  5547. "Comp_1" ))
  5548. gsb_data_report_text_comparison_set_first_comparison ( text_comparison_number,
  5549. utils_str_atoi ( attribute_values[i]));
  5550. if ( !strcmp ( attribute_names[i],
  5551. "Lien_1_2" ))
  5552. gsb_data_report_text_comparison_set_link_first_to_second_part ( text_comparison_number,
  5553. utils_str_atoi ( attribute_values[i]));
  5554. if ( !strcmp ( attribute_names[i],
  5555. "Comp_2" ))
  5556. gsb_data_report_text_comparison_set_second_comparison ( text_comparison_number,
  5557. utils_str_atoi ( attribute_values[i]));
  5558. if ( !strcmp ( attribute_names[i],
  5559. "Mont_1" ))
  5560. gsb_data_report_text_comparison_set_first_amount ( text_comparison_number,
  5561. utils_str_atoi ( attribute_values[i]));
  5562. if ( !strcmp ( attribute_names[i],
  5563. "Mont_2" ))
  5564. gsb_data_report_text_comparison_set_second_amount ( text_comparison_number,
  5565. utils_str_atoi ( attribute_values[i]));
  5566. i++;
  5567. }
  5568. while ( attribute_names[i] );
  5569. gsb_data_report_set_text_comparison_list ( last_report_number,
  5570. g_slist_append ( gsb_data_report_get_text_comparison_list (last_report_number),
  5571. GINT_TO_POINTER (text_comparison_number)));
  5572. }
  5573. return;
  5574. }
  5575. if ( !strcmp ( element_name,
  5576. "Comp" )
  5577. &&
  5578. attribute_names[1]
  5579. &&
  5580. !strcmp ( attribute_names[1],
  5581. "Comp_1" ))
  5582. {
  5583. gint i;
  5584. i = 0;
  5585. if ( attribute_names[i] )
  5586. {
  5587. gint amount_comparison_number;
  5588. /* no number for version <0.6 */
  5589. amount_comparison_number = gsb_data_report_amount_comparison_new (0);
  5590. gsb_data_report_amount_comparison_set_report_number ( amount_comparison_number,
  5591. last_report_number );
  5592. do
  5593. {
  5594. if ( !strcmp ( attribute_names[i],
  5595. "Lien_struct" ))
  5596. gsb_data_report_amount_comparison_set_link_to_last_amount_comparison ( amount_comparison_number,
  5597. utils_str_atoi ( attribute_values[i]));
  5598. if ( !strcmp ( attribute_names[i],
  5599. "Comp_1" ))
  5600. gsb_data_report_amount_comparison_set_first_comparison ( amount_comparison_number,
  5601. utils_str_atoi ( attribute_values[i]));
  5602. if ( !strcmp ( attribute_names[i],
  5603. "Lien_1_2" ))
  5604. gsb_data_report_amount_comparison_set_link_first_to_second_part ( amount_comparison_number,
  5605. utils_str_atoi ( attribute_values[i]));
  5606. if ( !strcmp ( attribute_names[i],
  5607. "Comp_2" ))
  5608. gsb_data_report_amount_comparison_set_second_comparison ( amount_comparison_number,
  5609. utils_str_atoi ( attribute_values[i]));
  5610. if ( !strcmp ( attribute_names[i],
  5611. "Mont_1" ))
  5612. {
  5613. /* to go to the 0.6.0 we need to change the amount string
  5614. * from 12.340000 to 12.34 before doing the conversion */
  5615. gchar *tmp_string;
  5616. tmp_string = utils_str_reduce_exponant_from_string ( attribute_values[i], 2 );
  5617. gsb_data_report_amount_comparison_set_first_amount ( amount_comparison_number,
  5618. gsb_real_get_from_string (tmp_string));
  5619. if (tmp_string) g_free (tmp_string);
  5620. }
  5621. if ( !strcmp ( attribute_names[i],
  5622. "Mont_2" ))
  5623. {
  5624. /* to go to the 0.6.0 we need to change the amount string
  5625. * from 12.340000 to 12.34 before doing the conversion */
  5626. gchar *tmp_string;
  5627. tmp_string = utils_str_reduce_exponant_from_string ( attribute_values[i], 2 );
  5628. gsb_data_report_amount_comparison_set_second_amount ( amount_comparison_number,
  5629. gsb_real_get_from_string (tmp_string));
  5630. if (tmp_string) g_free (tmp_string);
  5631. }
  5632. i++;
  5633. }
  5634. while ( attribute_names[i] );
  5635. gsb_data_report_set_amount_comparison_list ( last_report_number,
  5636. g_slist_append ( gsb_data_report_get_amount_comparison_list (last_report_number),
  5637. GINT_TO_POINTER (amount_comparison_number)));
  5638. return;
  5639. }
  5640. }
  5641. if ( !strcmp ( element_name,
  5642. "Mode_paie" ))
  5643. {
  5644. gint i;
  5645. i = 0;
  5646. if ( attribute_names[i] )
  5647. {
  5648. do
  5649. {
  5650. if ( !strcmp ( attribute_names[i],
  5651. "Nom" ))
  5652. gsb_data_report_set_method_of_payment_list ( last_report_number,
  5653. g_slist_append ( gsb_data_report_get_method_of_payment_list (last_report_number),
  5654. my_strdup (attribute_values[i])));
  5655. i++;
  5656. }
  5657. while ( attribute_names[i] );
  5658. }
  5659. return;
  5660. }
  5661. }
  5662. void gsb_file_load_end_element_before_0_6 ( GMarkupParseContext *context,
  5663. const gchar *element_name,
  5664. gpointer user_data,
  5665. GError **error)
  5666. {
  5667. /* when it's the end of an element, we set it in the split structure to 0 */
  5668. if ( !strcmp ( element_name,
  5669. "Generalites" ))
  5670. download_tmp_values.general_part = FALSE;
  5671. if ( !strcmp ( element_name,
  5672. "Comptes" ))
  5673. download_tmp_values.account_part = FALSE;
  5674. if ( !strcmp ( element_name,
  5675. "Etats" ))
  5676. download_tmp_values.report_part = FALSE;
  5677. }
  5678. void gsb_file_load_text_element_before_0_6 ( GMarkupParseContext *context,
  5679. const gchar *text,
  5680. gsize text_len,
  5681. gpointer user_data,
  5682. GError **error)
  5683. {
  5684. /* we come here for all text element, we split here to go
  5685. * on the necessary function to work with that element */
  5686. if ( download_tmp_values.general_part )
  5687. gsb_file_load_general_part_before_0_6 ( context,
  5688. text );
  5689. if ( download_tmp_values.account_part )
  5690. gsb_file_load_account_part_before_0_6 ( context,
  5691. text );
  5692. if ( download_tmp_values.report_part )
  5693. gsb_file_load_report_part_before_0_6 ( context,
  5694. text );
  5695. }
  5696. void gsb_file_load_general_part_before_0_6 ( GMarkupParseContext *context,
  5697. const gchar *text )
  5698. {
  5699. const gchar *element_name;
  5700. element_name = g_markup_parse_context_get_element ( context );
  5701. /* check here if we are not between 2 subsections */
  5702. if ( !strcmp ( element_name,
  5703. "Generalites" ))
  5704. return;
  5705. if ( !strcmp ( element_name,
  5706. "Version_fichier" ))
  5707. {
  5708. /* TODO dOM
  5709. if ( download_tmp_values.file_version )
  5710. g_free ( download_tmp_values.file_version );
  5711. */
  5712. download_tmp_values.file_version = my_strdup (text);
  5713. return;
  5714. }
  5715. if ( !strcmp ( element_name,
  5716. "Version_grisbi" ))
  5717. {
  5718. if ( download_tmp_values.grisbi_version )
  5719. g_free ( download_tmp_values.grisbi_version );
  5720. download_tmp_values.grisbi_version = my_strdup (text);
  5721. return;
  5722. }
  5723. if ( !strcmp ( element_name,
  5724. "Titre" ))
  5725. {
  5726. if ( titre_fichier )
  5727. g_free ( titre_fichier );
  5728. titre_fichier = my_strdup (text);
  5729. return;
  5730. }
  5731. if ( !strcmp ( element_name,
  5732. "Adresse_commune" ))
  5733. {
  5734. if ( adresse_commune )
  5735. g_free ( adresse_commune );
  5736. adresse_commune = my_strdup (text);
  5737. return;
  5738. }
  5739. if ( !strcmp ( element_name,
  5740. "Adresse_secondaire" ))
  5741. {
  5742. if ( adresse_secondaire )
  5743. g_free ( adresse_secondaire );
  5744. adresse_secondaire = my_strdup (text);
  5745. return;
  5746. }
  5747. if ( !strcmp ( element_name,
  5748. "Numero_devise_totaux_tiers" ))
  5749. {
  5750. no_devise_totaux_tiers = utils_str_atoi ( text);
  5751. return;
  5752. }
  5753. if ( !strcmp ( element_name,
  5754. "Type_affichage_des_echeances" ))
  5755. {
  5756. affichage_echeances = utils_str_atoi ( text);
  5757. /* Compatibility issue. */
  5758. switch ( affichage_echeances )
  5759. {
  5760. case 0: affichage_echeances = SCHEDULER_PERIODICITY_MONTH_VIEW; break;
  5761. case 1: affichage_echeances = SCHEDULER_PERIODICITY_TWO_MONTHS_VIEW; break;
  5762. case 2: affichage_echeances = SCHEDULER_PERIODICITY_YEAR_VIEW; break;
  5763. case 3: affichage_echeances = SCHEDULER_PERIODICITY_ONCE_VIEW; break;
  5764. case 4: affichage_echeances = SCHEDULER_PERIODICITY_CUSTOM_VIEW; break;
  5765. }
  5766. return;
  5767. }
  5768. if ( !strcmp ( element_name,
  5769. "Affichage_echeances_perso_nb_libre" ))
  5770. {
  5771. affichage_echeances_perso_nb_libre = utils_str_atoi ( text);
  5772. return;
  5773. }
  5774. if ( !strcmp ( element_name,
  5775. "Type_affichage_perso_echeances" ))
  5776. {
  5777. affichage_echeances_perso_j_m_a = utils_str_atoi ( text);
  5778. return;
  5779. }
  5780. if ( !strcmp ( element_name,
  5781. "Echelle_date_import" ))
  5782. {
  5783. valeur_echelle_recherche_date_import = utils_str_atoi ( text);
  5784. return;
  5785. }
  5786. if ( !strcmp ( element_name,
  5787. "Utilise_logo" ))
  5788. {
  5789. etat.utilise_logo = utils_str_atoi ( text);
  5790. return;
  5791. }
  5792. if ( !strcmp ( element_name,
  5793. "Chemin_logo" ))
  5794. {
  5795. GdkPixbuf *pixbuf;
  5796. gchar *chemin_logo;
  5797. chemin_logo = my_strdup (text);
  5798. pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
  5799. if ( pixbuf )
  5800. {
  5801. gtk_window_set_default_icon ( pixbuf );
  5802. gsb_select_icon_set_logo_pixbuf ( pixbuf );
  5803. }
  5804. if ( chemin_logo && strlen (chemin_logo) > 0 )
  5805. g_free ( chemin_logo );
  5806. return;
  5807. }
  5808. if ( !strcmp ( element_name,
  5809. "Caracteristiques_par_compte" ))
  5810. {
  5811. etat.retient_affichage_par_compte = utils_str_atoi(text);
  5812. return;
  5813. }
  5814. if ( !strcmp ( element_name,
  5815. "Affichage_opes" ))
  5816. {
  5817. gchar **pointeur_char;
  5818. gint i, j;
  5819. gint number_columns;
  5820. pointeur_char = g_strsplit ( my_strdup (text),
  5821. "-",
  5822. 0 );
  5823. /* there is a pb here to go from 0.5.5 and before, untill 0.6.0
  5824. * because the nb of columns goes from 8 to 9 ; the best is to
  5825. * check how much numbers there is and to divide it by TRANSACTION_LIST_ROWS_NB
  5826. * so we'll have the last nb of columns. it will work event if we increase again
  5827. * the number of columns, but we need to find another way if TRANSACTION_LIST_ROWS_NB
  5828. * increases */
  5829. i = 0;
  5830. while (pointeur_char[i])
  5831. i++;
  5832. number_columns = i/TRANSACTION_LIST_ROWS_NB;
  5833. for ( i=0 ; i<TRANSACTION_LIST_ROWS_NB ; i++ )
  5834. for ( j=0 ; j<= number_columns ; j++ )
  5835. {
  5836. /* we have to check here because if one time we change TRANSACTION_LIST_ROWS_NB or
  5837. * CUSTOM_MODEL_VISIBLE_COLUMNS, it will crash without that (ex : (5.5 -> 6.0 )) */
  5838. if ( pointeur_char[j + i*CUSTOM_MODEL_VISIBLE_COLUMNS] )
  5839. tab_affichage_ope[i][j] = utils_str_atoi ( pointeur_char[j + i*number_columns]);
  5840. else
  5841. j = CUSTOM_MODEL_VISIBLE_COLUMNS;
  5842. }
  5843. g_strfreev ( pointeur_char );
  5844. return;
  5845. }
  5846. if ( !strcmp ( element_name,
  5847. "Rapport_largeur_col_echeancier" ))
  5848. {
  5849. /* here do nothing because it was a ration before, and now it's fixed width,
  5850. * so come back to default */
  5851. return;
  5852. }
  5853. }
  5854. void gsb_file_load_account_part_before_0_6 ( GMarkupParseContext *context,
  5855. const gchar *text )
  5856. {
  5857. const gchar *element_name;
  5858. element_name = g_markup_parse_context_get_element ( context );
  5859. /* check here if we are not between 2 subsections or if we
  5860. * needn't that section */
  5861. if ( !strcmp ( element_name,
  5862. "Comptes" )
  5863. ||
  5864. !strcmp ( element_name,
  5865. "Compte" )
  5866. ||
  5867. !strcmp ( element_name,
  5868. "Detail_de_Types" )
  5869. ||
  5870. !strcmp ( element_name,
  5871. "Detail_des_operations" )
  5872. ||
  5873. !strcmp ( element_name,
  5874. "Details" ))
  5875. return;
  5876. if ( !strcmp ( element_name,
  5877. "Ordre_des_comptes" ))
  5878. {
  5879. gchar **pointeur_char;
  5880. gint i;
  5881. /* in the 0.6, the accounts are saved in the good order,
  5882. * so for before, get the order and reorder the list later */
  5883. pointeur_char = g_strsplit ( text,
  5884. "-",
  5885. 0 );
  5886. i = 0;
  5887. sort_accounts = NULL;
  5888. while ( pointeur_char[i] )
  5889. {
  5890. sort_accounts = g_slist_append ( sort_accounts,
  5891. GINT_TO_POINTER ( utils_str_atoi ( pointeur_char[i] )));
  5892. i++;
  5893. }
  5894. g_strfreev ( pointeur_char );
  5895. return;
  5896. }
  5897. if ( !strcmp ( element_name,
  5898. "Nom" ))
  5899. {
  5900. account_number = gsb_data_account_new ( GSB_TYPE_BANK );
  5901. gsb_data_account_set_name ( account_number,
  5902. text);
  5903. return;
  5904. }
  5905. if ( !strcmp ( element_name,
  5906. "Id_compte" ))
  5907. {
  5908. gsb_data_account_set_id (account_number,
  5909. text);
  5910. if ( !strlen ( gsb_data_account_get_id (account_number)))
  5911. gsb_data_account_set_id (account_number,
  5912. NULL );
  5913. return;
  5914. }
  5915. /* we change here the default number of the account */
  5916. if ( !strcmp ( element_name,
  5917. "No_de_compte" ))
  5918. {
  5919. account_number = gsb_data_account_set_account_number ( account_number,
  5920. utils_str_atoi ( text));
  5921. return;
  5922. }
  5923. if ( !strcmp ( element_name,
  5924. "Titulaire" ))
  5925. {
  5926. gsb_data_account_set_holder_name ( account_number,
  5927. text);
  5928. return;
  5929. }
  5930. if ( !strcmp ( element_name,
  5931. "Type_de_compte" ))
  5932. {
  5933. gsb_data_account_set_kind (account_number,
  5934. utils_str_atoi ( text));
  5935. return;
  5936. }
  5937. if ( !strcmp ( element_name,
  5938. "Devise" ))
  5939. {
  5940. gsb_data_account_set_currency ( account_number,
  5941. utils_str_atoi ( text));
  5942. return;
  5943. }
  5944. if ( !strcmp ( element_name,
  5945. "Banque" ))
  5946. {
  5947. gsb_data_account_set_bank ( account_number,
  5948. utils_str_atoi ( text));
  5949. return;
  5950. }
  5951. if ( !strcmp ( element_name,
  5952. "Guichet" ))
  5953. {
  5954. gsb_data_account_set_bank_branch_code ( account_number,
  5955. text);
  5956. return;
  5957. }
  5958. if ( !strcmp ( element_name,
  5959. "No_compte_banque" ))
  5960. {
  5961. gsb_data_account_set_bank_account_number ( account_number,
  5962. text);
  5963. return;
  5964. }
  5965. if ( !strcmp ( element_name,
  5966. "Cle_du_compte" ))
  5967. {
  5968. gsb_data_account_set_bank_account_key ( account_number,
  5969. text);
  5970. return;
  5971. }
  5972. if ( !strcmp ( element_name,
  5973. "Solde_initial" ))
  5974. {
  5975. /* to go to the 0.6.0 we need to change the amount string
  5976. * from 12.340000 to 12.34 before doing the conversion */
  5977. gchar *tmp_string;
  5978. gsb_real number;
  5979. tmp_string = utils_str_reduce_exponant_from_string ( text, 2 );
  5980. /* printf ("solde_initial = %s\n", tmp_string ); */
  5981. number = gsb_real_get_from_string ( tmp_string );
  5982. if ( number.mantissa == error_real.mantissa )
  5983. gsb_data_account_set_init_balance ( account_number, null_real );
  5984. else
  5985. gsb_data_account_set_init_balance ( account_number, number );
  5986. /* printf ("tmp_string = %s number.mantissa = %ld number.exponent = %d initial_balance = %s\n", tmp_string,
  5987. number.mantissa, number.exponent,
  5988. gsb_real_get_string ( gsb_data_account_get_init_balance ( account_number, 2))); */
  5989. if (tmp_string)
  5990. g_free (tmp_string);
  5991. return;
  5992. }
  5993. if ( !strcmp ( element_name,
  5994. "Solde_mini_voulu" ))
  5995. {
  5996. /* to go to the 0.6.0 we need to change the amount string
  5997. * from 12.340000 to 12.34 before doing the conversion */
  5998. gchar *tmp_string;
  5999. gsb_real number;
  6000. tmp_string = utils_str_reduce_exponant_from_string ( text, 2 );
  6001. number = gsb_real_get_from_string ( tmp_string );
  6002. if ( number.mantissa == error_real.mantissa )
  6003. gsb_data_account_set_mini_balance_wanted ( account_number, null_real );
  6004. else
  6005. gsb_data_account_set_mini_balance_wanted ( account_number, number );
  6006. if (tmp_string)
  6007. g_free (tmp_string);
  6008. return;
  6009. }
  6010. if ( !strcmp ( element_name,
  6011. "Solde_mini_autorise" ))
  6012. {
  6013. /* to go to the 0.6.0 we need to change the amount string
  6014. * from 12.340000 to 12.34 before doing the conversion */
  6015. gchar *tmp_string;
  6016. gsb_real number;
  6017. tmp_string = utils_str_reduce_exponant_from_string ( text, 2 );
  6018. number = gsb_real_get_from_string ( tmp_string );
  6019. if ( number.mantissa == error_real.mantissa )
  6020. gsb_data_account_set_mini_balance_authorized ( account_number, null_real );
  6021. else
  6022. gsb_data_account_set_mini_balance_authorized ( account_number, number );
  6023. if (tmp_string)
  6024. g_free (tmp_string);
  6025. return;
  6026. }
  6027. if ( !strcmp ( element_name,
  6028. "Date_dernier_releve" ))
  6029. {
  6030. /* as the date comes before the last number of reconcile, the fastest way is to use
  6031. * a buffer for ther reconcile structure, and when we have the last number of reconcile,
  6032. * we append the buffer to the list */
  6033. buffer_reconcile_conversion = g_malloc0 (sizeof (struct reconcile_conversion_struct));
  6034. if (buffer_reconcile_conversion)
  6035. {
  6036. gchar **pointeur_char;
  6037. pointeur_char = g_strsplit ( text, "/", 0 );
  6038. buffer_reconcile_conversion -> final_date = g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  6039. utils_str_atoi ( pointeur_char[1] ),
  6040. utils_str_atoi ( pointeur_char[2] ));
  6041. g_strfreev ( pointeur_char );
  6042. }
  6043. return;
  6044. }
  6045. if ( !strcmp ( element_name,
  6046. "Solde_dernier_releve" ))
  6047. {
  6048. /* to go to the 0.6.0 we need to change the amount string
  6049. * from 12.340000 to 12.34 before doing the conversion */
  6050. gchar *tmp_string;
  6051. tmp_string = utils_str_reduce_exponant_from_string ( text, 2 );
  6052. if (buffer_reconcile_conversion)
  6053. buffer_reconcile_conversion -> final_balance = gsb_real_get_from_string (tmp_string);
  6054. if (tmp_string)
  6055. g_free (tmp_string);
  6056. return;
  6057. }
  6058. if ( !strcmp ( element_name,
  6059. "Dernier_no_de_rapprochement" ))
  6060. {
  6061. if (buffer_reconcile_conversion)
  6062. {
  6063. buffer_reconcile_conversion -> reconcile_number = utils_str_atoi ( text);
  6064. buffer_reconcile_conversion -> account_number = account_number;
  6065. reconcile_conversion_list = g_slist_append ( reconcile_conversion_list,
  6066. buffer_reconcile_conversion );
  6067. buffer_reconcile_conversion = NULL;
  6068. }
  6069. return;
  6070. }
  6071. if ( !strcmp ( element_name,
  6072. "Compte_cloture" ))
  6073. {
  6074. gsb_data_account_set_closed_account ( account_number,
  6075. utils_str_atoi ( text));
  6076. return;
  6077. }
  6078. if ( !strcmp ( element_name,
  6079. "Affichage_r" ))
  6080. {
  6081. gsb_data_account_set_r ( account_number,
  6082. utils_str_atoi (text));
  6083. return;
  6084. }
  6085. if ( !strcmp ( element_name,
  6086. "Nb_lignes_ope" ))
  6087. {
  6088. gsb_data_account_set_nb_rows ( account_number,
  6089. utils_str_atoi (text));
  6090. return;
  6091. }
  6092. if ( !strcmp ( element_name,
  6093. "Commentaires" ))
  6094. {
  6095. gsb_data_account_set_comment ( account_number,
  6096. text);
  6097. return;
  6098. }
  6099. if ( !strcmp ( element_name,
  6100. "Adresse_du_titulaire" ))
  6101. {
  6102. gsb_data_account_set_holder_address ( account_number,
  6103. text);
  6104. return;
  6105. }
  6106. if ( !strcmp ( element_name,
  6107. "Type_defaut_debit" ))
  6108. {
  6109. gsb_data_account_set_default_debit ( account_number,
  6110. utils_str_atoi ( text) );
  6111. return;
  6112. }
  6113. if ( !strcmp ( element_name,
  6114. "Type_defaut_credit" ))
  6115. {
  6116. gsb_data_account_set_default_credit ( account_number,
  6117. utils_str_atoi ( text));
  6118. return;
  6119. }
  6120. if ( !strcmp ( element_name,
  6121. "Tri_par_type" ))
  6122. {
  6123. gsb_data_account_set_reconcile_sort_type ( account_number,
  6124. utils_str_atoi ( text));
  6125. return;
  6126. }
  6127. if ( !strcmp ( element_name,
  6128. "Neutres_inclus" ))
  6129. {
  6130. gsb_data_account_set_split_neutral_payment ( account_number,
  6131. utils_str_atoi ( text) );
  6132. return;
  6133. }
  6134. if ( !strcmp ( element_name,
  6135. "Ordre_du_tri" ))
  6136. {
  6137. if (text)
  6138. {
  6139. gchar **pointeur_char;
  6140. gint i;
  6141. pointeur_char = g_strsplit ( text,
  6142. "/",
  6143. 0 );
  6144. i = 0;
  6145. while ( pointeur_char[i] )
  6146. {
  6147. gsb_data_account_sort_list_add ( account_number,
  6148. utils_str_atoi ( pointeur_char[i] ));
  6149. i++;
  6150. }
  6151. g_strfreev ( pointeur_char );
  6152. }
  6153. return;
  6154. }
  6155. if ( !strcmp ( element_name,
  6156. "Classement_croissant" ))
  6157. {
  6158. gsb_data_account_set_sort_type ( account_number,
  6159. utils_str_atoi ( text));
  6160. return;
  6161. }
  6162. if ( !strcmp ( element_name,
  6163. "Classement_colonne" ))
  6164. {
  6165. gsb_data_account_set_sort_column ( account_number,
  6166. utils_str_atoi ( text));
  6167. return;
  6168. }
  6169. if ( !strcmp ( element_name,
  6170. "Classement_type_par_colonne" ))
  6171. {
  6172. gint i;
  6173. gchar **pointeur_char;
  6174. pointeur_char = g_strsplit ( text,
  6175. "-",
  6176. 0 );
  6177. for ( i=0 ; i<CUSTOM_MODEL_VISIBLE_COLUMNS ; i++ )
  6178. {
  6179. gsb_data_account_set_element_sort ( account_number,
  6180. i,
  6181. utils_str_atoi ( pointeur_char[i] ));
  6182. }
  6183. g_strfreev ( pointeur_char );
  6184. return;
  6185. }
  6186. /* récupération de l'agencement du transaction_form */
  6187. if ( !strcmp ( element_name,
  6188. "Nb_colonnes_formulaire" ))
  6189. {
  6190. if ( !gsb_data_account_get_form_organization (account_number) )
  6191. gsb_data_form_new_organization (account_number);
  6192. gsb_data_form_set_nb_columns ( account_number,
  6193. utils_str_atoi (text));
  6194. return;
  6195. }
  6196. if ( !strcmp ( element_name,
  6197. "Nb_lignes_formulaire" ))
  6198. {
  6199. if ( !gsb_data_account_get_form_organization (account_number) )
  6200. gsb_data_form_new_organization (account_number);
  6201. gsb_data_form_set_nb_rows ( account_number,
  6202. utils_str_atoi (text));
  6203. return;
  6204. }
  6205. if ( !strcmp ( element_name,
  6206. "Organisation_formulaire" ))
  6207. {
  6208. gchar **pointeur_char;
  6209. gint i, j;
  6210. if ( !gsb_data_account_get_form_organization (account_number) )
  6211. gsb_data_form_new_organization (account_number);
  6212. pointeur_char = g_strsplit ( text,
  6213. "-",
  6214. 0 );
  6215. for ( i=0 ; i<MAX_HEIGHT ; i++ )
  6216. for ( j=0 ; j<MAX_WIDTH ; j++ )
  6217. gsb_data_form_set_value ( account_number,
  6218. j, i,
  6219. utils_str_atoi (pointeur_char[j + i*MAX_WIDTH]));
  6220. g_strfreev ( pointeur_char );
  6221. return;
  6222. }
  6223. if ( !strcmp ( element_name,
  6224. "Largeur_col_formulaire" ))
  6225. {
  6226. gchar **pointeur_char;
  6227. gint i;
  6228. if ( !gsb_data_account_get_form_organization (account_number) )
  6229. gsb_data_form_new_organization (account_number);
  6230. pointeur_char = g_strsplit ( text,
  6231. "-",
  6232. 0 );
  6233. for ( i=0 ; i<MAX_WIDTH ; i++ )
  6234. gsb_data_form_set_width_column ( account_number,
  6235. i,
  6236. utils_str_atoi (pointeur_char[i]));
  6237. g_strfreev ( pointeur_char );
  6238. return;
  6239. }
  6240. }
  6241. void gsb_file_load_report_part_before_0_6 ( GMarkupParseContext *context,
  6242. const gchar *text )
  6243. {
  6244. const gchar *element_name;
  6245. element_name = g_markup_parse_context_get_element ( context );
  6246. /* check here if we are not between 2 subsections or if we
  6247. * needn't that section */
  6248. if ( !strcmp ( element_name,
  6249. "Etats" )
  6250. ||
  6251. !strcmp ( element_name,
  6252. "Generalites" )
  6253. ||
  6254. !strcmp ( element_name,
  6255. "No_dernier_etat" )
  6256. ||
  6257. !strcmp ( element_name,
  6258. "Detail_des_etats" )
  6259. ||
  6260. !strcmp ( element_name,
  6261. "Etat" ))
  6262. return;
  6263. if ( !strcmp ( element_name,
  6264. "No" ))
  6265. {
  6266. last_report_number = gsb_data_report_new_with_number (utils_str_atoi (text));
  6267. return;
  6268. }
  6269. if ( !strcmp ( element_name,
  6270. "Nom" ))
  6271. {
  6272. gsb_data_report_set_report_name ( last_report_number,
  6273. text);
  6274. return;
  6275. }
  6276. if ( !strcmp ( element_name,
  6277. "Type_classement" ))
  6278. {
  6279. gsb_data_report_set_sorting_type ( last_report_number,
  6280. gsb_string_get_int_list_from_string ( text,
  6281. "/" ));
  6282. return;
  6283. }
  6284. if ( !strcmp ( element_name,
  6285. "Aff_r" ))
  6286. {
  6287. gsb_data_report_set_show_r ( last_report_number,
  6288. utils_str_atoi (text));
  6289. return;
  6290. }
  6291. if ( !strcmp ( element_name,
  6292. "Aff_ope" ))
  6293. {
  6294. gsb_data_report_set_show_report_transactions ( last_report_number,
  6295. utils_str_atoi (text));
  6296. return;
  6297. }
  6298. if ( !strcmp ( element_name,
  6299. "Aff_nb_ope" ))
  6300. {
  6301. gsb_data_report_set_show_report_transaction_amount ( last_report_number,
  6302. utils_str_atoi (text));
  6303. return;
  6304. }
  6305. if ( !strcmp ( element_name,
  6306. "Aff_no_ope" ))
  6307. {
  6308. gsb_data_report_set_show_report_transaction_number ( last_report_number,
  6309. utils_str_atoi (text));
  6310. return;
  6311. }
  6312. if ( !strcmp ( element_name,
  6313. "Aff_date_ope" ))
  6314. {
  6315. gsb_data_report_set_show_report_date ( last_report_number,
  6316. utils_str_atoi (text));
  6317. return;
  6318. }
  6319. if ( !strcmp ( element_name,
  6320. "Aff_tiers_ope" ))
  6321. {
  6322. gsb_data_report_set_show_report_payee ( last_report_number,
  6323. utils_str_atoi (text));
  6324. return;
  6325. }
  6326. if ( !strcmp ( element_name,
  6327. "Aff_categ_ope" ))
  6328. {
  6329. gsb_data_report_set_show_report_category ( last_report_number,
  6330. utils_str_atoi (text));
  6331. return;
  6332. }
  6333. if ( !strcmp ( element_name,
  6334. "Aff_ss_categ_ope" ))
  6335. {
  6336. gsb_data_report_set_show_report_sub_category ( last_report_number,
  6337. utils_str_atoi (text));
  6338. return;
  6339. }
  6340. if ( !strcmp ( element_name,
  6341. "Aff_type_ope" ))
  6342. {
  6343. gsb_data_report_set_show_report_method_of_payment ( last_report_number,
  6344. utils_str_atoi (text));
  6345. return;
  6346. }
  6347. if ( !strcmp ( element_name,
  6348. "Aff_ib_ope" ))
  6349. {
  6350. gsb_data_report_set_show_report_budget ( last_report_number,
  6351. utils_str_atoi (text));
  6352. return;
  6353. }
  6354. if ( !strcmp ( element_name,
  6355. "Aff_ss_ib_ope" ))
  6356. {
  6357. gsb_data_report_set_show_report_sub_budget ( last_report_number,
  6358. utils_str_atoi (text));
  6359. return;
  6360. }
  6361. if ( !strcmp ( element_name,
  6362. "Aff_cheque_ope" ))
  6363. {
  6364. gsb_data_report_set_show_report_method_of_payment_content ( last_report_number,
  6365. utils_str_atoi (text));
  6366. return;
  6367. }
  6368. if ( !strcmp ( element_name,
  6369. "Aff_notes_ope" ))
  6370. {
  6371. gsb_data_report_set_show_report_note ( last_report_number,
  6372. utils_str_atoi (text));
  6373. return;
  6374. }
  6375. if ( !strcmp ( element_name,
  6376. "Aff_pc_ope" ))
  6377. {
  6378. gsb_data_report_set_show_report_voucher ( last_report_number,
  6379. utils_str_atoi (text));
  6380. return;
  6381. }
  6382. if ( !strcmp ( element_name,
  6383. "Aff_rappr_ope" ))
  6384. {
  6385. gsb_data_report_set_show_report_marked ( last_report_number,
  6386. utils_str_atoi (text));
  6387. return;
  6388. }
  6389. if ( !strcmp ( element_name,
  6390. "Aff_infobd_ope" ))
  6391. {
  6392. gsb_data_report_set_show_report_bank_references ( last_report_number,
  6393. utils_str_atoi (text));
  6394. return;
  6395. }
  6396. if ( !strcmp ( element_name,
  6397. "Aff_exo_ope" ))
  6398. {
  6399. gsb_data_report_set_show_report_financial_year ( last_report_number,
  6400. utils_str_atoi (text));
  6401. return;
  6402. }
  6403. if ( !strcmp ( element_name,
  6404. "Class_ope" ))
  6405. {
  6406. gsb_data_report_set_sorting_report ( last_report_number,
  6407. utils_str_atoi (text));
  6408. return;
  6409. }
  6410. if ( !strcmp ( element_name,
  6411. "Aff_titres_col" ))
  6412. {
  6413. gsb_data_report_set_column_title_show ( last_report_number,
  6414. utils_str_atoi (text));
  6415. return;
  6416. }
  6417. if ( !strcmp ( element_name,
  6418. "Aff_titres_chgt" ))
  6419. {
  6420. gsb_data_report_set_column_title_type ( last_report_number,
  6421. utils_str_atoi (text));
  6422. return;
  6423. }
  6424. if ( !strcmp ( element_name,
  6425. "Pas_detail_ventil" ))
  6426. {
  6427. gsb_data_report_set_not_detail_split ( last_report_number,
  6428. utils_str_atoi (text));
  6429. return;
  6430. }
  6431. if ( !strcmp ( element_name,
  6432. "Sep_rev_dep" ))
  6433. {
  6434. gsb_data_report_set_split_credit_debit ( last_report_number,
  6435. utils_str_atoi (text));
  6436. return;
  6437. }
  6438. if ( !strcmp ( element_name,
  6439. "Devise_gen" ))
  6440. {
  6441. gsb_data_report_set_currency_general ( last_report_number,
  6442. utils_str_atoi (text));
  6443. return;
  6444. }
  6445. if ( !strcmp ( element_name,
  6446. "Incl_tiers" ))
  6447. {
  6448. gsb_data_report_set_append_in_payee ( last_report_number,
  6449. utils_str_atoi (text));
  6450. return;
  6451. }
  6452. if ( !strcmp ( element_name,
  6453. "Ope_click" ))
  6454. {
  6455. gsb_data_report_set_report_can_click ( last_report_number,
  6456. utils_str_atoi (text));
  6457. return;
  6458. }
  6459. if ( !strcmp ( element_name,
  6460. "Exo_date" ))
  6461. {
  6462. gsb_data_report_set_use_financial_year ( last_report_number,
  6463. utils_str_atoi (text));
  6464. return;
  6465. }
  6466. if ( !strcmp ( element_name,
  6467. "Detail_exo" ))
  6468. {
  6469. gsb_data_report_set_financial_year_type ( last_report_number,
  6470. utils_str_atoi (text));
  6471. return;
  6472. }
  6473. if ( !strcmp ( element_name,
  6474. "No_exo" ))
  6475. {
  6476. gchar **pointeur_char;
  6477. gint i;
  6478. pointeur_char = g_strsplit ( text,
  6479. "/",
  6480. 0 );
  6481. i=0;
  6482. while ( pointeur_char[i] )
  6483. {
  6484. gsb_data_report_set_financial_year_list ( last_report_number,
  6485. g_slist_append ( gsb_data_report_get_financial_year_list (last_report_number),
  6486. GINT_TO_POINTER ( utils_str_atoi ( pointeur_char[i] ))));
  6487. i++;
  6488. }
  6489. g_strfreev ( pointeur_char );
  6490. return;
  6491. }
  6492. if ( !strcmp ( element_name,
  6493. "Plage_date" ))
  6494. {
  6495. gsb_data_report_set_date_type ( last_report_number,
  6496. utils_str_atoi (text));
  6497. return;
  6498. }
  6499. if ( !strcmp ( element_name,
  6500. "Date_debut" )
  6501. &&
  6502. strlen(element_name))
  6503. {
  6504. gchar **pointeur_char;
  6505. pointeur_char = g_strsplit ( text,
  6506. "/",
  6507. 0 );
  6508. gsb_data_report_set_personal_date_start ( last_report_number,
  6509. g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  6510. utils_str_atoi ( pointeur_char[1] ),
  6511. utils_str_atoi ( pointeur_char[2] )));
  6512. g_strfreev ( pointeur_char );
  6513. return;
  6514. }
  6515. if ( !strcmp ( element_name, "Date_fin" )
  6516. &&
  6517. strlen(element_name))
  6518. {
  6519. gchar **pointeur_char;
  6520. pointeur_char = g_strsplit ( text,
  6521. "/",
  6522. 0 );
  6523. gsb_data_report_set_personal_date_end ( last_report_number,
  6524. g_date_new_dmy ( utils_str_atoi ( pointeur_char[0] ),
  6525. utils_str_atoi ( pointeur_char[1] ),
  6526. utils_str_atoi ( pointeur_char[2] )));
  6527. g_strfreev ( pointeur_char );
  6528. return;
  6529. }
  6530. if ( !strcmp ( element_name,
  6531. "Utilise_plages" ))
  6532. {
  6533. gsb_data_report_set_period_split ( last_report_number,
  6534. utils_str_atoi (text));
  6535. return;
  6536. }
  6537. if ( !strcmp ( element_name,
  6538. "Sep_plages" ))
  6539. {
  6540. /* in 0.6 we add separation per day, so + 1 */
  6541. gsb_data_report_set_period_split_type ( last_report_number,
  6542. utils_str_atoi (text) + 1);
  6543. return;
  6544. }
  6545. if ( !strcmp ( element_name,
  6546. "Sep_exo" ))
  6547. {
  6548. gsb_data_report_set_financial_year_split ( last_report_number,
  6549. utils_str_atoi (text));
  6550. return;
  6551. }
  6552. if ( !strcmp ( element_name,
  6553. "Deb_sem_plages" ))
  6554. {
  6555. gsb_data_report_set_period_split_day ( last_report_number,
  6556. utils_str_atoi (text));
  6557. return;
  6558. }
  6559. if ( !strcmp ( element_name,
  6560. "Detail_comptes" ))
  6561. {
  6562. gsb_data_report_set_account_use_chosen ( last_report_number,
  6563. utils_str_atoi (text));
  6564. return;
  6565. }
  6566. if ( !strcmp ( element_name,
  6567. "No_comptes" ))
  6568. {
  6569. gchar **pointeur_char;
  6570. gint i;
  6571. pointeur_char = g_strsplit ( text,
  6572. "/",
  6573. 0 );
  6574. i=0;
  6575. while ( pointeur_char[i] )
  6576. {
  6577. gsb_data_report_set_account_numbers ( last_report_number,
  6578. g_slist_append ( gsb_data_report_get_account_numbers (last_report_number),
  6579. GINT_TO_POINTER ( utils_str_atoi ( pointeur_char[i] ))));
  6580. i++;
  6581. }
  6582. g_strfreev ( pointeur_char );
  6583. return;
  6584. }
  6585. if ( !strcmp ( element_name,
  6586. "Grp_ope_compte" ))
  6587. {
  6588. gsb_data_report_set_account_group_reports ( last_report_number,
  6589. utils_str_atoi (text));
  6590. return;
  6591. }
  6592. if ( !strcmp ( element_name,
  6593. "Total_compte" ))
  6594. {
  6595. gsb_data_report_set_account_show_amount ( last_report_number,
  6596. utils_str_atoi (text));
  6597. return;
  6598. }
  6599. if ( !strcmp ( element_name,
  6600. "Aff_nom_compte" ))
  6601. {
  6602. gsb_data_report_set_account_show_name ( last_report_number,
  6603. utils_str_atoi (text));
  6604. return;
  6605. }
  6606. if ( !strcmp ( element_name,
  6607. "Type_vir" ))
  6608. {
  6609. gsb_data_report_set_transfer_choice ( last_report_number,
  6610. utils_str_atoi (text));
  6611. return;
  6612. }
  6613. if ( !strcmp ( element_name,
  6614. "No_comptes_virements" ))
  6615. {
  6616. gchar **pointeur_char;
  6617. gint i;
  6618. pointeur_char = g_strsplit ( text,
  6619. "/",
  6620. 0 );
  6621. i=0;
  6622. while ( pointeur_char[i] )
  6623. {
  6624. gsb_data_report_set_transfer_account_numbers ( last_report_number,
  6625. g_slist_append ( gsb_data_report_get_transfer_account_numbers (last_report_number),
  6626. GINT_TO_POINTER ( utils_str_atoi ( pointeur_char[i] ))));
  6627. i++;
  6628. }
  6629. g_strfreev ( pointeur_char );
  6630. return;
  6631. }
  6632. if ( !strcmp ( element_name,
  6633. "Exclure_non_vir" ))
  6634. {
  6635. gsb_data_report_set_transfer_reports_only ( last_report_number,
  6636. utils_str_atoi (text));
  6637. return;
  6638. }
  6639. if ( !strcmp ( element_name,
  6640. "Categ" ))
  6641. {
  6642. gsb_data_report_set_category_used ( last_report_number,
  6643. utils_str_atoi (text));
  6644. return;
  6645. }
  6646. if ( !strcmp ( element_name,
  6647. "Detail_categ" ))
  6648. {
  6649. gsb_data_report_set_category_detail_used ( last_report_number,
  6650. utils_str_atoi (text));
  6651. return;
  6652. }
  6653. if ( !strcmp ( element_name,
  6654. "No_categ" ))
  6655. {
  6656. gchar **pointeur_char;
  6657. gint i;
  6658. GSList *tmp_list = NULL;
  6659. struct_categ_budget_sel *categ_struct;
  6660. /* before 0.6, it was only categories, so by default, we select all the sub-categories
  6661. * of the selected categories */
  6662. pointeur_char = g_strsplit ( text,
  6663. "/",
  6664. 0 );
  6665. i=0;
  6666. while ( pointeur_char[i] )
  6667. {
  6668. GSList *sub_categ_budget_list;
  6669. categ_struct = g_malloc0 (sizeof (struct_categ_budget_sel));
  6670. tmp_list = g_slist_append (tmp_list, categ_struct);
  6671. categ_struct -> div_number = utils_str_atoi ( pointeur_char[i] );
  6672. /* we append now all the sub-categories */
  6673. sub_categ_budget_list = gsb_data_category_get_sub_category_list (categ_struct -> div_number);
  6674. while (sub_categ_budget_list)
  6675. {
  6676. categ_struct -> sub_div_numbers = g_slist_append (categ_struct -> sub_div_numbers,
  6677. GINT_TO_POINTER (gsb_data_category_get_no_sub_category (sub_categ_budget_list -> data)));
  6678. sub_categ_budget_list = sub_categ_budget_list -> next;
  6679. }
  6680. /* we append a null sub-category */
  6681. categ_struct -> sub_div_numbers = g_slist_append (categ_struct -> sub_div_numbers,
  6682. NULL );
  6683. i++;
  6684. }
  6685. /* we append a null category with a null sub-category only if detail is not set*/
  6686. if (!gsb_data_report_get_category_detail_used (last_report_number))
  6687. {
  6688. categ_struct = g_malloc0 (sizeof (struct_categ_budget_sel));
  6689. tmp_list = g_slist_append (tmp_list, categ_struct);
  6690. categ_struct -> sub_div_numbers = g_slist_append (categ_struct -> sub_div_numbers,
  6691. NULL );
  6692. }
  6693. g_strfreev ( pointeur_char );
  6694. gsb_data_report_set_category_struct (last_report_number, tmp_list);
  6695. return;
  6696. }
  6697. if ( !strcmp ( element_name,
  6698. "Total_categ" ))
  6699. {
  6700. gsb_data_report_set_category_show_category_amount ( last_report_number,
  6701. utils_str_atoi (text));
  6702. return;
  6703. }
  6704. if ( !strcmp ( element_name,
  6705. "Aff_ss_categ" ))
  6706. {
  6707. gsb_data_report_set_category_show_sub_category ( last_report_number,
  6708. utils_str_atoi (text));
  6709. return;
  6710. }
  6711. if ( !strcmp ( element_name,
  6712. "Aff_pas_ss_categ" ))
  6713. {
  6714. gsb_data_report_set_category_show_without_category ( last_report_number,
  6715. utils_str_atoi (text));
  6716. return;
  6717. }
  6718. if ( !strcmp ( element_name,
  6719. "Total_ss_categ" ))
  6720. {
  6721. gsb_data_report_set_category_show_sub_category_amount ( last_report_number,
  6722. utils_str_atoi (text));
  6723. return;
  6724. }
  6725. if ( !strcmp ( element_name,
  6726. "Devise_categ" ))
  6727. {
  6728. gsb_data_report_set_category_currency ( last_report_number,
  6729. utils_str_atoi (text));
  6730. return;
  6731. }
  6732. if ( !strcmp ( element_name,
  6733. "Aff_nom_categ" ))
  6734. {
  6735. gsb_data_report_set_category_show_name ( last_report_number,
  6736. utils_str_atoi (text));
  6737. return;
  6738. }
  6739. if ( !strcmp ( element_name,
  6740. "IB" ))
  6741. {
  6742. gsb_data_report_set_budget_used ( last_report_number,
  6743. utils_str_atoi (text));
  6744. return;
  6745. }
  6746. if ( !strcmp ( element_name,
  6747. "Detail_ib" ))
  6748. {
  6749. gsb_data_report_set_budget_detail_used ( last_report_number,
  6750. utils_str_atoi (text));
  6751. return;
  6752. }
  6753. if ( !strcmp ( element_name,
  6754. "No_ib" ))
  6755. {
  6756. gchar **pointeur_char;
  6757. gint i;
  6758. GSList *tmp_list = NULL;
  6759. struct_categ_budget_sel *budget_struct;
  6760. /* before 0.6, it was only budgets, so by default, we select all the sub-budgets
  6761. * of the selected budgets */
  6762. pointeur_char = g_strsplit ( text,
  6763. "/",
  6764. 0 );
  6765. i=0;
  6766. while ( pointeur_char[i] )
  6767. {
  6768. GSList *sub_budget_list;
  6769. budget_struct = g_malloc0 (sizeof (struct_categ_budget_sel));
  6770. tmp_list = g_slist_append (tmp_list, budget_struct);
  6771. budget_struct -> div_number = utils_str_atoi ( pointeur_char[i] );
  6772. /* we append now all the sub-categories */
  6773. sub_budget_list = gsb_data_budget_get_sub_budget_list (budget_struct -> div_number);
  6774. while (sub_budget_list)
  6775. {
  6776. budget_struct -> sub_div_numbers = g_slist_append (budget_struct -> sub_div_numbers,
  6777. GINT_TO_POINTER (gsb_data_budget_get_no_sub_budget (sub_budget_list -> data)));
  6778. sub_budget_list = sub_budget_list -> next;
  6779. }
  6780. /* we append a null sub-category */
  6781. budget_struct -> sub_div_numbers = g_slist_append (budget_struct -> sub_div_numbers,
  6782. NULL );
  6783. i++;
  6784. }
  6785. /* we append a null budget with a null sub-budget only if detail is not set*/
  6786. if (!gsb_data_report_get_budget_detail_used (last_report_number))
  6787. {
  6788. budget_struct = g_malloc0 (sizeof (struct_categ_budget_sel));
  6789. tmp_list = g_slist_append (tmp_list, budget_struct);
  6790. budget_struct -> sub_div_numbers = g_slist_append (budget_struct -> sub_div_numbers,
  6791. NULL );
  6792. }
  6793. g_strfreev ( pointeur_char );
  6794. gsb_data_report_set_budget_struct (last_report_number, tmp_list);
  6795. return;
  6796. }
  6797. if ( !strcmp ( element_name,
  6798. "Total_ib" ))
  6799. {
  6800. gsb_data_report_set_budget_show_budget_amount ( last_report_number,
  6801. utils_str_atoi (text));
  6802. return;
  6803. }
  6804. if ( !strcmp ( element_name,
  6805. "Aff_ss_ib" ))
  6806. {
  6807. gsb_data_report_set_budget_show_sub_budget ( last_report_number,
  6808. utils_str_atoi (text));
  6809. return;
  6810. }
  6811. if ( !strcmp ( element_name,
  6812. "Aff_pas_ss_ib" ))
  6813. {
  6814. gsb_data_report_set_budget_show_without_budget ( last_report_number,
  6815. utils_str_atoi (text));
  6816. return;
  6817. }
  6818. if ( !strcmp ( element_name,
  6819. "Total_ss_ib" ))
  6820. {
  6821. gsb_data_report_set_budget_show_sub_budget_amount ( last_report_number,
  6822. utils_str_atoi (text));
  6823. return;
  6824. }
  6825. if ( !strcmp ( element_name,
  6826. "Devise_ib" ))
  6827. {
  6828. gsb_data_report_set_budget_currency ( last_report_number,
  6829. utils_str_atoi (text));
  6830. return;
  6831. }
  6832. if ( !strcmp ( element_name,
  6833. "Aff_nom_ib" ))
  6834. {
  6835. gsb_data_report_set_budget_show_name ( last_report_number,
  6836. utils_str_atoi (text));
  6837. return;
  6838. }
  6839. if ( !strcmp ( element_name,
  6840. "Tiers" ))
  6841. {
  6842. gsb_data_report_set_payee_used ( last_report_number,
  6843. utils_str_atoi (text));
  6844. return;
  6845. }
  6846. if ( !strcmp ( element_name,
  6847. "Detail_tiers" ))
  6848. {
  6849. gsb_data_report_set_payee_detail_used ( last_report_number,
  6850. utils_str_atoi (text));
  6851. return;
  6852. }
  6853. if ( !strcmp ( element_name,
  6854. "No_tiers" ))
  6855. {
  6856. gchar **pointeur_char;
  6857. gint i;
  6858. pointeur_char = g_strsplit ( text,
  6859. "/",
  6860. 0 );
  6861. i=0;
  6862. while ( pointeur_char[i] )
  6863. {
  6864. gsb_data_report_set_payee_numbers ( last_report_number,
  6865. g_slist_append ( gsb_data_report_get_payee_numbers (last_report_number),
  6866. GINT_TO_POINTER ( utils_str_atoi ( pointeur_char[i] ))));
  6867. i++;
  6868. }
  6869. g_strfreev ( pointeur_char );
  6870. return;
  6871. }
  6872. if ( !strcmp ( element_name,
  6873. "Total_tiers" ))
  6874. {
  6875. gsb_data_report_set_payee_show_payee_amount ( last_report_number,
  6876. utils_str_atoi (text));
  6877. return;
  6878. }
  6879. if ( !strcmp ( element_name,
  6880. "Devise_tiers" ))
  6881. {
  6882. gsb_data_report_set_payee_currency ( last_report_number,
  6883. utils_str_atoi (text));
  6884. return;
  6885. }
  6886. if ( !strcmp ( element_name,
  6887. "Aff_nom_tiers" ))
  6888. {
  6889. gsb_data_report_set_payee_show_name ( last_report_number,
  6890. utils_str_atoi (text));
  6891. return;
  6892. }
  6893. if ( !strcmp ( element_name,
  6894. "Texte" ))
  6895. {
  6896. gsb_data_report_set_text_comparison_used ( last_report_number,
  6897. utils_str_atoi (text));
  6898. return;
  6899. }
  6900. if ( !strcmp ( element_name,
  6901. "Montant" ))
  6902. {
  6903. gsb_data_report_set_amount_comparison_used ( last_report_number,
  6904. utils_str_atoi (text));
  6905. return;
  6906. }
  6907. if ( !strcmp ( element_name,
  6908. "Montant_devise" ))
  6909. {
  6910. gsb_data_report_set_amount_comparison_currency ( last_report_number,
  6911. utils_str_atoi (text));
  6912. return;
  6913. }
  6914. if ( !strcmp ( element_name,
  6915. "Excl_nul" ))
  6916. {
  6917. gsb_data_report_set_amount_comparison_only_report_non_null ( last_report_number,
  6918. utils_str_atoi (text));
  6919. return;
  6920. }
  6921. if ( !strcmp ( element_name,
  6922. "Detail_mod_paie" ))
  6923. {
  6924. gsb_data_report_set_method_of_payment_used ( last_report_number,
  6925. utils_str_atoi (text));
  6926. return;
  6927. }
  6928. }
  6929. /**
  6930. * called after downloading a file, check the version and do the changes if
  6931. * necessary
  6932. *
  6933. * \param
  6934. *
  6935. * \return
  6936. * */
  6937. gboolean gsb_file_load_update_previous_version ( void )
  6938. {
  6939. gchar* tmpstr;
  6940. gint currency_number;
  6941. GSList *list_tmp;
  6942. gint i;
  6943. GSList *list_tmp_account;
  6944. GSList *list_tmp_transactions;
  6945. GSList *list_tmp_scheduled;
  6946. gint version_number;
  6947. gint account_number;
  6948. GList *dlist_tmp;
  6949. gchar** strarray;
  6950. strarray = g_strsplit ( download_tmp_values.file_version, ".", 0 );
  6951. tmpstr = g_strjoinv ( "", strarray );
  6952. version_number = utils_str_atoi ( tmpstr );
  6953. g_strfreev ( strarray );
  6954. g_free ( tmpstr );
  6955. /* for now the file is not modified */
  6956. modification_fichier ( FALSE );
  6957. switch ( version_number )
  6958. {
  6959. /* ************************************* */
  6960. /* ouverture d'un fichier 0.4.0 */
  6961. /* ************************************* */
  6962. case 40:
  6963. /* il n'y a aucune différence de struct entre la 0.4.0 et la 0.4.1 */
  6964. /* sauf que la 0.4.0 n'attribuait pas le no de relevé aux opés filles */
  6965. /* d'une ventilation */
  6966. list_tmp_transactions = gsb_data_transaction_get_complete_transactions_list ();
  6967. while ( list_tmp_transactions )
  6968. {
  6969. gint transaction_number_tmp;
  6970. transaction_number_tmp = gsb_data_transaction_get_transaction_number (
  6971. list_tmp_transactions -> data);
  6972. /* si l'opération est une ventil, on refait le tour de la liste pour trouver ses filles */
  6973. if ( gsb_data_transaction_get_split_of_transaction (transaction_number_tmp))
  6974. {
  6975. GSList *list_tmp_transactions_2;
  6976. list_tmp_transactions_2 = gsb_data_transaction_get_complete_transactions_list ();
  6977. while ( list_tmp_transactions_2 )
  6978. {
  6979. gint transaction_number_tmp_2;
  6980. transaction_number_tmp_2 = gsb_data_transaction_get_transaction_number (
  6981. list_tmp_transactions_2 -> data) ;
  6982. if ( gsb_data_transaction_get_account_number (transaction_number_tmp_2) ==
  6983. gsb_data_transaction_get_account_number (transaction_number_tmp)
  6984. &&
  6985. gsb_data_transaction_get_mother_transaction_number (transaction_number_tmp_2) ==
  6986. transaction_number_tmp)
  6987. gsb_data_transaction_set_reconcile_number ( transaction_number_tmp_2,
  6988. gsb_data_transaction_get_reconcile_number (transaction_number_tmp));
  6989. list_tmp_transactions_2 = list_tmp_transactions_2 -> next;
  6990. }
  6991. }
  6992. list_tmp_transactions = list_tmp_transactions -> next;
  6993. }
  6994. /* ************************************* */
  6995. /* ouverture d'un fichier 0.4.1 */
  6996. /* ************************************* */
  6997. case 41:
  6998. /* ajout de la 0.5 -> valeur_echelle_recherche_date_import qu'on me ŕ 2 */
  6999. valeur_echelle_recherche_date_import = 2;
  7000. /* passage ŕ l'utf8 : on fait le tour des devises pour retrouver l'euro */
  7001. /* Handle Euro nicely */
  7002. currency_number = gsb_data_currency_get_number_by_name ("Euro");
  7003. if (currency_number)
  7004. {
  7005. gsb_data_currency_set_code ( currency_number,
  7006. "€" );
  7007. gsb_data_currency_set_code_iso4217 ( currency_number,
  7008. "EUR" );
  7009. }
  7010. /* ************************************* */
  7011. /* ouverture d'un fichier 0.5.0 */
  7012. /* ************************************* */
  7013. case 50:
  7014. /* ************************************* */
  7015. /* ouverture d'un fichier 0.5.1 */
  7016. /* ************************************* */
  7017. case 51:
  7018. /* ************************************* */
  7019. /* ouverture d'un fichier 0.5.5 */
  7020. /* ************************************* */
  7021. case 55:
  7022. /* ************************************* */
  7023. /* ouverture d'un fichier 0.5.6 */
  7024. /* ************************************* */
  7025. case 56:
  7026. /* ************************************* */
  7027. /* ouverture d'un fichier 0.5.7 */
  7028. /* ************************************* */
  7029. case 57:
  7030. /* ************************************* */
  7031. /* ouverture d'un fichier 0.5.8 */
  7032. /* ************************************* */
  7033. case 58:
  7034. case 59:
  7035. /* all the change between the 0.5.0 and 0.6.0 are set here because a confuse between
  7036. * the number of version and the number of file structure */
  7037. /* pour l'instant le fichier 0.5.1 ne diffčre pas de la version 0.5.0 */
  7038. /* excepté un changement dans la notation du pointage */
  7039. /* rien=0 ; P=1 ; T=2 ; R=3 */
  7040. /* on fait donc le tour des opés pour inverser R et P */
  7041. switch_t_r ();
  7042. /* un bug dans la 0.5.0 permettait ŕ des comptes d'avoir un affichage différent, */
  7043. /* męme si celui ci devait ętre identique pour tous, on vérifie ici */
  7044. if ( !etat.retient_affichage_par_compte )
  7045. {
  7046. gint affichage_r;
  7047. gint nb_lignes_ope;
  7048. GSList *list_tmp;
  7049. affichage_r = 0;
  7050. nb_lignes_ope = 3;
  7051. list_tmp = gsb_data_account_get_list_accounts ();
  7052. while ( list_tmp )
  7053. {
  7054. i = gsb_data_account_get_no_account ( list_tmp -> data );
  7055. gsb_data_account_set_r ( i, affichage_r );
  7056. gsb_data_account_set_nb_rows ( i, nb_lignes_ope );
  7057. list_tmp = list_tmp -> next;
  7058. }
  7059. }
  7060. /* to go from 0.5.x to 0.6.x, there is a change in the method of payment :
  7061. * before, they were saved in each account, and have for each accounts numbers 1, 2, 3...
  7062. * now, they are saved in a general list and we must adapt the numbers to avoid several method of payments
  7063. * with the same number
  7064. * the change is done while downloading the file, all we need to do now is to change
  7065. * the payment number of all the transactions and scheduled transactions to set the new number */
  7066. list_tmp_transactions = gsb_data_transaction_get_complete_transactions_list ();
  7067. while ( list_tmp_transactions )
  7068. {
  7069. gint transaction_number;
  7070. transaction_number = gsb_data_transaction_get_transaction_number (
  7071. list_tmp_transactions -> data);
  7072. gsb_data_transaction_set_method_of_payment_number ( transaction_number,
  7073. gsb_file_load_get_new_payment_number (
  7074. gsb_data_transaction_get_account_number (transaction_number),
  7075. gsb_data_transaction_get_method_of_payment_number (transaction_number)) );
  7076. list_tmp_transactions = list_tmp_transactions -> next;
  7077. }
  7078. /* do the same for scheduled transactions */
  7079. list_tmp_scheduled = gsb_data_scheduled_get_scheduled_list ();
  7080. while (list_tmp_scheduled)
  7081. {
  7082. gint scheduled_number;
  7083. scheduled_number = gsb_data_scheduled_get_scheduled_number (list_tmp_scheduled -> data);
  7084. gsb_data_scheduled_set_method_of_payment_number ( scheduled_number,
  7085. gsb_file_load_get_new_payment_number (
  7086. gsb_data_scheduled_get_account_number (scheduled_number),
  7087. gsb_data_scheduled_get_method_of_payment_number (scheduled_number)) );
  7088. list_tmp_scheduled = list_tmp_scheduled -> next;
  7089. }
  7090. /* do the same for the sort list of accounts and default payment */
  7091. list_tmp = gsb_data_account_get_list_accounts ();
  7092. while ( list_tmp )
  7093. {
  7094. GSList *sorted_list;
  7095. GSList *new_sorted_list = NULL;
  7096. account_number = gsb_data_account_get_no_account ( list_tmp -> data );
  7097. gsb_data_account_set_default_debit ( account_number,
  7098. gsb_file_load_get_new_payment_number ( account_number,
  7099. gsb_data_account_get_default_debit (account_number)));
  7100. gsb_data_account_set_default_credit ( account_number,
  7101. gsb_file_load_get_new_payment_number ( account_number,
  7102. gsb_data_account_get_default_credit (account_number)) );
  7103. sorted_list = gsb_data_account_get_sort_list (account_number);
  7104. while (sorted_list)
  7105. {
  7106. gint new_number;
  7107. new_number = gsb_file_load_get_new_payment_number ( account_number,
  7108. GPOINTER_TO_INT (sorted_list -> data));
  7109. if (new_number)
  7110. new_sorted_list = g_slist_append ( new_sorted_list,
  7111. GINT_TO_POINTER (new_number));
  7112. sorted_list = sorted_list -> next;
  7113. }
  7114. gsb_data_account_sort_list_free (account_number);
  7115. gsb_data_account_set_sort_list (account_number, new_sorted_list);
  7116. list_tmp = list_tmp -> next;
  7117. }
  7118. /* a problem untill the 0.5.7 :
  7119. * all new method of payment are not added to the sorting list for reconciliation,
  7120. * so check all the method of payment, and if 1 is not in the sorted list for its account */
  7121. list_tmp = gsb_data_payment_get_payments_list ();
  7122. while (list_tmp)
  7123. {
  7124. gint payment_number;
  7125. GSList *sorted_list;
  7126. gint account_number;
  7127. payment_number = gsb_data_payment_get_number (list_tmp -> data);
  7128. account_number = gsb_data_payment_get_account_number (payment_number);
  7129. sorted_list = gsb_data_account_get_sort_list (account_number);
  7130. if ( !g_slist_find ( sorted_list,
  7131. GINT_TO_POINTER (payment_number)))
  7132. gsb_data_account_sort_list_add ( account_number,
  7133. payment_number );
  7134. list_tmp = list_tmp -> next;
  7135. }
  7136. /* a problem untill the 0.5.7, the children of a scheduled split are marked
  7137. * as a split mother */
  7138. list_tmp_scheduled = gsb_data_scheduled_get_scheduled_list ();
  7139. while (list_tmp_scheduled)
  7140. {
  7141. gint scheduled_number;
  7142. scheduled_number = gsb_data_scheduled_get_scheduled_number (list_tmp_scheduled -> data);
  7143. if ( gsb_data_scheduled_get_mother_scheduled_number (scheduled_number))
  7144. gsb_data_scheduled_set_split_of_scheduled ( scheduled_number,
  7145. 0 );
  7146. list_tmp_scheduled = list_tmp_scheduled -> next;
  7147. }
  7148. /* there is a bug untill now, which is some children of split
  7149. * are not marked R, and the mother is...
  7150. * very annoying now, we MUST mark them as R, so check here... */
  7151. /* we use that to correct another bug, sometimes, the mother of split
  7152. * has a financial year an budget... bad things because makes errors in reports,
  7153. * so change that here */
  7154. /* another fix, some children of split have not the same values of the mother
  7155. * for some fields wich should be ; fix here */
  7156. list_tmp_transactions = gsb_data_transaction_get_complete_transactions_list ();
  7157. while ( list_tmp_transactions )
  7158. {
  7159. gint transaction_number;
  7160. gint mother_number;
  7161. transaction_number = gsb_data_transaction_get_transaction_number (list_tmp_transactions -> data);
  7162. /* if it's a split and marked R, we look for the children */
  7163. if ( gsb_data_transaction_get_split_of_transaction (transaction_number))
  7164. {
  7165. /* change the problem of marked transactions */
  7166. if (gsb_data_transaction_get_marked_transaction (transaction_number) == OPERATION_RAPPROCHEE)
  7167. {
  7168. GSList *list_tmp_transactions_2;
  7169. list_tmp_transactions_2 = gsb_data_transaction_get_complete_transactions_list ();
  7170. while ( list_tmp_transactions_2 )
  7171. {
  7172. gint transaction_number_2;
  7173. transaction_number_2 = gsb_data_transaction_get_transaction_number (list_tmp_transactions_2 -> data);
  7174. if ( gsb_data_transaction_get_mother_transaction_number (transaction_number_2) == transaction_number)
  7175. gsb_data_transaction_set_marked_transaction ( transaction_number_2,
  7176. OPERATION_RAPPROCHEE );
  7177. list_tmp_transactions_2 = list_tmp_transactions_2 -> next;
  7178. }
  7179. }
  7180. /* erase what shouldn't be set */
  7181. gsb_data_transaction_set_budgetary_number (transaction_number, 0);
  7182. gsb_data_transaction_set_sub_budgetary_number (transaction_number, 0);
  7183. gsb_data_transaction_set_financial_year_number (transaction_number, 0);
  7184. gsb_data_transaction_set_voucher (transaction_number, NULL);
  7185. }
  7186. /* if t's a child, fix the values to be the same as for mother */
  7187. mother_number = gsb_data_transaction_get_mother_transaction_number ( transaction_number );
  7188. if (mother_number)
  7189. {
  7190. /* set the value date */
  7191. gsb_data_transaction_set_value_date ( transaction_number,
  7192. gsb_date_copy (gsb_data_transaction_get_value_date (mother_number)));
  7193. /* set the party */
  7194. gsb_data_transaction_set_party_number ( transaction_number,
  7195. gsb_data_transaction_get_party_number (mother_number));
  7196. /* set the currency */
  7197. gsb_data_transaction_set_currency_number ( transaction_number,
  7198. gsb_data_transaction_get_currency_number (mother_number));
  7199. /* set the type */
  7200. gsb_data_transaction_set_method_of_payment_number ( transaction_number,
  7201. gsb_data_transaction_get_method_of_payment_number (mother_number));
  7202. /* set the type content */
  7203. gsb_data_transaction_set_method_of_payment_content ( transaction_number,
  7204. gsb_data_transaction_get_method_of_payment_content (mother_number));
  7205. /* set the bank */
  7206. gsb_data_transaction_set_bank_references ( transaction_number,
  7207. gsb_data_transaction_get_bank_references (mother_number));
  7208. }
  7209. list_tmp_transactions = list_tmp_transactions -> next;
  7210. }
  7211. /* change to the 0.6.0 : the number of choice of periodicity
  7212. * now 7 choice => in scheduler_periodicity, we have to change
  7213. * the last choices to the new numbers */
  7214. list_tmp_scheduled = gsb_data_scheduled_get_scheduled_list ();
  7215. while (list_tmp_scheduled)
  7216. {
  7217. gint scheduled_number;
  7218. scheduled_number = gsb_data_scheduled_get_scheduled_number (list_tmp_scheduled -> data);
  7219. switch ( gsb_data_scheduled_get_frequency (scheduled_number))
  7220. {
  7221. case 0:
  7222. case 1:
  7223. case 2:
  7224. /* for once, weekly and months, no change */
  7225. break;
  7226. case 3:
  7227. /* year frequency */
  7228. gsb_data_scheduled_set_frequency ( scheduled_number,
  7229. SCHEDULER_PERIODICITY_YEAR_VIEW );
  7230. break;
  7231. /* there is a bug and the periodicity can be more than 4...
  7232. * so set the default here to set it to SCHEDULER_PERIODICITY_CUSTOM_VIEW */
  7233. case 4:
  7234. default:
  7235. /* custom frequency */
  7236. gsb_data_scheduled_set_frequency ( scheduled_number,
  7237. SCHEDULER_PERIODICITY_CUSTOM_VIEW );
  7238. break;
  7239. }
  7240. switch ( gsb_data_scheduled_get_user_interval ( scheduled_number ))
  7241. {
  7242. case 0:
  7243. /* no change for day */
  7244. break;
  7245. case 1:
  7246. /* for months */
  7247. gsb_data_scheduled_set_user_interval ( scheduled_number,
  7248. PERIODICITY_MONTHS );
  7249. break;
  7250. case 2:
  7251. /* for years */
  7252. gsb_data_scheduled_set_user_interval ( scheduled_number,
  7253. PERIODICITY_YEARS );
  7254. break;
  7255. }
  7256. list_tmp_scheduled = list_tmp_scheduled -> next;
  7257. }
  7258. /* new to the 0.6.0 : append the currency_floating_point to the currencies
  7259. * now all the amount are gint and no float, and currency_floating_point will
  7260. * determine where is the point in the float
  7261. * by defaut (in the last releases), the value was automatickly 2 */
  7262. list_tmp = gsb_data_currency_get_currency_list ();
  7263. while ( list_tmp )
  7264. {
  7265. i = gsb_data_currency_get_no_currency ( list_tmp -> data );
  7266. gsb_data_currency_set_floating_point ( i,
  7267. 2 );
  7268. list_tmp = list_tmp -> next;
  7269. }
  7270. /* there is a bug from i don't know when, sometimes when removing some splitted
  7271. * transactions, the children were not removed, so we check all the children to make
  7272. * sure the mother is a splitted transaction, else we erase it */
  7273. list_tmp = gsb_data_transaction_get_complete_transactions_list ();
  7274. while (list_tmp)
  7275. {
  7276. gint mother_transaction;
  7277. gint transaction_number = gsb_data_transaction_get_transaction_number (list_tmp -> data);
  7278. list_tmp = list_tmp -> next;
  7279. mother_transaction = gsb_data_transaction_get_mother_transaction_number (transaction_number);
  7280. if (mother_transaction
  7281. &&
  7282. !gsb_data_transaction_get_split_of_transaction (mother_transaction))
  7283. {
  7284. /* the mother is not a splitted transaction */
  7285. /* if it was a transfer, remove the contra transaction */
  7286. if (gsb_data_transaction_get_contra_transaction_number (transaction_number) > 0)
  7287. gsb_data_transaction_remove_transaction_without_check (gsb_data_transaction_get_contra_transaction_number (transaction_number));
  7288. /*we erase the child */
  7289. gsb_data_transaction_remove_transaction_without_check (transaction_number);
  7290. }
  7291. }
  7292. /* we shall do so for the planned operations */
  7293. list_tmp = gsb_data_scheduled_get_scheduled_list ();
  7294. tmpstr = NULL;
  7295. while ( list_tmp )
  7296. {
  7297. gint scheduled_number;
  7298. gint mother_scheduled_number;
  7299. scheduled_number = gsb_data_scheduled_get_scheduled_number (list_tmp -> data);
  7300. list_tmp = list_tmp -> next;
  7301. mother_scheduled_number = gsb_data_scheduled_get_mother_scheduled_number (
  7302. scheduled_number );
  7303. if ( mother_scheduled_number )
  7304. {
  7305. if ( gsb_data_scheduled_get_automatic_scheduled (
  7306. mother_scheduled_number ) == -1 )
  7307. {
  7308. /* it's a child but didn't find the mother, it can happen in old files
  7309. * previous to 0.6 where the children wer saved before the mother */
  7310. /*we erase the child */
  7311. gsb_data_scheduled_remove_scheduled ( scheduled_number );
  7312. if ( tmpstr == NULL )
  7313. tmpstr = utils_str_itoa ( scheduled_number );
  7314. else
  7315. tmpstr = g_strconcat ( tmpstr, " - ",
  7316. utils_str_itoa ( scheduled_number ), NULL );
  7317. }
  7318. }
  7319. }
  7320. if ( tmpstr != NULL )
  7321. g_printf ( "the scheduled transactions have been deleted :\n%s\n",
  7322. tmpstr );
  7323. /* a bug before 0.6 (and perhaps after ? still not found for now) set
  7324. * a negative number for certain banks, so change that here */
  7325. list_tmp = gsb_data_bank_get_bank_list ();
  7326. while ( list_tmp )
  7327. {
  7328. i = gsb_data_bank_get_no_bank ( list_tmp -> data );
  7329. if ( i<0 )
  7330. {
  7331. gint new_number;
  7332. GSList *account_list;
  7333. new_number = gsb_data_bank_set_new_number ( i, gsb_data_bank_max_number () + 1);
  7334. /* only accounts are associated with bank number */
  7335. account_list = gsb_data_account_get_list_accounts ();
  7336. while (account_list)
  7337. {
  7338. gint account_number;
  7339. account_number = gsb_data_account_get_no_account (account_list -> data);
  7340. if (gsb_data_account_get_bank (account_number) == i)
  7341. gsb_data_account_set_bank ( account_number, new_number );
  7342. account_list = account_list -> next;
  7343. }
  7344. }
  7345. list_tmp = list_tmp -> next;
  7346. }
  7347. /* new to 0.6.0 : struct of reconcile has changed,
  7348. * it contains now an account number, init and final dates and
  7349. * init and final balances
  7350. * and now there is no more information on reconcile in the account
  7351. * so here we try to fill that fields, and especially set the last
  7352. * final date and last final balance in the last reconciles
  7353. * hopefully, we can do that because each reconciled transaction has
  7354. * its number of reconcile */
  7355. /* first step, fill the account numbers and try to fill the init
  7356. * and final dates */
  7357. list_tmp_transactions = gsb_data_transaction_get_complete_transactions_list ();
  7358. while ( list_tmp_transactions )
  7359. {
  7360. gint transaction_number;
  7361. gint reconcile_number;
  7362. transaction_number = gsb_data_transaction_get_transaction_number (
  7363. list_tmp_transactions -> data);
  7364. /* ok first we work only with reconciled transactions */
  7365. if ( gsb_data_transaction_get_marked_transaction (
  7366. transaction_number) == OPERATION_RAPPROCHEE )
  7367. {
  7368. gint account_number;
  7369. gint reconcile_account;
  7370. const GDate *date_reconcile;
  7371. const GDate *date_transaction;
  7372. gboolean trouve = FALSE;
  7373. account_number = gsb_data_transaction_get_account_number (
  7374. transaction_number );
  7375. reconcile_number = gsb_data_transaction_get_reconcile_number (
  7376. transaction_number);
  7377. if ( reconcile_number == 0 )
  7378. {
  7379. if ( ( reconcile_number = gsb_data_reconcile_get_account_last_number (
  7380. account_number ) ) == 0 )
  7381. {
  7382. reconcile_number = gsb_data_reconcile_new (NULL);
  7383. gsb_data_reconcile_set_account ( reconcile_number, -1 );
  7384. gsb_data_reconcile_set_name ( reconcile_number,
  7385. gsb_data_account_get_name ( account_number ) );
  7386. gsb_data_reconcile_set_init_balance ( reconcile_number,
  7387. null_real );
  7388. gsb_data_reconcile_set_final_balance ( reconcile_number,
  7389. null_real );
  7390. }
  7391. }
  7392. reconcile_account = gsb_data_reconcile_get_account ( reconcile_number );
  7393. /* ok, we set the account number (faster to not check and directly
  7394. * write it... even if already done) */
  7395. /* on regarde quel est le numéro de compte associé au rapprochement.
  7396. * s'il est égal ŕ -1 on met directement le numéro de compte de l'opération
  7397. * sinon on crée un nouveau rapprochement pour ce compte. */
  7398. if ( reconcile_account == -1 )
  7399. {
  7400. gsb_data_reconcile_set_account ( reconcile_number, account_number );
  7401. buffer_old_new_rec_conversion = g_malloc0 (sizeof (
  7402. struct old_new_rec_conversion_struct));
  7403. buffer_old_new_rec_conversion -> account_number = account_number;
  7404. buffer_old_new_rec_conversion -> old_rec_number = reconcile_number;
  7405. buffer_old_new_rec_conversion -> new_rec_number = reconcile_number;
  7406. old_new_rec_list = g_slist_append ( old_new_rec_list,
  7407. buffer_old_new_rec_conversion );
  7408. }
  7409. else
  7410. {
  7411. struct old_new_rec_conversion_struct *old_new_rec_struct;
  7412. list_tmp = old_new_rec_list;
  7413. while (list_tmp)
  7414. {
  7415. old_new_rec_struct = list_tmp -> data;
  7416. if ( old_new_rec_struct -> account_number == account_number &&
  7417. old_new_rec_struct -> old_rec_number == reconcile_number )
  7418. {
  7419. trouve = TRUE;
  7420. reconcile_number = old_new_rec_struct -> new_rec_number;
  7421. break;
  7422. }
  7423. list_tmp = list_tmp -> next;
  7424. }
  7425. if ( trouve == FALSE )
  7426. {
  7427. buffer_old_new_rec_conversion = g_malloc0 (sizeof (
  7428. struct old_new_rec_conversion_struct));
  7429. buffer_old_new_rec_conversion -> account_number = account_number;
  7430. buffer_old_new_rec_conversion -> old_rec_number = reconcile_number;
  7431. reconcile_number = gsb_data_reconcile_new (
  7432. gsb_data_reconcile_get_name (reconcile_number) );
  7433. gsb_data_reconcile_set_account ( reconcile_number, account_number );
  7434. buffer_old_new_rec_conversion -> new_rec_number = reconcile_number;
  7435. old_new_rec_list = g_slist_append ( old_new_rec_list,
  7436. buffer_old_new_rec_conversion );
  7437. }
  7438. }
  7439. /* set the new_reconcile_number if necessary */
  7440. gsb_data_transaction_set_reconcile_number ( transaction_number,
  7441. reconcile_number );
  7442. /* set the initial date, we cannot have exactly the date of the
  7443. * reconciled paper, but we will take the first date of the
  7444. * transactions of this reconcile */
  7445. date_reconcile = gsb_data_reconcile_get_init_date (reconcile_number);
  7446. date_transaction = gsb_data_transaction_get_date (transaction_number);
  7447. if ( !date_reconcile
  7448. ||
  7449. g_date_compare ( date_reconcile, date_transaction) > 0 )
  7450. gsb_data_reconcile_set_init_date ( reconcile_number, date_transaction );
  7451. /* set the final date in the same way */
  7452. date_reconcile = gsb_data_reconcile_get_final_date (reconcile_number);
  7453. if ( !date_reconcile
  7454. ||
  7455. g_date_compare ( date_reconcile, date_transaction) < 0 )
  7456. gsb_data_reconcile_set_final_date ( reconcile_number, date_transaction );
  7457. /* add the amount of the transaction to the init balance of that reconcile,
  7458. * used later to find the initials and finals balances */
  7459. if (!gsb_data_transaction_get_mother_transaction_number (transaction_number))
  7460. gsb_data_reconcile_set_init_balance ( reconcile_number,
  7461. gsb_real_add ( gsb_data_reconcile_get_init_balance (
  7462. reconcile_number),
  7463. gsb_data_transaction_get_amount (transaction_number)));
  7464. }
  7465. list_tmp_transactions = list_tmp_transactions -> next;
  7466. }
  7467. /* second step, some reconciles can have the account number to -1
  7468. * if they hadn't any transactions associated to them,
  7469. * we delete them here */
  7470. dlist_tmp = gsb_data_reconcile_get_reconcile_list ();
  7471. while (dlist_tmp)
  7472. {
  7473. gint reconcile_number;
  7474. reconcile_number = gsb_data_reconcile_get_no_reconcile (dlist_tmp -> data);
  7475. dlist_tmp = dlist_tmp -> next;
  7476. if (gsb_data_reconcile_get_account (reconcile_number) == -1)
  7477. gsb_data_reconcile_remove (reconcile_number);
  7478. }
  7479. /* third step, we want to fill the inital and final balance of
  7480. * all the reconcile but all that we have is the final balance
  7481. * of the last reconcile and the transactions for all the
  7482. * reconciles (cannot run from the beginning with the initial
  7483. * balance of account because user can change the first time the
  7484. * initial balance of the reconcile).
  7485. * so run from the end and go to the start */
  7486. list_tmp_account = gsb_data_account_get_list_accounts ();
  7487. while (list_tmp_account)
  7488. {
  7489. gint account_number;
  7490. gint reconcile_number;
  7491. GList *rec_list = NULL;
  7492. struct reconcile_conversion_struct *reconcile;
  7493. account_number = gsb_data_account_get_no_account (list_tmp_account -> data);
  7494. list_tmp = reconcile_conversion_list;
  7495. while ( list_tmp )
  7496. {
  7497. gint reconcile_number;
  7498. reconcile = list_tmp -> data;
  7499. if ( reconcile -> account_number == account_number )
  7500. {
  7501. const GDate *final_date;
  7502. gint ecart_date;
  7503. reconcile_number = gsb_data_reconcile_get_account_last_number (
  7504. reconcile -> account_number );
  7505. final_date = gsb_data_reconcile_get_final_date ( reconcile_number );
  7506. ecart_date = g_date_days_between ( final_date, reconcile -> final_date );
  7507. if ( abs (ecart_date) < 10 )
  7508. {
  7509. gsb_data_reconcile_set_final_date ( reconcile_number,
  7510. reconcile -> final_date );
  7511. gsb_data_reconcile_set_final_balance ( reconcile_number,
  7512. reconcile -> final_balance );
  7513. result_reconcile = TRUE;
  7514. }
  7515. else
  7516. {
  7517. result_reconcile = gsb_file_load_set_last_reconcile_data (
  7518. account_number,
  7519. reconcile -> final_date,
  7520. reconcile -> final_balance);
  7521. }
  7522. break;
  7523. }
  7524. list_tmp = list_tmp -> next;
  7525. }
  7526. /* for each account, we find the last reconcile number, get the
  7527. * final balance and calculate the initial balance, wich is the
  7528. * final balance of the previous reconcile... */
  7529. rec_list = g_list_last ( gsb_data_reconcile_get_sort_reconcile_list (
  7530. account_number) );
  7531. while (rec_list)
  7532. {
  7533. gint previous_reconcile_number;
  7534. reconcile_number = GPOINTER_TO_INT ( rec_list -> data );
  7535. gsb_data_reconcile_set_init_balance ( reconcile_number,
  7536. gsb_real_sub ( gsb_data_reconcile_get_final_balance (
  7537. reconcile_number),
  7538. gsb_data_reconcile_get_init_balance (
  7539. reconcile_number)));
  7540. if ( rec_list -> prev )
  7541. {
  7542. previous_reconcile_number = GPOINTER_TO_INT ( (rec_list -> prev) -> data );
  7543. if (previous_reconcile_number)
  7544. gsb_data_reconcile_set_final_balance ( previous_reconcile_number,
  7545. gsb_data_reconcile_get_init_balance (reconcile_number));
  7546. }
  7547. rec_list = rec_list -> prev;
  7548. }
  7549. list_tmp_account = list_tmp_account -> next;
  7550. }
  7551. /*
  7552. * untill 0.6, no archive, so by default we let grisbi check at opening and set
  7553. * the transactions limit to 3000 */
  7554. conf.check_for_archival = TRUE;
  7555. conf.max_non_archived_transactions_for_check = 3000;
  7556. /**
  7557. * new in 0.6, there is no name for saving file but a directory
  7558. * with autoname for autosave.
  7559. * the best here is to show the first page of the new assistant
  7560. * to choose the save directory */
  7561. gsb_assistant_first_come_to_0_6 ();
  7562. /* ********************************************************* */
  7563. /* to set just before the new version */
  7564. /* ********************************************************* */
  7565. if ( etat.modification_fichier == 0 )
  7566. modification_fichier ( TRUE );
  7567. /* ************************************* */
  7568. /* opening 0.6.0 */
  7569. /* ************************************* */
  7570. /* now the order of account is saved directly in the file, but if come before,
  7571. * need to reorder the list */
  7572. gsb_data_account_reorder (sort_accounts);
  7573. case 60:
  7574. if ( conf.sauvegarde_demarrage )
  7575. etat.modification_fichier = TRUE;
  7576. break;
  7577. default :
  7578. /* we don't know here the release of that file, give the release needed */
  7579. tmpstr = g_strdup_printf ( _("Grisbi version %s is needed to open this file.\nYou are using version %s."),
  7580. download_tmp_values.grisbi_version,
  7581. VERSION );
  7582. dialogue_error ( tmpstr);
  7583. g_free ( tmpstr );
  7584. return ( FALSE );
  7585. }
  7586. /* general stuff for all versions */
  7587. /* mark the file as opened */
  7588. gsb_file_util_modify_lock ( TRUE );
  7589. /* check now if a lot of transactions,
  7590. * if yes, we propose to file the transactions
  7591. * by default take the 3000 transactions as limit */
  7592. if ( conf.check_for_archival
  7593. &&
  7594. g_slist_length (gsb_data_transaction_get_transactions_list ()) >
  7595. conf.max_non_archived_transactions_for_check )
  7596. gsb_assistant_archive_run (TRUE);
  7597. /* if we opened an archive, we say it here */
  7598. if (etat.is_archive)
  7599. dialogue_hint (_("You have opened an archive.\nThere is no limit in Grisbi, "
  7600. "you can do whatever you want and save it later (new reports...) "
  7601. "but remember it's an archive before modifying some transactions "
  7602. "or important information."),
  7603. _("Grisbi archive opened"));
  7604. return TRUE;
  7605. }
  7606. /**
  7607. * while going from 0.5.x to 0.6.x, there is a change of number of method of payment
  7608. * that function returns the new number of method of payment, from the last one and its account
  7609. * this is a temporary function wich should be removed the day when 0.5.x are not longer supported
  7610. *
  7611. * \param account_number
  7612. * \param payment_number
  7613. *
  7614. * \return the new number of payment or 0 if not found
  7615. * */
  7616. gint gsb_file_load_get_new_payment_number ( gint account_number,
  7617. gint payment_number )
  7618. {
  7619. GSList *tmp_list;
  7620. tmp_list = payment_conversion_list;
  7621. while (tmp_list)
  7622. {
  7623. struct payment_conversion_struct *conversion;
  7624. conversion = tmp_list -> data;
  7625. /* for the sorted list in accounts, payment_number can be negative if
  7626. * we split the neutrals payment, so return too a negative value
  7627. * in that case */
  7628. if ( conversion -> account_number == account_number
  7629. &&
  7630. conversion -> last_payment_number == abs (payment_number))
  7631. {
  7632. if (payment_number < 0)
  7633. return -conversion -> new_payment_number;
  7634. else
  7635. return conversion -> new_payment_number;
  7636. }
  7637. tmp_list = tmp_list -> next;
  7638. }
  7639. return 0;
  7640. }
  7641. /**
  7642. * il arrive que le dernier rapprochement effectué ne soit pas le dernier en date. Ce qui
  7643. * fausse la reconstruction des rapprochements. Dans ce cas on reconstitue le dernier
  7644. * rapprochement en date ŕ partir du dernier rapprochement effectué.
  7645. *
  7646. * \param account_number
  7647. * \param final_date for account
  7648. * \param final_balance for account
  7649. *
  7650. * \return TRUE is OK
  7651. * */
  7652. gboolean gsb_file_load_set_last_reconcile_data ( gint account_number,
  7653. GDate *final_date,
  7654. gsb_real final_balance )
  7655. {
  7656. GList *rec_list;
  7657. gsb_real amount = final_balance;
  7658. devel_debug_int ( account_number );
  7659. rec_list = g_list_last ( gsb_data_reconcile_get_sort_reconcile_list (
  7660. account_number) );
  7661. while (rec_list)
  7662. {
  7663. gint reconcile_number_next;
  7664. gint reconcile_number;
  7665. const GDate *last_date_next;
  7666. const GDate *last_date;
  7667. reconcile_number = GPOINTER_TO_INT ( rec_list -> data );
  7668. last_date = gsb_data_reconcile_get_final_date ( reconcile_number );
  7669. if ( g_date_compare ( final_date, last_date ) >= 0 )
  7670. {
  7671. if ( rec_list -> next )
  7672. {
  7673. reconcile_number_next = GPOINTER_TO_INT ( (rec_list -> next) -> data );
  7674. if ( reconcile_number_next )
  7675. last_date_next = gsb_data_reconcile_get_final_date ( reconcile_number_next );
  7676. if ( g_date_compare ( final_date, last_date_next ) < 0 )
  7677. {
  7678. gsb_data_reconcile_set_final_balance (
  7679. gsb_data_reconcile_get_account_last_number (account_number),
  7680. amount );
  7681. return TRUE;
  7682. }
  7683. }
  7684. else
  7685. {
  7686. gsb_data_reconcile_set_final_date ( reconcile_number, final_date );
  7687. gsb_data_reconcile_set_final_balance ( reconcile_number, final_balance );
  7688. return TRUE;
  7689. }
  7690. }
  7691. else
  7692. {
  7693. amount = gsb_real_add ( amount, gsb_data_reconcile_get_init_balance (
  7694. reconcile_number));
  7695. }
  7696. rec_list = rec_list -> prev;
  7697. }
  7698. return FALSE;
  7699. }
  7700. /**
  7701. * copy an old grisbi file
  7702. *
  7703. * \param filename the name of the file
  7704. *
  7705. * \return TRUE : ok, FALSE : problem
  7706. * */
  7707. void gsb_file_load_copy_old_file ( gchar *filename, gchar *file_content)
  7708. {
  7709. if ( g_str_has_suffix (filename, ".gsb" ) )
  7710. {
  7711. GFile * file_ori;
  7712. GFile * file_copy;
  7713. GError * error = NULL;
  7714. copy_old_filename = g_path_get_basename ( filename );
  7715. copy_old_filename = gsb_string_remplace_string ( copy_old_filename, ".gsb",
  7716. "-old-version.gsb" );
  7717. copy_old_filename = g_build_filename (
  7718. my_get_XDG_grisbi_data_dir (),
  7719. copy_old_filename, NULL );
  7720. file_ori = g_file_new_for_path ( filename );
  7721. file_copy = g_file_new_for_path ( copy_old_filename );
  7722. if ( !g_file_copy ( file_ori, file_copy, G_FILE_COPY_OVERWRITE,
  7723. NULL, NULL, NULL, &error ) )
  7724. {
  7725. dialogue_error (error -> message );
  7726. g_error_free ( error );
  7727. }
  7728. }
  7729. }
  7730. /* Local Variables: */
  7731. /* c-basic-offset: 4 */
  7732. /* End: */