Impacted versions:
10.0 + e

Steps to reproduce:
1) Create a salary rule that has 'appears_on_payslip' = False.
- An example would be a company contribution that the employee does not need to see.
  2) Add it to a salary structure
  3) run a payroll/payslip calculation

Current behavior:
Numerous thing.
1) Every time you compute sheet, you will duplicate these 'hidden' lines
2) details_by_salary_rule_category no longer has any of the hidden lines, though they certainly contribute to categories (e.g. tests will fail, and bad things)
3) when using hr_payroll_account, lines with contribution registers and accounts that SHOULD be on the journal entry are not !!

Expected behavior:
1) every time you compute the sheet, the lines should be deleted and recalculated
2) details_by_salary_rule_category should have all categories (to be able to make complex rules and tests)
3) journal entry should have a line for every line with an account

Pull Request eminent.

addons/hr_payroll/models/hr_payroll.py
inputs = InputLine(payslip.employee_id.id, inputs_dict, self.env)
        worked_days = WorkedDays(payslip.employee_id.id, worked_days_dict, self.env)
        payslips = Payslips(payslip.employee_id.id, payslip, self.env)
        rules = BrowsableObject(payslip.employee_id.id, rules_dict, self.env)
        baselocaldict = {'categories': categories, 'rules': rules, 'payslip': payslips, 'worked_days': worked_days, 'inputs': inputs}
        
        contracts = self.env['hr.contract'].browse(contract_ids)
        structure_ids = contracts.get_all_structures()
        
        rule_ids = self.env['hr.payroll.structure'].browse(structure_ids).get_all_rules()
        
        sorted_rule_ids = [id for id, sequence in sorted(rule_ids, key=lambda x:x[1])]
        sorted_rules = self.env['hr.salary.rule'].browse(sorted_rule_ids)
        for contract in contracts:
            employee = contract.employee_id
            localdict = dict(baselocaldict, employee=employee, contract=contract)
            for rule in sorted_rules:
                key = rule.code + '-' + str(contract.id)
                localdict['result'] = None
                localdict['result_qty'] = 1.0
                localdict['result_rate'] = 100
                
                if rule.satisfy_condition(localdict) and rule.id not in blacklist:
                    
                    amount, qty, rate = rule.compute_rule(localdict)
                    
                    previous_amount = rule.code in localdict and localdict[rule.code] or 0.0
                    
                    tot_rule = amount * qty * rate / 100.0
                    localdict[rule.code] = tot_rule