This commit is contained in:
oscar alvarez 2023-05-02 09:49:52 -05:00
parent 8fa37ef7c6
commit 101525047e
3 changed files with 81 additions and 2 deletions

56
fpc.nim Normal file
View File

@ -0,0 +1,56 @@
import macros
import nimpy
macro eval(value: static[string]): untyped =
result = parseStmt value
# let e: int = 5
# echo eval("1 + e")
type Contract = object
employee: int
start_date: string
end_date: string
salary: float
# type
# WageType = tuple[id: int, name: string]
type
WageType = object
id: int
name: string
sequence: int
definition: string
# unit_price_formula: void
# expense_formula: void
# salary_constitute: bool
# uom: int
# type_concept: string
# concepts_salary: @[]
# adjust_days_worked: bool
type Payroll = object
employee: int
start_date: string
end_date: string
# salary: float
# lines: @[PayrollLine]
# proc computePayroll(wages: seq[WageType]): int {.exportpy.} =
proc computePayroll(wages: seq[WageType]): string {.exportpy.} =
# echo wage.name
# for waget in wages:
# echo waget.name
# echo waget.sequence
# var mat = Payroll(
# employee: 456,
# start_date: "2023-01-01",
# end_date: "2023-01-31"
# )
let mat: string = wage.name
return mat

View File

@ -31,6 +31,10 @@ from .constants import (
FIELDS_AMOUNT, EXTRAS, SHEET_SUMABLES, LIM_PERCENT_DEDUCTIBLE,
)
# Nimporter is required for impot Nim
import nimporter
import trytond.modules.staff_payroll_co.fpc as fpc # Nim imports!
STATES = {'readonly': (Eval('state') != 'draft')}
_ZERO = Decimal('0.0')
@ -276,7 +280,6 @@ class Payroll(metaclass=PoolMeta):
def get_days(self, start, end, wage_adjust_days_worked=None):
adjust = 1
# adjust_days_worked = False
print("este contrato.--------", self.contract.id)
adjust_days_worked = self.contract.position.adjust_days_worked if self.contract else true
# print('this is', adj)
# if self.contract and self.contract.position:
@ -1721,6 +1724,26 @@ class PayrollGroupStart(metaclass=PoolMeta):
class PayrollGroup(metaclass=PoolMeta):
__name__ = 'staff.payroll_group'
def transition_open_nim(self):
Payroll = Pool().get('staff.payroll')
Wage = Pool().get('staff.wage_type')
fields_names = [
'name', 'sequence', 'definition', 'unit_price_formula',
'unit_price_formula', 'salary_constitute', 'expense_formula',
'type_concept'
]
wages = Wage.search_read([], fields_names=fields_names)
print('wages ===================', type(wages))
wage = {
"id" : 3,
"name" : "User"
}
res = fpc.computePayroll(wage)
print("Running in Nim....", res)
return 'end'
def transition_open_(self):
if self.start.task:
Employee = Pool().get('company.employee')

View File

@ -76,7 +76,7 @@ setup(name=name,
],
package_data={
'trytond.modules.%s' % MODULE: (info.get('xml', [])
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po',
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.nim',
'*.ods', '*.csv', '*.odt', '*.fodt', '*.fods']),
},
classifiers=[