Skip to content

Commit

Permalink
bugfix: Duplicate entries weren't added even once
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed May 24, 2024
1 parent 6c3d178 commit 217f8a6
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions backend/donations/views/donations_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,9 @@ def _build_xml(
# 02. XML header
xml_str += _build_xml_header(ngo, batch_count, zip_timestamp)

# 03. XML body
# 03. XML body (duplicates were already removed)
for donation_idx, donation in enumerate(donations_batch):
# skip donations which have a duplicate CNP from the XML
cnp = donation.get_cnp()
if cnp in cnp_idx and cnp_idx[cnp]["has_duplicate"]:
continue

xml_str = _build_xml_donation_content(donation, donation_idx, ngo, xml_str)
xml_str += _build_xml_donation_content(donation, donation_idx, ngo)

# 04. XML closing tag
xml_str += """</form1>"""
Expand Down Expand Up @@ -411,13 +406,13 @@ def _build_xml_header(ngo, xml_idx, zip_timestamp) -> str:
return xml_str


def _build_xml_donation_content(donation: Donor, donation_idx: int, ngo: Ngo, xml_str: str):
def _build_xml_donation_content(donation: Donor, donation_idx: int, ngo: Ngo):
# TODO: first name and last name have been swapped
# https://github.com/code4romania/redirectioneaza/issues/269

# noinspection HttpUrlsUsage
detailed_address: Dict = _get_address_details(donation)
xml_str += f"""
return f"""
<contrib>
<nrCrt>
<nV>{donation_idx + 1}</nV>
Expand Down Expand Up @@ -472,5 +467,3 @@ def _build_xml_donation_content(donation: Donor, donation_idx: int, ngo: Ngo, xm
</s15>
</contrib>
"""

return xml_str

0 comments on commit 217f8a6

Please sign in to comment.