Skip to content

Rules behavior

Documented against app commit ed7d6935. The same text lives in docs/agent/rules.md in the app repo.

Rules, copy rules, cleanup rules, momskoder, and Import Bank CSV. Bank import lives here because finishing a bank line creates and applies a rule. The bilag it produces is docs/agent/transactions.md.

Imports\oldBankBogforingController is not routed. On Imports\BankBogforingController, update_old, exclude, and the commented store are not routed. Do not extend them. The live bank methods are index, store, type, display, update, and edit.

PathViewWhat it is
GET /rulesresources/views/pages/rules/index.blade.phpRule list.
GET /rules/add and GET /rules/{id}resources/views/pages/rules/form.blade.phpCreate and edit.
GET /rules/copyresources/views/pages/copyrule/index.blade.phpCopy rules onto another company or year.
GET /cleanupresources/views/pages/cleanups/index.blade.phpCleanup rules.
GET /settings/momskoderesources/views/pages/momskode/index.blade.phpMomskoder.
GET /bogforings/importbankresources/views/pages/imports/bankbogforings/index.blade.phpUpload a bank CSV.
POST /bogforings/importbank/typeresources/views/pages/imports/bankbogforings/type.blade.phpMap columns.
POST /bogforings/importbank/displayresources/views/pages/imports/bankbogforings/display.blade.phpNew rows against what is already posted.
GET /bogforings/importbank/{id}resources/views/pages/imports/bankbogforings/edit.blade.phpFinish each line: type, konto, modkonto, rule.

Middleware for rules, copy, and cleanup: module:rule or module:cleanup, plus account and year. Momskode is module:momskode and does not require a year. Bank import uses module:bogforing, account, and year.

POST /rules/add (RuleController@save) stores the match text, the bogføring type, leverandør or kunde, konto, modkonto, and momskode. GET /rules/delete/{id} removes one rule. The form script public/js/rule.js can create the party in place with POST /api/leverandorers or POST /api/kunders.

The bank edit script and the daybook also call:

CallEffect
POST /api/rulesApi\RuleController@save. Creates or updates the rule for the line just booked.
POST /api/rules/get-rulesReturns rules that match the current text, for the picker.
POST /api/rules/batch-updateApplies one rule onto many bank lines.
GET /api/rules/delete/{id}Deletes a rule from the edit screen.

POST /rules/copy (CopyRuleController@store) copies the selected rules onto the target company. It does not post bilag.

POST /cleanup and POST /cleanup/{id} store a cleanup rule (match text, optional regex via is_regex, replacement). GET /cleanup/delete/{id} removes it. POST /api/cleanup (Api\CleanupController@store) is what public/js/cleanup.js calls from this page and from bogføring cleanup. GET /api/cleanup/test is not used.

Applying a rule to existing daybook rows is BogforingController@groupUpdate, documented in docs/agent/bogforing.md.

POST /settings/momskode and POST /settings/momskode/{id} store the code, VAT percent, and the konto numbers VAT posts to. A momskode with a second konto is what momskodeDoubleMap represents. BogforingTransactionService::store uses the first konto for the type 3 or 4 line and, when the second exists, writes an extra line with the opposite sign. Changing VAT does not rewrite old lines.

GET /bogforings/importbank is the file form. POST /bogforings/importbank/type opens the column mapper (date, text, amount, delimiter, saldo). POST /bogforings/importbank (store) saves the column map on bank_csv_configs and, for type custom, a bank_csv_types row for this company. An empty file redirects back with “No data found in the file”.

POST /bogforings/importbank/display compares the file with existing rows and shows which lines are new. Grey rows are matches and will be ignored. POST /bogforings/importbank/update writes a bank_csvs header, a csv_saldos row, and one inactive bogføring per unmatched line through BogforingService::storeBankCsvRows (is_active = 0, is_bogfo_visible = 0, category Daglig, type Finansbilag). It then redirects to GET /bogforings/importbank/{id}.

edit lists those draft headers. The script posts:

CallEffect
POST /api/bankbogforing/compareChecks the line against existing bilag before save.
POST /api/bankbogforing/updateApi\BankBogforingController@update completes one line.
POST /api/bankbogforing/batch-updateCompletes many lines with the same type and konto.

Completion runs BogforingService::updateBankBogforingPost, which sets is_active = 1 and is_bogfo_visible = 1, then buildBankBogforingTransactions and simplifiedStore so the lines match a manual bilag. Saving also posts the rule through /api/rules, which is why the next file with the same text can be filled in.

public/js/imports/express.js, rule2.js, and modalCleanup.js belong to the unrouted old bank blades. The live edit page loads public/js/imports/bankbogforing/edit.js only.