Rules / regular expression with account_statement_rule

I’m playing around with the account_statement_rule module, but I just walked into a problem. I want to have a rule where:

  • (party is empty or not) and amount > 0 -> the account should be ‘receivable’
  • (party is empty or not) and amount < 0 -> the account should be ‘payable’

How to achieve this?

I’m just thinking about a small enhancement to get this working:

The module is never looking if there is a party on the origin. So I would propose to change modules/account_statement_rule: d6f41dff15db

party =


party = or

The module then checks first if there is a party on the rule. If not get the party from the origin.

Which will be the benefit of your proposal?
The party of the line and the party of the origin should be exactly the same.

I forgot a small detail: I import the bank statements, so the origin lines are created automatically.

Yes, but the account_statement_rule doesn’t do anything with that. It tries to find the party again based on account number or party name, but neither of those exists in the keywords. And if there is no party, the rule-system stops.

When you want to create origin lines with an account where party is required and the rule-system doesn’t find a party, the rule-system should try to get the party from the origin line. If it then fails, that’s no problem.
In this way, users are able to automatically generate almost all the statement lines, which is a big win, when you have a lot of origin lines with a party. Those lines are then automatically generated.

With the change I can do all the work in about 4 steps:

  1. import bank statement
  2. open a bank statement and make the tab “Origins” active
  3. press the “Apply Rules” button
  4. validate / post / reconcile

As a small company I don’t want to spend a lot of time. I think I can catch almost all of the origin lines with a set of rules.

How could you not have the party on the statement line but on the origin? The origin is created first and lines are created based on the origin so they should have party filled.

During importing the statement, the party is searched based on bank account number. So most of the origin lines have a party based on that. However the account_statement_rule doesn’t do anything with that. Instead it tries to find the party again. See modules/account_statement_rule: edbc31fd9853 and modules/account_statement_rule: edbc31fd9853 It would be a nice if the module also checks if a party exists on the origin.

OK it is when the rule creates a new line based on the origin. So I agree that it will be better to use the party of origin if set but only after trying to find it from the keywords rule.

Yes, I agree and I think that’s the case in my second message of this thread.

No using the origin party should be fallback after the rules not before. Because it is the point of the rule to fill those field using expression. For example the same bank account can be used by different parties.