improve spacing in mdwn output, add payment date print-out
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 20 Apr 2021 13:10:27 +0000 (14:10 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 20 Apr 2021 13:10:27 +0000 (14:10 +0100)
src/budget_sync/write_budget_markdown.py

index c72caf21392ff36da280812a7a729e3bb401a3f7..b04e7fd597ac8e1bbc5e3696dc4a04dc2ba3a237 100644 (file)
@@ -84,6 +84,12 @@ class MarkdownWriter:
                          f" which is &euro;{node.budget_excluding_subtasks})")
             else:
                 total = f"&euro;{node.fixed_budget_excluding_subtasks}"
+            if payment.submitted:
+                print(f"    * submitted on {payment.submitted}",
+                      file=self.buffer)
+            if payment.paid:
+                print(f"    * paid on {payment.paid}",
+                      file=self.buffer)
             if payment.amount != node.fixed_budget_excluding_subtasks \
                     or payment.amount != node.budget_excluding_subtasks:
                 print(f"    * &euro;{payment.amount} out of total of {total}",
@@ -98,9 +104,9 @@ def _markdown_for_person(person: Person,
                          assigned_nodes: List[Node]) -> str:
     writer = MarkdownWriter()
     print(f"<!-- autogenerated by budget-sync -->", file=writer.buffer)
-    writer.write_headers([f"# {person.identifier}"])
+    writer.write_headers([f"\n# {person.identifier}\n"])
     print(file=writer.buffer)
-    status_tracking_header = "# Status Tracking"
+    status_tracking_header = "\n# Status Tracking\n"
     writer.write_headers([status_tracking_header])
     displayed_nodes_dict: Dict[DisplayStatus, List[Node]]
     displayed_nodes_dict = {i: [] for i in DisplayStatus}
@@ -109,7 +115,7 @@ def _markdown_for_person(person: Person,
         displayed_nodes_dict[display_status].append(node)
 
     def write_display_status_chunk(display_status: DisplayStatus):
-        display_status_header = f"## {display_status.value}"
+        display_status_header = f"\n## {display_status.value}\n"
         for node in displayed_nodes_dict[display_status]:
             if display_status == DisplayStatus.Completed:
                 payment_found = False
@@ -141,8 +147,9 @@ def _markdown_for_person(person: Person,
         else:
             assert payee_state == PayeeState.Paid
             display_status_header = f"## Paid by NLNet"
+        display_status_header="\n%s\n" % display_status_header
         for milestone, payments_list in payments_dict.items():
-            milestone_header = f"### {milestone.identifier}"
+            milestone_header = f"\n### {milestone.identifier}\n"
             for payment in payments_list:
                 if payment.state == payee_state:
                     writer.write_node(headers=[status_tracking_header,