brynq-sdk-nmbrs 2.3.1.dev0__py3-none-any.whl → 2.3.3.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- brynq_sdk_nmbrs/__init__.py +86 -80
- brynq_sdk_nmbrs/address.py +82 -2
- brynq_sdk_nmbrs/bank.py +5 -2
- brynq_sdk_nmbrs/children.py +96 -61
- brynq_sdk_nmbrs/companies.py +45 -1
- brynq_sdk_nmbrs/debtors.py +76 -2
- brynq_sdk_nmbrs/department.py +113 -1
- brynq_sdk_nmbrs/document.py +50 -0
- brynq_sdk_nmbrs/employee_wage_tax_settings.py +16 -9
- brynq_sdk_nmbrs/function.py +128 -2
- brynq_sdk_nmbrs/leave.py +105 -8
- brynq_sdk_nmbrs/salaries.py +75 -3
- brynq_sdk_nmbrs/schedules.py +77 -3
- brynq_sdk_nmbrs/schemas/address.py +33 -4
- brynq_sdk_nmbrs/schemas/children.py +67 -0
- brynq_sdk_nmbrs/schemas/company.py +16 -0
- brynq_sdk_nmbrs/schemas/debtor.py +23 -1
- brynq_sdk_nmbrs/schemas/department.py +33 -0
- brynq_sdk_nmbrs/schemas/document.py +13 -0
- brynq_sdk_nmbrs/schemas/employees.py +3 -1
- brynq_sdk_nmbrs/schemas/function.py +28 -0
- brynq_sdk_nmbrs/schemas/leave.py +12 -0
- brynq_sdk_nmbrs/schemas/salary.py +18 -0
- brynq_sdk_nmbrs/schemas/schedules.py +81 -16
- brynq_sdk_nmbrs/schemas/social_insurance.py +39 -6
- brynq_sdk_nmbrs/schemas/wage_tax.py +65 -5
- brynq_sdk_nmbrs/schemas/wage_tax_settings.py +42 -29
- brynq_sdk_nmbrs/schemas/wagecomponents.py +66 -9
- brynq_sdk_nmbrs/social_insurance.py +81 -3
- brynq_sdk_nmbrs/wage_tax.py +104 -3
- brynq_sdk_nmbrs/wagecomponents.py +81 -45
- {brynq_sdk_nmbrs-2.3.1.dev0.dist-info → brynq_sdk_nmbrs-2.3.3.dev0.dist-info}/METADATA +1 -1
- brynq_sdk_nmbrs-2.3.3.dev0.dist-info/RECORD +55 -0
- {brynq_sdk_nmbrs-2.3.1.dev0.dist-info → brynq_sdk_nmbrs-2.3.3.dev0.dist-info}/WHEEL +1 -1
- brynq_sdk_nmbrs-2.3.1.dev0.dist-info/RECORD +0 -52
- {brynq_sdk_nmbrs-2.3.1.dev0.dist-info → brynq_sdk_nmbrs-2.3.3.dev0.dist-info}/top_level.txt +0 -0
|
@@ -1,14 +1,47 @@
|
|
|
1
|
-
import math
|
|
2
1
|
import pandas as pd
|
|
3
2
|
import pandera as pa
|
|
4
3
|
from pandera import Bool
|
|
5
|
-
from pandera.typing import Series, String,
|
|
6
|
-
import pandera.extensions as extensions
|
|
4
|
+
from pandera.typing import Series, String, DateTime
|
|
7
5
|
from brynq_sdk_functions import BrynQPanderaDataFrameModel
|
|
8
|
-
from typing import Optional
|
|
9
|
-
from pydantic import BaseModel, Field
|
|
10
|
-
from datetime import datetime
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from pydantic import BaseModel, Field
|
|
11
8
|
|
|
9
|
+
# ---------------------------
|
|
10
|
+
# Get Schemas
|
|
11
|
+
# ---------------------------
|
|
12
|
+
class SocialInsuranceGet(BrynQPanderaDataFrameModel):
|
|
13
|
+
employee_id: Series[String] = pa.Field(coerce=True, description="Employee ID", alias="employee_id")
|
|
14
|
+
id: Series[String] = pa.Field(coerce=True, description="SVW Settings ID", alias="Id")
|
|
15
|
+
creation_date: Series[DateTime] = pa.Field(coerce=True, nullable=True, description="Creation Date", alias="CreationDate")
|
|
16
|
+
start_period: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Start Period", alias="StartPeriod")
|
|
17
|
+
start_year: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Start Year", alias="StartYear")
|
|
18
|
+
influence_obliged_insurance: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Whether employee influences obligatory insurance status", alias="InfluenceObligedInsurance")
|
|
19
|
+
wage_cost_benefit: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Eligible for wage cost subsidy (LKV - Loonkostenvoordeel)", alias="WageCostBenefit")
|
|
20
|
+
cao: Series[String] = pa.Field(coerce=True, nullable=True, description="Collectieve Arbeidsovereenkomst (Collective Labor Agreement)", alias="CAO")
|
|
21
|
+
wao_wia: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Disability Insurance (WAO/WIA - Wet Arbeidsongeschiktheid)", alias="Wao_Wia")
|
|
22
|
+
ww: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Unemployment Insurance (WW - Werkloosheidswet)", alias="Ww")
|
|
23
|
+
zw: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Sickness Benefits (ZW - Ziektewet)", alias="Zw")
|
|
24
|
+
income_related_contribution_zvw: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Income Related Health Insurance Contribution (ZVW - Zorgverzekeringswet)", alias="IncomeRelatedContributionZvw")
|
|
25
|
+
code_zvw: Series[String] = pa.Field(coerce=True, nullable=True, description="Health Insurance Code (ZVW)", alias="CodeZvw")
|
|
26
|
+
risk_group: Series[String] = pa.Field(coerce=True, nullable=True, description="Risk Group for premium calculation", alias="RiskGroup")
|
|
27
|
+
sector: Series[String] = pa.Field(coerce=True, nullable=True, description="Industry Sector code", alias="Sector")
|
|
28
|
+
employment_type: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Employment Type", alias="EmploymentType")
|
|
29
|
+
phase_classification: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Phase Classification", alias="PhaseClassification")
|
|
30
|
+
employment_sequence_tax_id: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Employment Sequence Tax ID", alias="EmploymentSequenceTaxId")
|
|
31
|
+
|
|
32
|
+
class _Annotation:
|
|
33
|
+
primary_key = "id"
|
|
34
|
+
foreign_keys = {
|
|
35
|
+
"employee_id": {
|
|
36
|
+
"parent_schema": "EmployeeSchema",
|
|
37
|
+
"parent_column": "employee_id",
|
|
38
|
+
"cardinality": "N:1"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# ---------------------------
|
|
43
|
+
# Upload Schemas
|
|
44
|
+
# ---------------------------
|
|
12
45
|
class SocialInsuranceUpdate(BaseModel):
|
|
13
46
|
employee_id: int = Field(None, example="1234567890", description="Employee ID", alias="EmployeeId")
|
|
14
47
|
influence_obliged_insurance: Optional[bool] = Field(None, example="1234567890", description="Influence Obliged Insurance", alias="InfluenceObligedInsurance")
|
|
@@ -1,16 +1,76 @@
|
|
|
1
1
|
import math
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Annotated, Optional, Union
|
|
4
|
+
|
|
2
5
|
import pandas as pd
|
|
3
6
|
import pandera as pa
|
|
4
|
-
from pandera import Bool
|
|
5
|
-
from pandera.typing import Series, String, Float, DateTime
|
|
6
7
|
import pandera.extensions as extensions
|
|
7
|
-
from
|
|
8
|
-
from typing import
|
|
8
|
+
from pandera import Bool
|
|
9
|
+
from pandera.typing import DateTime, Float, Series, String
|
|
9
10
|
from pydantic import BaseModel, Field, StringConstraints
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
from brynq_sdk_functions import BrynQPanderaDataFrameModel
|
|
11
13
|
|
|
12
14
|
|
|
15
|
+
# ---------------------------
|
|
16
|
+
# REST API Get Schema (Wage Tax Settings History)
|
|
17
|
+
# ---------------------------
|
|
13
18
|
class WageTaxSettingsGet(BrynQPanderaDataFrameModel):
|
|
19
|
+
"""Schema for REST API: GET /companies/{companyId}/employees/wagetaxsettings"""
|
|
20
|
+
employee_id: Series[String] = pa.Field(coerce=True, description="Employee ID", alias="employeeId")
|
|
21
|
+
wage_tax_setting_id: Series[String] = pa.Field(coerce=True, description="Wage Tax Setting ID", alias="wageTaxSettingId")
|
|
22
|
+
start_date: Series[DateTime] = pa.Field(coerce=True, description="Start Date", alias="startDate")
|
|
23
|
+
created_at: Series[DateTime] = pa.Field(coerce=True, description="Created At", alias="createdAt")
|
|
24
|
+
payroll_tax_reduction: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Payroll Tax Reduction", alias="payrollTaxReduction")
|
|
25
|
+
type_of_income: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Type of Income", alias="typeOfIncome")
|
|
26
|
+
color_table: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Color Table", alias="colorTable")
|
|
27
|
+
period_table: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Period Table", alias="periodTable")
|
|
28
|
+
special_table: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Special Table", alias="specialTable")
|
|
29
|
+
payroll_tax: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Payroll Tax", alias="payrollTax")
|
|
30
|
+
benefit_scheme: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Benefit Scheme", alias="benefitScheme")
|
|
31
|
+
auto_small_jobs: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Auto Small Jobs Regulation", alias="autoSmallJobs")
|
|
32
|
+
yearly_salary: Series[pd.Float64Dtype] = pa.Field(coerce=True, nullable=True, description="Yearly Salary", alias="yearlySalary")
|
|
33
|
+
deviation_special_rate: Series[pd.Float64Dtype] = pa.Field(coerce=True, nullable=True, description="Deviation Special Rate Payroll Tax Deduction", alias="deviationSpecialRatePayrollTaxDeduction")
|
|
34
|
+
code_tax_reduction: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Code Tax Reduction", alias="codeTaxReduction")
|
|
35
|
+
holiday_vouchers: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Holiday Vouchers", alias="holidayVouchers")
|
|
36
|
+
code_30_percent_rule: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Code Calculate 30 Percent Rule", alias="codeCalculate30PercentRule")
|
|
37
|
+
|
|
38
|
+
class _Annotation:
|
|
39
|
+
primary_key = "wage_tax_setting_id"
|
|
40
|
+
foreign_keys = {
|
|
41
|
+
"employee_id": {
|
|
42
|
+
"parent_schema": "EmployeeSchema",
|
|
43
|
+
"parent_column": "employee_id",
|
|
44
|
+
"cardinality": "N:1"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class WageTaxSettingsCreate(BaseModel):
|
|
50
|
+
"""Schema for REST API: POST /employees/{employeeId}/wagetaxsetting"""
|
|
51
|
+
start_date: datetime = Field(..., example="2024-01-01T00:00:00Z", description="Start Date", alias="startDate")
|
|
52
|
+
payroll_tax_reduction: Optional[bool] = Field(None, example=True, description="Payroll Tax Reduction", alias="payrollTaxReduction")
|
|
53
|
+
type_of_income: Optional[int] = Field(None, example=15, description="Type of Income", alias="typeOfIncome")
|
|
54
|
+
color_table: Optional[int] = Field(None, example=1, description="Color Table", alias="colorTable")
|
|
55
|
+
period_table: Optional[int] = Field(None, example=2, description="Period Table", alias="periodTable")
|
|
56
|
+
special_table: Optional[int] = Field(None, example=0, description="Special Table", alias="specialTable")
|
|
57
|
+
payroll_tax: Optional[bool] = Field(None, example=True, description="Payroll Tax", alias="payrollTax")
|
|
58
|
+
benefit_scheme: Optional[bool] = Field(None, example=True, description="Benefit Scheme", alias="benefitScheme")
|
|
59
|
+
auto_small_jobs: Optional[bool] = Field(None, example=False, description="Auto Small Jobs Regulation", alias="autoSmallJobs")
|
|
60
|
+
yearly_salary: Optional[float] = Field(None, example=45000.00, description="Yearly Salary", alias="yearlySalary")
|
|
61
|
+
deviation_special_rate: Optional[float] = Field(None, example=0.0, description="Deviation Special Rate Payroll Tax Deduction", alias="deviationSpecialRatePayrollTaxDeduction")
|
|
62
|
+
code_tax_reduction: Optional[int] = Field(None, example=0, description="Code Tax Reduction", alias="codeTaxReduction")
|
|
63
|
+
holiday_vouchers: Optional[int] = Field(None, example=0, description="Holiday Vouchers", alias="holidayVouchers")
|
|
64
|
+
code_30_percent_rule: Optional[int] = Field(None, example=0, description="Code Calculate 30 Percent Rule", alias="codeCalculate30PercentRule")
|
|
65
|
+
|
|
66
|
+
class Config:
|
|
67
|
+
populate_by_name = True
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# ---------------------------
|
|
71
|
+
# SOAP API Get Schema (Company Wage Tax List)
|
|
72
|
+
# ---------------------------
|
|
73
|
+
class CompanyWageTaxGet(BrynQPanderaDataFrameModel):
|
|
14
74
|
wagetax_id: Series[pd.Int64Dtype] = pa.Field(coerce=True, description="Loonaangifte ID", alias="LoonaangifteID")
|
|
15
75
|
serial_number: Series[pd.Int64Dtype] = pa.Field(coerce=True, description="Serial Number", alias="SerialNumber")
|
|
16
76
|
payment_reference: Series[String] = pa.Field(coerce=True, description="Payment Reference", alias="PaymentReference")
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
1
|
from typing import Optional
|
|
3
2
|
|
|
4
3
|
import pandas as pd
|
|
5
4
|
import pandera as pa
|
|
6
5
|
from pandera import Bool
|
|
7
6
|
from pandera.typing import DateTime, Float, Series, String
|
|
8
|
-
from pydantic import BaseModel, Field
|
|
7
|
+
from pydantic import BaseModel, Field, model_serializer
|
|
9
8
|
|
|
10
9
|
from brynq_sdk_functions import BrynQPanderaDataFrameModel
|
|
11
10
|
|
|
@@ -14,23 +13,23 @@ from brynq_sdk_functions import BrynQPanderaDataFrameModel
|
|
|
14
13
|
# Get Schemas
|
|
15
14
|
# ---------------------------
|
|
16
15
|
class EmployeeWageTaxSettingsGet(BrynQPanderaDataFrameModel):
|
|
17
|
-
employee_id: Series[String] = pa.Field(coerce=True, description="Employee
|
|
18
|
-
wage_tax_settings_id: Series[String] = pa.Field(coerce=True, description="Wage Tax Settings ID", alias="
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
employee_id: Series[String] = pa.Field(coerce=True, description="Employee unique identifier", alias="employeeId")
|
|
17
|
+
wage_tax_settings_id: Series[String] = pa.Field(coerce=True, description="Wage Tax Settings ID", alias="wageTaxSettingsId")
|
|
18
|
+
wage_tax: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Wage Tax", alias="wageTax")
|
|
19
|
+
wage_tax_rebate: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Loonheffingskorting", alias="wageTaxRebate")
|
|
20
|
+
single_elderly_discount: Series[Bool] = pa.Field(coerce=True, nullable=True, description="Single Elderly Discount", alias="singleElderlyDiscount")
|
|
21
|
+
color_table: Series[String] = pa.Field(coerce=True, nullable=True, description="List of available color table values for wage tax settings", alias="colorTable")
|
|
22
|
+
period_table: Series[String] = pa.Field(coerce=True, nullable=True, description="List of available period table values for wage tax settings", alias="periodTable")
|
|
23
|
+
income_type: Series[String] = pa.Field(coerce=True, nullable=True, description="Income Type", alias="incomeType")
|
|
24
|
+
special_annual_salary_rate: Series[Float] = pa.Field(coerce=True, nullable=True, description="Loonheffing BT", alias="specialAnnualSalaryRate")
|
|
25
|
+
special_table: Series[String] = pa.Field(coerce=True, nullable=True, description="Special Table", alias="specialTable")
|
|
26
|
+
different_special_rate: Series[String] = pa.Field(coerce=True, nullable=True, description="Afwijkend Bijzonder tarief %", alias="differentSpecialRate")
|
|
27
|
+
calc_30_percent_ruling: Series[String] = pa.Field(coerce=True, nullable=True, description="List of available 30 Percent Ruling Calculation types", alias="Calc30PercentRuling.Cal30PercentRuling")
|
|
28
|
+
calc_30_percent_ruling_end_period: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="30 Percent Ruling End Period", alias="Calc30PercentRuling.endPeriod")
|
|
29
|
+
calc_30_percent_ruling_end_year: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="30 Percent Ruling End Year", alias="Calc30PercentRuling.endYear")
|
|
30
|
+
period_year: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Period Year", alias="period.year")
|
|
31
|
+
period_period: Series[pd.Int64Dtype] = pa.Field(coerce=True, nullable=True, description="Period Period", alias="period.period")
|
|
32
|
+
created_at: Series[DateTime] = pa.Field(coerce=True, nullable=True, description="Created At", alias="createdAt")
|
|
34
33
|
|
|
35
34
|
class _Annotation:
|
|
36
35
|
primary_key = "wage_tax_settings_id"
|
|
@@ -49,15 +48,29 @@ class Period(BaseModel):
|
|
|
49
48
|
period_year: int = Field(..., ge=1900, le=2100, example=2021, description="Year", alias="year")
|
|
50
49
|
period_period: int = Field(..., ge=1, le=53, example=4, description="Period", alias="period")
|
|
51
50
|
|
|
51
|
+
class Calc30PercentRuling(BaseModel):
|
|
52
|
+
cal_30_percent_ruling: Optional[str] = Field(None, example="None", description="List of available 30 Percent Ruling Calculation types", alias="Cal30PercentRuling")
|
|
53
|
+
end_period: Optional[int] = Field(None, example=8, description="30 Percent Ruling End Period", alias="endPeriod")
|
|
54
|
+
end_year: Optional[int] = Field(None, example=2025, description="30 Percent Ruling End Year", alias="endYear")
|
|
55
|
+
|
|
52
56
|
class EmployeeWageTaxSettingsCreate(BaseModel):
|
|
53
|
-
wage_tax:
|
|
54
|
-
wage_tax_rebate:
|
|
55
|
-
single_elderly_discount:
|
|
56
|
-
color_table:
|
|
57
|
-
period_table:
|
|
58
|
-
income_type:
|
|
59
|
-
special_annual_salary_rate: Optional[float] = Field(None, ge=0, example=
|
|
60
|
-
special_table:
|
|
61
|
-
different_special_rate: Optional[float] = Field(None, example=0.0, description="
|
|
62
|
-
calc_30_percent_ruling: Optional[
|
|
57
|
+
wage_tax: bool = Field(..., example=True, description="Wage Tax", alias="wageTax")
|
|
58
|
+
wage_tax_rebate: bool = Field(..., example=True, description="Loonheffingskorting", alias="wageTaxRebate")
|
|
59
|
+
single_elderly_discount: bool = Field(..., example=True, description="Single Elderly Discount", alias="singleElderlyDiscount")
|
|
60
|
+
color_table: str = Field(..., example="White", description="List of available color table values for wage tax settings", alias="colorTable")
|
|
61
|
+
period_table: str = Field(..., example="Month", description="List of available period table values for wage tax settings", alias="periodTable")
|
|
62
|
+
income_type: str = Field(..., description="Income Type", alias="incomeType")
|
|
63
|
+
special_annual_salary_rate: Optional[float] = Field(None, ge=0, example=32000.0, description="Loonheffing BT", alias="specialAnnualSalaryRate")
|
|
64
|
+
special_table: str = Field(..., description="Special Table", alias="specialTable")
|
|
65
|
+
different_special_rate: Optional[float] = Field(None, example=0.0, description="Afwijkend Bijzonder tarief %", alias="differentSpecialRate")
|
|
66
|
+
calc_30_percent_ruling: Optional[Calc30PercentRuling] = Field(None, description="Calc 30 percent ruling", alias="Calc30PercentRuling")
|
|
63
67
|
period: Period = Field(..., description="Period", alias="period")
|
|
68
|
+
|
|
69
|
+
@model_serializer(mode='wrap')
|
|
70
|
+
def serialize_model(self, serializer, info):
|
|
71
|
+
data = serializer(self)
|
|
72
|
+
# Exclude Calc30PercentRuling if it exists but all its nested fields are None
|
|
73
|
+
if 'Calc30PercentRuling' in data and data['Calc30PercentRuling'] is not None:
|
|
74
|
+
if isinstance(data['Calc30PercentRuling'], dict) and all(v is None for v in data['Calc30PercentRuling'].values()):
|
|
75
|
+
data.pop('Calc30PercentRuling')
|
|
76
|
+
return data
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import math
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
2
4
|
import pandas as pd
|
|
3
5
|
import pandera as pa
|
|
4
|
-
from pandera.typing import Series, String
|
|
5
|
-
from
|
|
6
|
+
from pandera.typing import Float, Series, String
|
|
7
|
+
from pydantic import (
|
|
8
|
+
BaseModel,
|
|
9
|
+
Field,
|
|
10
|
+
confloat,
|
|
11
|
+
conint,
|
|
12
|
+
field_validator,
|
|
13
|
+
model_serializer,
|
|
14
|
+
)
|
|
6
15
|
|
|
7
|
-
from
|
|
8
|
-
from pydantic import BaseModel, Field, conint, confloat
|
|
16
|
+
from brynq_sdk_functions import BrynQPanderaDataFrameModel
|
|
9
17
|
|
|
10
18
|
|
|
11
19
|
# ---------------------------
|
|
@@ -61,8 +69,8 @@ class VariableWageComponentGet(BrynQPanderaDataFrameModel):
|
|
|
61
69
|
# Upload Schemas
|
|
62
70
|
# ---------------------------
|
|
63
71
|
class PeriodPost(BaseModel):
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
period_details_year: int = Field(..., ge=1900, le=2100, example=2021, description="Year", alias="year")
|
|
73
|
+
period_details_period: int = Field(..., ge=1, le=53, example=4, description="Period", alias="period")
|
|
66
74
|
|
|
67
75
|
class FixedWageComponentCreate(BaseModel):
|
|
68
76
|
code: int = Field(..., ge=1, example=1100, description="Wage Component Code", alias="code")
|
|
@@ -72,9 +80,36 @@ class FixedWageComponentCreate(BaseModel):
|
|
|
72
80
|
comment: Optional[str] = Field(None, example="some comment", description="Comment", alias="comment")
|
|
73
81
|
cost_center_id: Optional[str] = Field(None, example="aa506564-d1db-4fa8-83dc-d68db4cfcd82", description="Cost Center ID", alias="costCenterId")
|
|
74
82
|
cost_unit_id: Optional[str] = Field(None, example="d8ac6afb-2ac6-43bf-9880-2d382cdace43", description="Cost Unit ID", alias="costUnitId")
|
|
75
|
-
period_details: PeriodPost
|
|
83
|
+
period_details: Optional[PeriodPost] = Field(None, description="Period Details", alias="periodDetails")
|
|
76
84
|
unprotected_mode: Optional[bool] = Field(None, example=True, description="Unprotected Mode", alias="unprotectedMode")
|
|
77
85
|
|
|
86
|
+
@field_validator("end_year", "end_period", mode="before")
|
|
87
|
+
@classmethod
|
|
88
|
+
def empty_str_to_none(cls, v):
|
|
89
|
+
"""Convert empty strings to None for optional integer fields"""
|
|
90
|
+
if v == "" or v is None:
|
|
91
|
+
return None
|
|
92
|
+
return v
|
|
93
|
+
|
|
94
|
+
@field_validator("period_details", mode="before")
|
|
95
|
+
@classmethod
|
|
96
|
+
def empty_dict_to_none(cls, v):
|
|
97
|
+
"""Convert empty dicts to None for period_details"""
|
|
98
|
+
if isinstance(v, dict) and (not v or all(val is None for val in v.values())):
|
|
99
|
+
return None
|
|
100
|
+
return v
|
|
101
|
+
|
|
102
|
+
@model_serializer(mode='wrap')
|
|
103
|
+
def serialize_model(self, serializer, info):
|
|
104
|
+
data = serializer(self)
|
|
105
|
+
# Exclude periodDetails if it exists but is None or all its nested fields are None
|
|
106
|
+
if 'periodDetails' in data and data['periodDetails'] is not None:
|
|
107
|
+
if isinstance(data['periodDetails'], dict) and all(v is None for v in data['periodDetails'].values()):
|
|
108
|
+
data.pop('periodDetails')
|
|
109
|
+
elif 'periodDetails' in data and data['periodDetails'] is None:
|
|
110
|
+
data.pop('periodDetails')
|
|
111
|
+
return data
|
|
112
|
+
|
|
78
113
|
class FixedWageComponentUpdate(BaseModel):
|
|
79
114
|
fixed_wage_component_id: str = Field(..., example="643c6b90-57c6-4199-9e4e-ded553572d78", description="Fixed Wage Component ID", alias="fixedWageComponentId")
|
|
80
115
|
code: Optional[int] = Field(None, ge=1, example=1100, description="Wage Component Code", alias="code")
|
|
@@ -93,9 +128,28 @@ class VariableWageComponentCreate(BaseModel):
|
|
|
93
128
|
comment: Optional[str] = Field(None, example="comment", description="Comment", alias="comment")
|
|
94
129
|
cost_center_id: Optional[str] = Field(None, example="aa506564-d1db-4fa8-83dc-d68db4cfcd82", description="Cost Center ID", alias="costCenterId")
|
|
95
130
|
cost_unit_id: Optional[str] = Field(None, example="d8ac6afb-2ac6-43bf-9880-2d382cdace43", description="Cost Unit ID", alias="costUnitId")
|
|
96
|
-
period_details: PeriodPost
|
|
131
|
+
period_details: Optional[PeriodPost] = Field(None, description="Period Details", alias="periodDetails")
|
|
97
132
|
unprotected_mode: Optional[bool] = Field(None, example=True, description="Unprotected Mode", alias="unprotectedMode")
|
|
98
133
|
|
|
134
|
+
@field_validator("period_details", mode="before")
|
|
135
|
+
@classmethod
|
|
136
|
+
def empty_dict_to_none(cls, v):
|
|
137
|
+
"""Convert empty dicts to None for period_details"""
|
|
138
|
+
if isinstance(v, dict) and (not v or all(val is None for val in v.values())):
|
|
139
|
+
return None
|
|
140
|
+
return v
|
|
141
|
+
|
|
142
|
+
@model_serializer(mode='wrap')
|
|
143
|
+
def serialize_model(self, serializer, info):
|
|
144
|
+
data = serializer(self)
|
|
145
|
+
# Exclude periodDetails if it exists but is None or all its nested fields are None
|
|
146
|
+
if 'periodDetails' in data and data['periodDetails'] is not None:
|
|
147
|
+
if isinstance(data['periodDetails'], dict) and all(v is None for v in data['periodDetails'].values()):
|
|
148
|
+
data.pop('periodDetails')
|
|
149
|
+
elif 'periodDetails' in data and data['periodDetails'] is None:
|
|
150
|
+
data.pop('periodDetails')
|
|
151
|
+
return data
|
|
152
|
+
|
|
99
153
|
class VariableWageComponentUpdate(BaseModel):
|
|
100
154
|
variable_wage_component_id: str = Field(..., example="7fc59095-daed-4746-a7f8-a454e38e3683", description="Variable Wage Component ID", alias="variableWageComponentId")
|
|
101
155
|
code: Optional[int] = Field(None, ge=1, example=3045, description="Wage Component Code", alias="code")
|
|
@@ -107,4 +161,7 @@ class VariableWageComponentUpdate(BaseModel):
|
|
|
107
161
|
unprotected_mode: Optional[bool] = Field(None, example=True, description="Unprotected Mode", alias="unprotectedMode")
|
|
108
162
|
|
|
109
163
|
class WageComponentDelete(BaseModel):
|
|
110
|
-
|
|
164
|
+
fixed_wage_component_id: str = Field(..., example="7fc59095-daed-4746-a7f8-a454e38e3683", description="Wage Component ID", alias="wageComponentId")
|
|
165
|
+
|
|
166
|
+
class Config:
|
|
167
|
+
populate_by_name = True
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
from typing import Any, Dict,
|
|
1
|
+
from typing import Any, Dict, Union, Tuple
|
|
2
2
|
import pandas as pd
|
|
3
3
|
|
|
4
|
-
from .schemas.social_insurance import SocialInsuranceUpdate
|
|
4
|
+
from .schemas.social_insurance import SocialInsuranceUpdate, SocialInsuranceGet
|
|
5
5
|
from zeep.exceptions import Fault
|
|
6
6
|
from zeep.helpers import serialize_object
|
|
7
|
-
# import logging
|
|
8
7
|
from brynq_sdk_functions import Functions
|
|
9
8
|
|
|
10
9
|
|
|
@@ -13,6 +12,85 @@ class SocialInsurance:
|
|
|
13
12
|
self.nmbrs = nmbrs
|
|
14
13
|
self.soap_client_employees = nmbrs.soap_client_employees
|
|
15
14
|
|
|
15
|
+
def get(self, employee_id: Union[int, str]) -> Tuple[pd.DataFrame, pd.DataFrame]:
|
|
16
|
+
"""
|
|
17
|
+
Get current social insurance settings for an employee.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
employee_id: The ID of the employee
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
Tuple of (valid_data, invalid_data) DataFrames
|
|
24
|
+
"""
|
|
25
|
+
if self.nmbrs.mock_mode:
|
|
26
|
+
return pd.DataFrame(), pd.DataFrame()
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
response = self.nmbrs.soap_client_employees.service.SVW_GetCurrent(
|
|
30
|
+
EmployeeId=int(employee_id),
|
|
31
|
+
_soapheaders={'AuthHeaderWithDomain': self.nmbrs.soap_auth_header_employees}
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if response:
|
|
35
|
+
serialized_response = serialize_object(response)
|
|
36
|
+
if not isinstance(serialized_response, list):
|
|
37
|
+
serialized_response = [serialized_response]
|
|
38
|
+
df = pd.DataFrame(serialized_response)
|
|
39
|
+
df['employee_id'] = str(employee_id)
|
|
40
|
+
|
|
41
|
+
valid_data, invalid_data = Functions.validate_data(df=df, schema=SocialInsuranceGet, debug=True)
|
|
42
|
+
return valid_data, invalid_data
|
|
43
|
+
else:
|
|
44
|
+
return pd.DataFrame(), pd.DataFrame()
|
|
45
|
+
|
|
46
|
+
except Fault as e:
|
|
47
|
+
raise Exception(f"SOAP request failed: {str(e)}")
|
|
48
|
+
except Exception as e:
|
|
49
|
+
raise Exception(f"Failed to get Social Insurance: {str(e)}")
|
|
50
|
+
|
|
51
|
+
def get_all_by_company(self, company_id: Union[int, str]) -> Tuple[pd.DataFrame, pd.DataFrame]:
|
|
52
|
+
"""
|
|
53
|
+
Get all social insurance settings for all employees in a company.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
company_id: The ID of the company
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
Tuple of (valid_data, invalid_data) DataFrames
|
|
60
|
+
"""
|
|
61
|
+
if self.nmbrs.mock_mode:
|
|
62
|
+
return pd.DataFrame(), pd.DataFrame()
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
response = self.nmbrs.soap_client_employees.service.SVW_GetAll_AllEmployeesByCompany(
|
|
66
|
+
CompanyID=int(company_id),
|
|
67
|
+
_soapheaders={'AuthHeaderWithDomain': self.nmbrs.soap_auth_header_employees}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if response:
|
|
71
|
+
all_data = []
|
|
72
|
+
for emp in response:
|
|
73
|
+
emp_id = emp.EmployeeId
|
|
74
|
+
if emp.EmployeeSVWSettings and emp.EmployeeSVWSettings.EmployeeSVWSettings:
|
|
75
|
+
for svw in emp.EmployeeSVWSettings.EmployeeSVWSettings:
|
|
76
|
+
svw_data = serialize_object(svw)
|
|
77
|
+
svw_data['employee_id'] = str(emp_id)
|
|
78
|
+
all_data.append(svw_data)
|
|
79
|
+
|
|
80
|
+
if all_data:
|
|
81
|
+
df = pd.DataFrame(all_data)
|
|
82
|
+
valid_data, invalid_data = Functions.validate_data(df=df, schema=SocialInsuranceGet, debug=True)
|
|
83
|
+
return valid_data, invalid_data
|
|
84
|
+
else:
|
|
85
|
+
return pd.DataFrame(), pd.DataFrame()
|
|
86
|
+
else:
|
|
87
|
+
return pd.DataFrame(), pd.DataFrame()
|
|
88
|
+
|
|
89
|
+
except Fault as e:
|
|
90
|
+
raise Exception(f"SOAP request failed: {str(e)}")
|
|
91
|
+
except Exception as e:
|
|
92
|
+
raise Exception(f"Failed to get Social Insurance for company: {str(e)}")
|
|
93
|
+
|
|
16
94
|
def update(self, data: Dict[str, Any]) -> pd.DataFrame:
|
|
17
95
|
try:
|
|
18
96
|
social_insurance_model = SocialInsuranceUpdate(**data)
|
brynq_sdk_nmbrs/wage_tax.py
CHANGED
|
@@ -1,14 +1,115 @@
|
|
|
1
1
|
from typing import Any, Dict, List, Union, Tuple
|
|
2
2
|
import pandas as pd
|
|
3
|
-
|
|
3
|
+
import requests
|
|
4
|
+
from .schemas.wage_tax import (
|
|
5
|
+
WageTaxGet, WageTaxUpdate, CompanyWageTaxGet,
|
|
6
|
+
WageTaxSettingsGet, WageTaxSettingsCreate
|
|
7
|
+
)
|
|
4
8
|
from zeep.exceptions import Fault
|
|
5
9
|
from zeep.ns import WSDL, SOAP_ENV_11
|
|
6
10
|
from zeep.xsd import ComplexType, Element, String
|
|
7
11
|
from zeep.helpers import serialize_object
|
|
8
|
-
# import logging
|
|
9
12
|
from brynq_sdk_functions import Functions
|
|
10
13
|
|
|
11
14
|
|
|
15
|
+
class WageTaxSettings:
|
|
16
|
+
"""Wage Tax Settings History - uses REST API."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, nmbrs):
|
|
19
|
+
self.nmbrs = nmbrs
|
|
20
|
+
|
|
21
|
+
def get(self,
|
|
22
|
+
created_from: str = None,
|
|
23
|
+
employee_id: str = None) -> Tuple[pd.DataFrame, pd.DataFrame]:
|
|
24
|
+
"""
|
|
25
|
+
Get wage tax settings history for all employees across all companies.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
created_from: Optional filter to get settings created from a specific date (ISO format)
|
|
29
|
+
employee_id: Optional filter to get settings for a specific employee
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
Tuple of (valid_settings, invalid_settings) DataFrames
|
|
33
|
+
"""
|
|
34
|
+
wage_tax_settings = pd.DataFrame()
|
|
35
|
+
for company in self.nmbrs.company_ids:
|
|
36
|
+
wage_tax_settings = pd.concat([wage_tax_settings, self._get(company, created_from, employee_id)])
|
|
37
|
+
|
|
38
|
+
valid_settings, invalid_settings = Functions.validate_data(
|
|
39
|
+
df=wage_tax_settings,
|
|
40
|
+
schema=WageTaxSettingsGet,
|
|
41
|
+
debug=True
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return valid_settings, invalid_settings
|
|
45
|
+
|
|
46
|
+
def _get(self,
|
|
47
|
+
company_id: str,
|
|
48
|
+
created_from: str = None,
|
|
49
|
+
employee_id: str = None) -> pd.DataFrame:
|
|
50
|
+
"""
|
|
51
|
+
Get wage tax settings history for a specific company.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
company_id: The ID of the company
|
|
55
|
+
created_from: Optional filter to get settings created from a specific date
|
|
56
|
+
employee_id: Optional filter to get settings for a specific employee
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
DataFrame containing wage tax settings history
|
|
60
|
+
"""
|
|
61
|
+
params = {}
|
|
62
|
+
if created_from:
|
|
63
|
+
params['createdFrom'] = created_from
|
|
64
|
+
if employee_id:
|
|
65
|
+
params['employeeId'] = employee_id
|
|
66
|
+
|
|
67
|
+
request = requests.Request(
|
|
68
|
+
method='GET',
|
|
69
|
+
url=f"{self.nmbrs.base_url}companies/{company_id}/employees/wagetaxsettings",
|
|
70
|
+
params=params
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
data = self.nmbrs.get_paginated_result(request)
|
|
74
|
+
df = pd.json_normalize(
|
|
75
|
+
data,
|
|
76
|
+
record_path='wageTaxSettings',
|
|
77
|
+
meta=['employeeId']
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
return df
|
|
81
|
+
|
|
82
|
+
def create(self, employee_id: str, data: Dict[str, Any]):
|
|
83
|
+
"""
|
|
84
|
+
Create a new wage tax setting for an employee using Pydantic validation.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
employee_id: The ID of the employee
|
|
88
|
+
data: Dictionary containing wage tax settings data with fields matching
|
|
89
|
+
the EmployeeWageTaxSettingsCreate schema (using camelCase field names)
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Response from the API
|
|
93
|
+
"""
|
|
94
|
+
# Validate with Pydantic model
|
|
95
|
+
nested_data = self.nmbrs.flat_dict_to_nested_dict(data, WageTaxSettingsCreate)
|
|
96
|
+
wage_tax_model = WageTaxSettingsCreate(**nested_data)
|
|
97
|
+
|
|
98
|
+
if self.nmbrs.mock_mode:
|
|
99
|
+
return wage_tax_model
|
|
100
|
+
|
|
101
|
+
# Convert validated model to dict for API payload
|
|
102
|
+
payload = wage_tax_model.model_dump(exclude_none=True, by_alias=True)
|
|
103
|
+
|
|
104
|
+
# Send request
|
|
105
|
+
resp = self.nmbrs.session.post(
|
|
106
|
+
url=f"{self.nmbrs.base_url}employees/{employee_id}/wagetaxsetting",
|
|
107
|
+
json=payload,
|
|
108
|
+
timeout=self.nmbrs.timeout
|
|
109
|
+
)
|
|
110
|
+
return resp
|
|
111
|
+
|
|
112
|
+
|
|
12
113
|
class WageTax:
|
|
13
114
|
def __init__(self, nmbrs):
|
|
14
115
|
self.nmbrs = nmbrs
|
|
@@ -33,7 +134,7 @@ class WageTax:
|
|
|
33
134
|
wagetax_settings_temp['companyId'] = company['number']
|
|
34
135
|
wagetax_settings = pd.concat([wagetax_settings, wagetax_settings_temp])
|
|
35
136
|
|
|
36
|
-
valid_wagetax_settings, invalid_wagetax_settings = Functions.validate_data(df=wagetax_settings, schema=
|
|
137
|
+
valid_wagetax_settings, invalid_wagetax_settings = Functions.validate_data(df=wagetax_settings, schema=CompanyWageTaxGet, debug=True)
|
|
37
138
|
|
|
38
139
|
# No validation schema for now, but could be added later
|
|
39
140
|
return valid_wagetax_settings, invalid_wagetax_settings
|