File: classement_echeances.c

package info (click to toggle)
grisbi 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 28,808 kB
  • sloc: ansic: 161,477; sh: 4,559; makefile: 918; xml: 580; perl: 370
file content (134 lines) | stat: -rw-r--r-- 5,104 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* ************************************************************************** */
/*                                  classement_echeances.c                    */
/*                                                                            */
/*     Copyright (C)    2000-2003 Cédric Auger (cedric@grisbi.org)           */
/*          2003-2004 Benjamin Drieu (bdrieu@april.org)                       */
/*          2003-2004 Alain Portal (aportal@univ-montp2.fr)                   */
/*          2008-2009 Pierre Biava (grisbi@pierre.biava.name)                 */
/*          http://www.grisbi.org                                             */
/*                                                                            */
/*  This program is free software; you can redistribute it and/or modify      */
/*  it under the terms of the GNU General Public License as published by      */
/*  the Free Software Foundation; either version 2 of the License, or         */
/*  (at your option) any later version.                                       */
/*                                                                            */
/*  This program is distributed in the hope that it will be useful,           */
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of            */
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
/*  GNU General Public License for more details.                              */
/*                                                                            */
/*  You should have received a copy of the GNU General Public License         */
/*  along with this program; if not, write to the Free Software               */
/*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
/*                                                                            */
/* ************************************************************************** */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "include.h"


/*START_INCLUDE*/
#include "classement_echeances.h"
#include "gsb_data_scheduled.h"
#include "gsb_data_transaction.h"
/*END_INCLUDE*/

/*START_STATIC*/
/*END_STATIC*/


/*START_EXTERN*/
/*END_EXTERN*/




/* ************************************************************************* */
/* Classement de deux échéances d'opérations par date                        */
/* ************************************************************************* */
gint classement_sliste_echeance_par_date ( gpointer data_1,
                        gpointer data_2,
                        gpointer manual )
{
    const GDate *date;
    gint scheduled_number_1 = GPOINTER_TO_INT(data_1);
    gint scheduled_number_2 = GPOINTER_TO_INT(data_2);

    if ( manual )
    {
        date = gsb_data_scheduled_get_date ( scheduled_number_1 );
        if ( date )
            return ( g_date_compare ( date,
                            gsb_data_scheduled_get_date (scheduled_number_2) ));
        else
            return -1;
    }
    else
    {
        date = gsb_data_transaction_get_date ( scheduled_number_1 );
        if ( date )
            return ( g_date_compare ( date,
                            gsb_data_transaction_get_date (scheduled_number_2) ));
        else
            return -1;
    }

}


/* ************************************************************************* */
/* Classement de deux opérations par date croissante                           */
/* ************************************************************************* */
gint classement_sliste_transactions_par_date ( gpointer transaction_pointer_1,
                        gpointer transaction_pointer_2 )
{
    const GDate *date;
    gint transaction_number_1;
    gint transaction_number_2;

    transaction_number_1 = gsb_data_transaction_get_transaction_number (
                        transaction_pointer_1 );
    transaction_number_2 = gsb_data_transaction_get_transaction_number (
                        transaction_pointer_2 );
    date = gsb_data_transaction_get_date (transaction_number_1);
    if ( date )
        return ( g_date_compare ( date,
                        gsb_data_transaction_get_date (transaction_number_2) ));
    else
        return -1;
}


/**
 * Classement de deux opérations par date décroissante
 *
 *
 *
 * */
gint classement_sliste_transactions_par_date_decroissante ( gpointer transaction_pointer_1,
                        gpointer transaction_pointer_2 )
{
    const GDate *date;
    gint transaction_number_1;
    gint transaction_number_2;

    transaction_number_1 = gsb_data_transaction_get_transaction_number (
                        transaction_pointer_1 );
    transaction_number_2 = gsb_data_transaction_get_transaction_number (
                        transaction_pointer_2 );

    date = gsb_data_transaction_get_date ( transaction_number_1 );
    if ( date )
        return - ( g_date_compare ( date,
                        gsb_data_transaction_get_date ( transaction_number_2 ) ) );
    else
        return -1;
}


/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */