post move with line tax
This commit is contained in:
parent
f5f9bad49f
commit
2d1214ba30
113
payroll.py
113
payroll.py
|
@ -24,32 +24,34 @@ _ZERO = Decimal('0.0')
|
|||
|
||||
|
||||
def get_dom_contract_period(start, end):
|
||||
dom = ['OR', [
|
||||
('start_date', '>=', start),
|
||||
('finished_date', '<=', end),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', start),
|
||||
('finished_date', '>=', start),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', end),
|
||||
('finished_date', '>=', end),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', start),
|
||||
('finished_date', '>=', end),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', start),
|
||||
('finished_date', '=', None),
|
||||
],
|
||||
[
|
||||
('start_date', '>=', start),
|
||||
('start_date', '<=', end),
|
||||
('finished_date', '=', None),
|
||||
],
|
||||
]
|
||||
dom = [
|
||||
'OR',
|
||||
[
|
||||
('start_date', '>=', start),
|
||||
('finished_date', '<=', end),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', start),
|
||||
('finished_date', '>=', start),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', end),
|
||||
('finished_date', '>=', end),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', start),
|
||||
('finished_date', '>=', end),
|
||||
('finished_date', '!=', None),
|
||||
], [
|
||||
('start_date', '<=', start),
|
||||
('finished_date', '=', None),
|
||||
],
|
||||
[
|
||||
('start_date', '>=', start),
|
||||
('start_date', '<=', end),
|
||||
('finished_date', '=', None),
|
||||
],
|
||||
]
|
||||
return dom
|
||||
|
||||
|
||||
|
@ -66,10 +68,10 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
employee = fields.Many2One('company.employee', 'Employee',
|
||||
states=STATES, required=True, depends=['state'], select=True)
|
||||
kind = fields.Selection([
|
||||
('normal', 'Normal'),
|
||||
('special', 'Special'),
|
||||
], 'Kind', required=True, select=True, states=STATES,
|
||||
help="Special allow overlap dates with another payroll")
|
||||
('normal', 'Normal'),
|
||||
('special', 'Special'),
|
||||
], 'Kind', required=True, select=True, states=STATES,
|
||||
help="Special allow overlap dates with another payroll")
|
||||
contract = fields.Many2One('staff.contract', 'Contract',
|
||||
select=True, domain=[
|
||||
('employee', '=', Eval('employee')),
|
||||
|
@ -102,11 +104,11 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
depends=['start', 'end', 'state']),
|
||||
'on_change_with_worked_days')
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('processed', 'Processed'),
|
||||
('cancel', 'Cancel'),
|
||||
('posted', 'Posted'),
|
||||
], 'State', readonly=True)
|
||||
('draft', 'Draft'),
|
||||
('processed', 'Processed'),
|
||||
('cancel', 'Cancel'),
|
||||
('posted', 'Posted'),
|
||||
], 'State', readonly=True)
|
||||
journal = fields.Many2One('account.journal', 'Journal', required=True,
|
||||
states=STATES)
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
|
@ -338,14 +340,15 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
|
||||
Configuration = Pool().get('staff.configuration')
|
||||
configuration = Configuration(1)
|
||||
tax = getattr(configuration, 'tax_withholding')
|
||||
entity_in_line = configuration.expense_contribution_entity
|
||||
debit_acc2 = None
|
||||
attr_getter = attrgetter(
|
||||
'amount', 'party', 'amount_60_40', 'wage_type.id'
|
||||
'amount', 'party', 'amount_60_40', 'wage_type.id', 'tax_base'
|
||||
)
|
||||
for line in self.lines:
|
||||
amount, party, amount_60_40, wage_type = attr_getter(line)
|
||||
wage_type_= wage_dict[wage_type]
|
||||
amount, party, amount_60_40, wage_type, tax_base = attr_getter(line)
|
||||
wage_type_ = wage_dict[wage_type]
|
||||
definition = wage_type_['definition']
|
||||
account_60_40 = wage_type_['account_60_40.']
|
||||
debit_acc = wage_type_['debit_account.']
|
||||
|
@ -355,7 +358,7 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
continue
|
||||
try:
|
||||
party_id = party.id
|
||||
except:
|
||||
except Exception:
|
||||
party_id = None
|
||||
if not party_id:
|
||||
if mandatory_wages.get(wage_type):
|
||||
|
@ -397,8 +400,7 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
lines_moves[debit_acc['id']] = {
|
||||
employee_id: line.get_move_line(
|
||||
debit_acc, p,
|
||||
('debit', amount_debit)
|
||||
)}
|
||||
('debit', amount_debit))}
|
||||
else:
|
||||
line.update_move_line(
|
||||
lines_moves[debit_acc['id']][employee_id],
|
||||
|
@ -410,8 +412,7 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
lines_moves[debit_acc2['id']] = {
|
||||
employee_id: line.get_move_line(
|
||||
debit_acc2, party_id,
|
||||
('debit', amount_debit2)
|
||||
)}
|
||||
('debit', amount_debit2))}
|
||||
else:
|
||||
line.update_move_line(
|
||||
lines_moves[debit_acc2['id']][employee_id],
|
||||
|
@ -424,20 +425,24 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
if credit_acc:
|
||||
if credit_acc['id'] not in lines_moves.keys():
|
||||
lines_moves[credit_acc['id']] = {
|
||||
party_id: line.get_move_line(
|
||||
credit_acc, party_id, ('credit',
|
||||
amount_credit)
|
||||
)}
|
||||
party_id: line.get_move_line(
|
||||
credit_acc, party_id,
|
||||
('credit', amount_credit))}
|
||||
line_credit_ready = True
|
||||
else:
|
||||
if party_id not in lines_moves[credit_acc['id']].keys():
|
||||
lines_moves[credit_acc['id']].update({
|
||||
party_id: line.get_move_line(
|
||||
credit_acc, party_id, (
|
||||
'credit', amount_credit)
|
||||
)
|
||||
})
|
||||
party_id: line.get_move_line(
|
||||
credit_acc, party_id,
|
||||
('credit', amount_credit))})
|
||||
line_credit_ready = True
|
||||
if tax_base and tax:
|
||||
tax_line = {
|
||||
'amount': tax_base,
|
||||
'tax': tax.id,
|
||||
'type': 'base',
|
||||
}
|
||||
lines_moves[credit_acc['id']][party_id]['tax_lines'] = [('create', [tax_line])]
|
||||
if definition != 'payment':
|
||||
deduction_acc = wage_type_['deduction_account.']
|
||||
if deduction_acc:
|
||||
|
@ -544,10 +549,10 @@ class Payroll(Workflow, ModelSQL, ModelView):
|
|||
for concept in self.employee.mandatory_wages:
|
||||
wage_type, party, fix_amount = attr_mandatory(concept)
|
||||
if wage_type.salary_constitute:
|
||||
wage_salary.append(
|
||||
wage_salary_append(
|
||||
(cache_wage_dict[wage_type.id], party, fix_amount))
|
||||
else:
|
||||
wage_no_salary.append(
|
||||
wage_no_salary_append(
|
||||
(cache_wage_dict[wage_type.id], party, fix_amount))
|
||||
|
||||
self._create_payroll_lines(config, wage_salary, extras, discounts, cache_wage_dict)
|
||||
|
|
Loading…
Reference in New Issue