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