# Add 'default rule' in account\_statement\_rule

**URL:** https://discuss.tryton.org/t/add-default-rule-in-account-statement-rule/4181
**Category:** Ideas
**Created:** [May 10, 2021, 3:06pm UTC](https://discuss.tryton.org/t/add-default-rule-in-account-statement-rule/4181 "2021-05-10T15:06:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [May 10, 2021, 3:06pm UTC](https://discuss.tryton.org/t/add-default-rule-in-account-statement-rule/4181/1 "2021-05-10T15:06:29Z")

</div>

The `account_statement_rule` is a nice module which takes a lot of work out of our hands. But IMO there can be another improvement to the module.

The module walks through a list of rules, checks them and if the rule applies, it gives the statement line back with an amount. When no rule applies, no statement line is added.

The improvement will be twofold:

1. Based on the rule, statement lines are created with a certain amount. It is not required that the statement line should have the total amount, so multiple statement lines can be created. This is the normal behavior. The module however should check the pending amount and if it’s ‘0’, it should stop checking the other rules as they don’t make any sense anymore. This makes it possible to have more rules which is not necessarily needed because you can create multiple statement lines from one rule.
2. When point 1. is working, default rule(s) can be created. Those rules are the last ones to be checked and basically are always ‘True’ so statement lines are always created. In my case I want to have two default rules, one for payment (creditor) and one for receiving (debitor) because both are always going to the default accounts and I get most of this kind of statement lines.

The whole idea is like the firewall. A set of rules which are checked from top to bottom and when one fits, the packet is allowed. At the end there is the default deny rule.

Any thoughts on this?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 10, 2021, 3:31pm UTC](https://discuss.tryton.org/t/add-default-rule-in-account-statement-rule/4181/2 "2021-05-10T15:31:38Z")

</div>

> [@edbo](#):
>
> It is not required that the statement line should have the total amount, so multiple statement lines can be created.

For me it is a mistake. The system should apply only the first matching rule.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [May 10, 2021, 6:07pm UTC](https://discuss.tryton.org/t/add-default-rule-in-account-statement-rule/4181/3 "2021-05-10T18:07:31Z")

</div>

> [@ced](#):
>
> The system should apply only the first matching rule.

I’m totally fine with that. But that’s not the case at the moment. When I have my default rule at the bottom, and there is another rule higher in the list, I get two statement lines for the same origin. Both rules are a match with the origin and both create a statement line with the amount and the account I set on the rule.

So when your idea was working, I should only get one statement line from the first rule with the right account. And that’s all I want 🙂

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 10, 2021, 10:10pm UTC](https://discuss.tryton.org/t/add-default-rule-in-account-statement-rule/4181/4 "2021-05-10T22:10:00Z")

</div>

> **[Apply only one matching rule (#10403) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/10403)**
>
> The statement should apply only the first rule matching (instead of all matching) the origin as it is described in the documentation. Normally it should be just about...

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [May 11, 2021, 12:19pm UTC](https://discuss.tryton.org/t/add-default-rule-in-account-statement-rule/4181/5 "2021-05-11T12:19:49Z")

</div>

The bug is fixed and now I get the the result I wanted. The fix should be in the next update hopefully.
