update
This commit is contained in:
parent
233713db59
commit
ce93879fe9
|
|
@ -4,6 +4,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
from calendar import monthrange
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal, InvalidOperation
|
from decimal import Decimal, InvalidOperation
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
@ -201,6 +202,17 @@ class SyncEhrLeavesToOaMonthJob(BaseJob):
|
||||||
raise ValueError("public_cfg.oa_login_name is required")
|
raise ValueError("public_cfg.oa_login_name is required")
|
||||||
|
|
||||||
oa_template_code = str(params.get("oa_template_code") or oa_form_code).strip()
|
oa_template_code = str(params.get("oa_template_code") or oa_form_code).strip()
|
||||||
|
sync_month = str(params.get("sync_month") or "").strip()
|
||||||
|
if sync_month:
|
||||||
|
if not re.match(r"^\d{4}-\d{2}$", sync_month):
|
||||||
|
raise ValueError("public_cfg.sync_month must be in format YYYY-MM, e.g. 2022-02")
|
||||||
|
year = int(sync_month[:4])
|
||||||
|
month = int(sync_month[5:7])
|
||||||
|
if month < 1 or month > 12:
|
||||||
|
raise ValueError("public_cfg.sync_month month must be in range 01-12")
|
||||||
|
month_start = date(year, month, 1)
|
||||||
|
month_end = date(year, month, monthrange(year, month)[1])
|
||||||
|
else:
|
||||||
run_date = _to_date(params.get("run_date"))
|
run_date = _to_date(params.get("run_date"))
|
||||||
month_start = run_date.replace(day=1)
|
month_start = run_date.replace(day=1)
|
||||||
month_end = run_date
|
month_end = run_date
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue