Server backup 2026-11-07 of uncommitted work in projects/pharma-web-celtic

Snapshot of the working tree on srv1071960 (branch main), taken during
server cleanup. .env files, node_modules, builds, logs and media were excluded.
This commit is contained in:
Shubhankar45
2026-11-07 05:43:12 +00:00
parent b001e2d03c
commit 0d30c58bf0
98 changed files with 1878 additions and 573 deletions
+35 -6
View File
@@ -80,7 +80,7 @@ FORMS: dict[str, FormSpec] = {
Col("From", "from_location", 25.0),
Col("To", "to_location", 23.2),
Col("POB", "pob", 15.3, "center"),
Col("Stockiest Visit", "stockiest_visit", 15.2, "center"),
Col("Stockist Visit", "stockiest_visit", 15.2, "center"),
),
serial_field="serial_no",
serial_dot=True,
@@ -231,6 +231,17 @@ _PLAN_CHEMIST_COLS = (
Col("NAME OF THE CHEMIST", "chemist_name", 52.8),
Col("PLANNED TIME", "planned_time", 37.0, "center"),
)
# Stockist visits: printed only when the report has any, so other reports keep their layout.
_STOCKIST_COLS = (
_serial("SR. NO.", 10.2),
Col("NAME OF THE STOCKIST", "stockist_name", 32.8),
Col("POB", "pob", 57.0),
)
_PLAN_STOCKIST_COLS = (
_serial("SR. NO.", 10.2),
Col("NAME OF THE STOCKIST", "stockist_name", 52.8),
Col("PLANNED TIME", "planned_time", 37.0, "center"),
)
# End-of-day report: the planned visits that were not made, and why.
_MISSED_COLS = (
_serial("SR. NO.", 8.6),
@@ -576,13 +587,14 @@ def build_dcr_context(
chemist_calls,
approval: dict[str, str] | None = None,
missed: list[Row] | None = None,
stockist_calls=(),
) -> dict[str, object]:
"""The approved Daily Call Report, laid out exactly like the printed company form.
Same template family, headings, column widths and number of ruled lines as the
``daily_call_report_csv`` company form: 10 doctor lines and 5 chemist lines, filled
from the top in visit order; more visits simply continue on the next page. The only
additions are the signatures: the MR's name, and (once approved) the Area Manager's
additions are the signatures: the MR's name, and (once approved) the Area Business Manager's
approval signature with its date and time.
A morning day plan uses the same form with a PLANNED TIME column in place of the
@@ -592,8 +604,8 @@ def build_dcr_context(
report_type = getattr(dcr, "report_type", None)
report_type = getattr(report_type, "value", report_type)
if report_type == "PLAN":
return _build_plan_context(dcr, doctor_calls, chemist_calls, approval)
is_self = report_type == "SELF" # an Area Manager's own report: no approval signature
return _build_plan_context(dcr, doctor_calls, chemist_calls, approval, stockist_calls)
is_self = report_type == "SELF" # an Area Business Manager's own report: no approval signature
doctors = [
{
"doctor_name": c.doctor.name,
@@ -605,6 +617,7 @@ def build_dcr_context(
for c in doctor_calls
]
chemists = [{"chemist_name": c.chemist.name, "pob": c.pob or ""} for c in chemist_calls]
stockists = [{"stockist_name": c.stockist.name, "pob": c.pob or ""} for c in stockist_calls]
meta = [
[("NAME:", dcr.mr.full_name), ("Date:", dcr.report_date.strftime("%d/%m/%Y"))],
[("HEADQUARTER:", dcr.headquarters.name), ("Month:", dcr.report_date.strftime("%B %Y"))],
@@ -619,12 +632,17 @@ def build_dcr_context(
"grids": {
"doctors": _grid(_DOCTOR_COLS, doctors, min_rows=10),
"chemists": _grid(_CHEMIST_COLS, chemists, min_rows=5, table_width=84),
**(
{"stockists": _grid(_STOCKIST_COLS, stockists, min_rows=0, table_width=84)}
if stockists
else {}
),
**({"missed": _grid(_MISSED_COLS, missed, min_rows=0)} if missed else {}),
},
"is_plan": False,
"stockist_visit": dcr.stockist_visit or "",
"order_value": dcr.order_value or "",
"signer_label": "Area Manager Signature" if is_self else "MR Signature",
"signer_label": "Area Business Manager Signature" if is_self else "MR Signature",
"mr_signed": f"{dcr.mr.full_name} ({dcr.mr.employee_code})",
"approval": approval, # {"name": ..., "at": "dd/mm/yyyy HH:MM"} or None
}
@@ -635,7 +653,9 @@ def _products(names: list[str] | str | None) -> str:
return names if isinstance(names, str) else ", ".join(names or [])
def _build_plan_context(dcr, doctor_calls, chemist_calls, approval) -> dict[str, object]:
def _build_plan_context(
dcr, doctor_calls, chemist_calls, approval, stockist_calls=()
) -> dict[str, object]:
doctors = [
{
"doctor_name": c.doctor.name,
@@ -649,6 +669,10 @@ def _build_plan_context(dcr, doctor_calls, chemist_calls, approval) -> dict[str,
{"chemist_name": c.chemist.name, "planned_time": c.visit_time.strftime("%H:%M")}
for c in chemist_calls
]
stockists = [
{"stockist_name": c.stockist.name, "planned_time": c.visit_time.strftime("%H:%M")}
for c in stockist_calls
]
meta = [
[("NAME:", dcr.mr.full_name), ("Date:", dcr.report_date.strftime("%d/%m/%Y"))],
[("HEADQUARTER:", dcr.headquarters.name), ("Month:", dcr.report_date.strftime("%B %Y"))],
@@ -663,6 +687,11 @@ def _build_plan_context(dcr, doctor_calls, chemist_calls, approval) -> dict[str,
"grids": {
"doctors": _grid(_PLAN_DOCTOR_COLS, doctors, min_rows=10),
"chemists": _grid(_PLAN_CHEMIST_COLS, chemists, min_rows=5, table_width=84),
**(
{"stockists": _grid(_PLAN_STOCKIST_COLS, stockists, min_rows=0, table_width=84)}
if stockists
else {}
),
},
"is_plan": True,
"stockist_visit": "",