66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
import base64
|
|
import json
|
|
|
|
from odoo import http, fields
|
|
from odoo.http import request
|
|
from odoo.tools import float_is_zero,float_round
|
|
|
|
|
|
class YuthonSalary(http.Controller):
|
|
|
|
@http.route('/yuthon/yuthon/salary', methods=['POST'], type='http', auth='none', csrf=False)
|
|
def index2(self, **kwargs):
|
|
id = kwargs.get('id')
|
|
data = request.env['hr.payslip'].sudo().search(domain = [("id", "=", int(id))])
|
|
lines_ids = []
|
|
amount_total = 0.0
|
|
for line in data.line_ids:
|
|
if float_is_zero(line.total, precision_rounding=line.currency_id.rounding):
|
|
continue
|
|
total = float_round(line.total, precision_rounding=line.currency_id.rounding)
|
|
amount_total += total
|
|
lines_ids.append({
|
|
'id':line.id,
|
|
'name':line.name,
|
|
'code':line.code,
|
|
'category_id':line.category_id.name,
|
|
'total':total,
|
|
'amount':line.amount,
|
|
'sequence':line.sequence,
|
|
'appears_on_payslip':line.appears_on_payslip,
|
|
'slip_id':line.slip_id.id,
|
|
})
|
|
|
|
result = {
|
|
'id':data.id,
|
|
'name':data.name,
|
|
'payslip_run_id':data.payslip_run_id.name,
|
|
'date_from':fields.Date.to_string(data.date_from),
|
|
'date_to':fields.Date.to_string(data.date_to),
|
|
'lines_ids':lines_ids,
|
|
'amount_total':amount_total,
|
|
'state':data.state,
|
|
}
|
|
|
|
return json.dumps({
|
|
'data':result,
|
|
'code':200,
|
|
'message':'success'
|
|
})
|
|
|
|
@http.route('/yuthon/yuthon/salary/confirm', methods=['POST'], type='http', auth='none', csrf=False)
|
|
def index3(self, **kwargs):
|
|
id = kwargs.get('id')
|
|
|
|
record = request.env['hr.payslip'].sudo().search(domain=[("id", "=", int(id))])
|
|
|
|
record.write({
|
|
'state':'verify',
|
|
})
|
|
|
|
return json.dumps({
|
|
'data': record.id,
|
|
'code': 200,
|
|
'message': 'success'
|
|
})
|