Overview
Comment: | Also list other types of usual accounts in advanced selector |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
94cd4005a629a6e847d4a2c4c4dc7b05 |
User & Date: | bohwaz on 2022-11-06 12:32:44 |
Other Links: | manifest | tags |
Context
2022-11-06
| ||
12:33 | Change accounts rules if changing the chart country check-in: 83fc1253fe user: bohwaz tags: trunk, stable | |
12:32 | Also list other types of usual accounts in advanced selector check-in: 94cd4005a6 user: bohwaz tags: trunk | |
12:11 | Fix selector when list is empty check-in: 2d0344ac5f user: bohwaz tags: trunk, stable | |
Changes
Modified src/include/lib/Garradin/Entities/Accounting/Year.php from [81cc63f281] to [e2ea767a49].
︙ | ︙ | |||
177 178 179 180 181 182 183 | /** * List common accounts used in this year, grouped by type * @return array */ public function listCommonAccountsGrouped(array $types = null): array { if (null === $types) { | | > > > | > > > > > > > > | | > | > > > > > > | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | /** * List common accounts used in this year, grouped by type * @return array */ public function listCommonAccountsGrouped(array $types = null): array { if (null === $types) { $target = Account::COMMON_TYPES; } else { $target = $types; } $out = []; foreach ($target as $type) { $out[$type] = (object) [ 'label' => Account::TYPES_NAMES[$type], 'type' => $type, 'accounts' => [], ]; } if (null === $types) { $out[0] = (object) [ 'label' => 'Autres', 'type' => 0, 'accounts' => [], ]; } $db = DB::getInstance(); $sql = sprintf('SELECT a.* FROM acc_accounts a LEFT JOIN acc_transactions_lines b ON b.id_account = a.id LEFT JOIN acc_transactions c ON c.id = b.id_transaction AND c.id_year = %d WHERE a.id_chart = %d %s AND (a.bookmark = 1 OR a.user = 1 OR c.id IS NOT NULL) GROUP BY a.id ORDER BY type, code COLLATE NOCASE;', $this->id(), $this->id_chart, $types !== null ? 'AND a.' . $db->where('type', $target) : '' ); $query = $db->iterate($sql); foreach ($query as $row) { $t = in_array($row->type, $target, true) ? $row->type : 0; $out[$t]->accounts[] = $row; } foreach ($out as $key => $v) { if (!count($v->accounts)) { unset($out[$key]); } } return $out; } } |