Overview
Comment:Correction de l'association de moyen de paiement à l'import, corrige [5294465736e2ef3e82af49cf4c2a69c0d31f4e77], signalé par @Marc Gaudillot
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable | 0.9.3
Files: files | file ages | folders
SHA1: 26aeff6d3a69c3bdc589b22054715eb4fe7bc3da
User & Date: bohwaz on 2019-09-23 20:11:53
Other Links: manifest | tags
Context
2019-09-23
20:47
Mise à jour version check-in: 1d2b0786d4 user: bohwaz tags: trunk, stable, 0.9.3
20:11
Correction de l'association de moyen de paiement à l'import, corrige [5294465736e2ef3e82af49cf4c2a69c0d31f4e77], signalé par @Marc Gaudillot check-in: 26aeff6d3a user: bohwaz tags: trunk, stable, 0.9.3
20:03
Cohérence format de liste membres, corrige [37b3fab88e63a975dbce0c1c0402892ae642044f] check-in: 6b5ef651c6 user: bohwaz tags: trunk
Changes

Modified src/include/lib/Garradin/Compta/Categories.php from [1997e6a481] to [aacf281b4b].

106
107
108
109
110
111
112
113

114
115

116








117
118
119
120
121
122
123
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







-
+


+
-
+
+
+
+
+
+
+
+







            FROM compta_categories AS cat INNER JOIN compta_comptes AS cc
                ON cc.id = cat.compte
            WHERE %s ORDER BY cat.intitule;', $where);

        return $db->getGrouped($query);
    }

    public function listMoyensPaiement()
    public function listMoyensPaiement($assoc = false)
    {
        $db = DB::getInstance();

        return $db->getGrouped('SELECT code, nom FROM compta_moyens_paiement ORDER BY nom COLLATE NOCASE;');
        $query = 'SELECT code, nom FROM compta_moyens_paiement ORDER BY nom COLLATE NOCASE;';

        if ($assoc) {
            return $db->getAssoc($query);
        }
        else {
            return $db->getGrouped($query);
        }
    }

    public function getMoyenPaiement($code)
    {
        $db = DB::getInstance();
        return $db->firstColumn('SELECT nom FROM compta_moyens_paiement WHERE code = ?;', $code);
    }

Modified src/include/lib/Garradin/Compta/Import.php from [85a128e4c5] to [2b6a446835].

85
86
87
88
89
90
91

92

93
94
95
96
97
98
99
85
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100







+
-
+







		$db = DB::getInstance();
		$db->begin();
		$cats = new Categories;
		$journal = new Journal;

		$columns = array_flip($this->header);
		$liste_cats = $db->getAssoc('SELECT intitule, id FROM compta_categories;');
		// Liste des moyens sous la forme nom -> code
		$liste_moyens = $cats->listMoyensPaiement();
		$liste_moyens = array_flip($cats->listMoyensPaiement(true));

		$col = function($column) use (&$row, &$columns)
		{
			if (!isset($columns[$column]))
				return null;

			if (!isset($row[$columns[$column]]))
118
119
120
121
122
123
124
125

126
127
128

129
130
131
132
133
134
135
119
120
121
122
123
124
125

126
127
128

129
130
131
132
133
134
135
136







-
+


-
+








			if ($line === 1)
			{
				if (trim($row[0]) != 'Numéro mouvement')
				{
					throw new UserException('Erreur sur la ligne ' . $line . ' : l\'entête des colonnes est absent ou incorrect.');
				}
				

				continue;
			}
	

			if (count($row) != count($columns))
			{
				$db->rollback();
				throw new UserException('Erreur sur la ligne ' . $line . ' : le nombre de colonnes est incorrect.');
			}

			if (trim($row[0]) !== '' && !is_numeric($row[0]))
158
159
160
161
162
163
164

165








166
167
168
169
170
171
172
159
160
161
162
163
164
165
166

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181







+
-
+
+
+
+
+
+
+
+








			$debit = $col('Compte de débit - numéro');
			$credit = $col('Compte de crédit - numéro');

			$cat = $col('Catégorie');
			$moyen = strtoupper(substr($col('Moyen de paiement'), 0, 2));

			// Association du moyen de paiement par nom
			if (!$moyen || !array_key_exists($moyen, $liste_moyens))
			if ($moyen && array_key_exists($moyen, $liste_moyens))
			{
				$moyen = $liste_moyens[$moyen];
			}

			// Vérification de l'existence du moyen de paiement
			// s'il n'est pas valide, on ne peut pas avoir de catégorie non plus
			if (!$moyen || !in_array($moyen, $liste_moyens, true))
			{
				$moyen = false;
				$cat = false;
			}

			if ($cat && !array_key_exists($cat, $liste_cats))
			{