--
This commit is contained in:
@@ -45,8 +45,8 @@ def test_identity_is_gathered_from_all_rows_not_just_the_first():
|
||||
PRINTED_HEADERS = {
|
||||
"tour_plan": ["Sl.No.", "Date", "From", "To", "POB", "Stockiest Visit"],
|
||||
"standard_tour_plan": ["Sl.No.", "PLACE"],
|
||||
"fare_chart": ["Sl.No.", "Date", "From", "To", "Kilometers (KM)"],
|
||||
"area_covered": ["SALE STATUS", "AREA TO COVER", "SALE OBJECTIVE", "STATUS"],
|
||||
"fare_chart": ["Sl.No.", "Date", "From", "To", "Kilometers (KM)\n(One Way)"],
|
||||
"area_covered": ["AREA TO COVER", "SALE OBJECTIVE", "STATUS"],
|
||||
"core_dr_call_conversion": ["DOCTOR NAME", "DATE OF VISIT", "PRODUCT TARGETED", "STATUS"],
|
||||
"field_activity_report": [
|
||||
"DATE",
|
||||
@@ -57,21 +57,19 @@ PRINTED_HEADERS = {
|
||||
"sales_and_stock_statement": [
|
||||
"Sl.No.",
|
||||
"Name of the Product",
|
||||
"Value in PTS",
|
||||
"Opening",
|
||||
"Receipt",
|
||||
"Sale",
|
||||
"Closing",
|
||||
"Value in PTS",
|
||||
],
|
||||
"sales_projection": [
|
||||
"SL. No.",
|
||||
"NAME OF THE PRODUCT",
|
||||
"PTS",
|
||||
"SEC. QTY",
|
||||
"QUANTITY",
|
||||
"VALUE",
|
||||
"CLOSING",
|
||||
"SEC. VALUE",
|
||||
"SALES",
|
||||
"QUANTITY",
|
||||
"VALUE",
|
||||
],
|
||||
}
|
||||
@@ -120,10 +118,10 @@ def test_blank_lines_carry_on_numbering_and_tour_plan_numbers_have_a_dot():
|
||||
def test_product_lists_print_in_their_own_columns():
|
||||
rows = _rows("sales_projection", 2)
|
||||
rows[0].update(product_name="INTEZOLE-PD", pts="106.92")
|
||||
rows[1].update(product_name="INTEZOLE-RD", pts="93.59", secondary_qty="4")
|
||||
rows[1].update(product_name="INTEZOLE-RD", pts="93.59", closing_qty="4", projection_value="250")
|
||||
cells = [r["cells"] for r in _ctx("sales_projection", rows)["grids"]["main"]["rows"][:2]]
|
||||
assert cells[0][:3] == ["1", "INTEZOLE-PD", "106.92"]
|
||||
assert cells[1][:4] == ["2", "INTEZOLE-RD", "93.59", "4"]
|
||||
assert cells[1] == ["2", "INTEZOLE-RD", "93.59", "4", "", "", "250"]
|
||||
|
||||
|
||||
def test_printing_every_month_together_renumbers_instead_of_repeating():
|
||||
@@ -140,11 +138,11 @@ def test_printing_every_month_together_renumbers_instead_of_repeating():
|
||||
assert [r["cells"][0] for r in body[:2]] == ["1", "1"]
|
||||
|
||||
|
||||
def test_sales_projection_sales_column_names_the_actual_month():
|
||||
rows = _rows("sales_projection", 2, month="September")
|
||||
assert _ctx("sales_projection", rows)["grids"]["main"]["headers"][7] == "SEP. SALES"
|
||||
# No month on any row (e.g. a blank template): a generic label, never a hardcoded month.
|
||||
assert _ctx("sales_projection", _rows("sales_projection", 2))["grids"]["main"]["headers"][7] == "SALES"
|
||||
def test_sales_projection_groups_closing_and_projection_under_their_own_headings():
|
||||
from app.pdf.service import _env
|
||||
|
||||
html = _env.get_template("forms/sales_projection.html").render(**_ctx("sales_projection", _rows("sales_projection", 1)))
|
||||
assert '<th colspan="2">CLOSING</th>' in html and '<th colspan="2">PROJECTION</th>' in html
|
||||
|
||||
|
||||
def test_no_form_prints_dashboard_extras():
|
||||
@@ -224,3 +222,19 @@ def test_plain_text_fallback_keeps_the_form_content_readable():
|
||||
text = _html_to_text(_env.get_template("forms/fare_chart.html").render(**ctx))
|
||||
assert "Puri" in text and "APPROVAL SIGNATURE: Meera" in text and "<" not in text
|
||||
assert _minimal_pdf(text).startswith(b"%PDF")
|
||||
|
||||
|
||||
def test_expense_statement_splits_rupees_and_paise_and_totals_every_column():
|
||||
rows = _rows("expense_statement", 2, from_location="BBSR")
|
||||
rows[0].update(report_date="2026-10-03", fare="120.5", da_ex="150", other_expense="20")
|
||||
rows[1].update(report_date="2026-10-01", da_hq="100", postage="15.75", total="999") # a stale total is ignored
|
||||
ctx = _ctx("expense_statement", rows, approval_status="approved", am_name="Anita Das")
|
||||
body = ctx["grids"]["main"]["rows"]
|
||||
assert len(body) == 27
|
||||
assert body[0]["cells"][4:9] == ["120", "50", "", "150", ""]
|
||||
assert body[0]["cells"][13:15] == ["290", "50"]
|
||||
assert body[1]["cells"][13:15] == ["115", "75"]
|
||||
assert ctx["sums"]["total_rs"] == "406" and ctx["sums"]["total_p"] == "25"
|
||||
assert ctx["sums"]["claimed"] == "406.25"
|
||||
assert (ctx["period_from"], ctx["period_to"]) == ("01/10/2026", "03/10/2026")
|
||||
assert ctx["approval"]["value"] == "Anita Das"
|
||||
|
||||
Reference in New Issue
Block a user