How to prevent a rule to be triggered inside a rule? I'm using the Rules module and I have two rules: 


A: When flagged, 'Post a journal entry to the ledger'
B: When unflagged, 'Remove journal entry from the ledger'


Rule A includes also two Rules components with conditions that check if the journal entry is balanced:

If the condition 'balanced' is true: 
 - Post journal entry to the ledger.

If the condition 'unbalanced' is true: 
 - Show a warning on the page and UNFLAG the journal entry. 

The problem is that I don't want the Rule B to be triggered inside rule A, which currently happens. 

Theoretically I could add a condition to Rule B like 'is balanced' but I don't want to modify other rules in order to prevent the execution of a rule inside a rule.

Is it possible to prevent nested Rules from firing?
This is a workaround solution.
You could add a boolean field to your journal entry content type. Side note, you could use the Field Permission module to hide the boolean field from the add/edit form.
Alternatively, if you're not using the sticky system, you could use that instead.
So now all you gotta do is add a condition to your Unflag Rule.

Boolean is false/unchecked OR content is unsticky.


Now in your Component Action add:

Set a data value and make your boolean True/checked OR Make content sticky
Unflag node
Set a data value and make your boolean false/unchecked OR Make content unsticky


Voilà!!! your component will not trigger your unflag rule.