Overview
Comment: | Add analytical account to import and export |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
fb1c44df6f19f3152360baf39d48b8b1 |
User & Date: | bohwaz on 2020-11-20 15:20:21 |
Other Links: | branch diff | manifest | tags |
Context
2020-11-20
| ||
15:54 | Fix non-mandatory argument check-in: b74db4a507 user: bohwaz tags: dev | |
15:20 | Add analytical account to import and export check-in: fb1c44df6f user: bohwaz tags: dev | |
14:36 | Fix misc issues with checkbox etc. check-in: d3f81e9b58 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Accounting/Transactions.php from [48a7e2b83b] to [13e724a358].
︙ | ︙ | |||
110 111 112 113 114 115 116 | /** * Return all transactions from year */ static public function export(int $year_id): \Generator { $sql = 'SELECT t.id, t.type, t.status, t.label, t.date, t.notes, t.reference, l.id AS line_id, a.code AS account, l.debit AS debit, l.credit AS credit, | | > > | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /** * Return all transactions from year */ static public function export(int $year_id): \Generator { $sql = 'SELECT t.id, t.type, t.status, t.label, t.date, t.notes, t.reference, l.id AS line_id, a.code AS account, l.debit AS debit, l.credit AS credit, l.reference AS line_reference, l.label AS line_label, l.reconciled, a2.code AS analytical FROM acc_transactions t INNER JOIN acc_transactions_lines l ON l.id_transaction = t.id INNER JOIN acc_accounts a ON a.id = l.id_account LEFT JOIN acc_accounts a2 ON a2.id = l.id_analytical WHERE t.id_year = ? ORDER BY t.date, t.id, l.id;'; $res = DB::getInstance()->iterate($sql, $year_id); $previous_id = null; foreach ($res as $row) { |
︙ | ︙ | |||
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 238 239 240 241 | $id_account = $accounts->getIdFromCode($row->account); if (!$id_account) { throw new UserException(sprintf('le compte "%s" n\'existe pas dans le plan comptable', $row->account)); } $row->line_id = trim($row->line_id); if ($row->line_id) { $line = $transaction->getLine((int)$row->line_id); if (!$line) { throw new UserException(sprintf('le numéro de ligne "%s" n\'existe pas dans l\'écriture "%s"', $row->line_id, $transaction->id ?: 'à créer')); } } else { $line = new Line; } $line->importForm([ 'credit' => $row->credit ?: 0, 'debit' => $row->debit ?: 0, 'id_account' => $id_account, 'reference' => $row->line_reference, 'label' => $row->line_label, 'reconciled' => $row->reconciled, ]); if (!$row->line_id) { $transaction->addLine($line); } } | > > > > > > > > > > | 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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | $id_account = $accounts->getIdFromCode($row->account); if (!$id_account) { throw new UserException(sprintf('le compte "%s" n\'existe pas dans le plan comptable', $row->account)); } $row->line_id = trim($row->line_id); $id_analytical = null; if (!empty($row->analytical)) { $id_analytical = $accounts->getIdFromCode($row->analytical); if (!$id_analytical) { throw new UserException(sprintf('le compte analytique "%s" n\'existe pas dans le plan comptable', $row->analytical)); } } if ($row->line_id) { $line = $transaction->getLine((int)$row->line_id); if (!$line) { throw new UserException(sprintf('le numéro de ligne "%s" n\'existe pas dans l\'écriture "%s"', $row->line_id, $transaction->id ?: 'à créer')); } } else { $line = new Line; } $line->importForm([ 'credit' => $row->credit ?: 0, 'debit' => $row->debit ?: 0, 'id_account' => $id_account, 'reference' => $row->line_reference, 'label' => $row->line_label, 'reconciled' => $row->reconciled, 'id_analytical' => $id_analytical, ]); if (!$row->line_id) { $transaction->addLine($line); } } |
︙ | ︙ |