Merge pull request #433 from eReuse/bugfix/4280-pdf

fix with last lot incoming
This commit is contained in:
cayop 2023-03-13 12:48:26 +01:00 committed by GitHub
commit d97eb08cce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 21 deletions

View File

@ -1071,22 +1071,18 @@ class ExportsView(View):
if not erasures or customer_details:
return my_data, customer_details
init = erasures[0].device.get_set_lots()
for e in erasures:
init = init.intersection(e.device.get_set_lots())
lots = {erasures[0].device.get_last_incoming_lot()}
for e in erasures[1:]:
lots.add(e.device.get_last_incoming_lot())
if not len(init):
if len(lots) != 1:
return my_data, customer_details
lots = sorted(list(init), key=lambda x: x.created)
lots.reverse()
for lot in lots:
lot = lots.pop()
try:
customer_details = lot.transfer.customer_details
if customer_details:
return my_data, customer_details
except Exception:
continue
pass
return my_data, customer_details

View File

@ -1021,18 +1021,24 @@ class Device(Thing):
return
def get_set_lots(self):
def get_last_incoming_lot(self):
lots = list(self.lots)
if hasattr(self, "orphan") and self.orphan:
lots = list(self.lots)
if self.binding:
return set(self.binding.device.lots)
return set(self.lots)
lots = list(self.binding.device.lots)
if hasattr(self, "parent") and self.parent:
elif hasattr(self, "parent") and self.parent:
lots = list(self.parent.lots)
if self.parent.binding:
return set(self.parent.binding.device.lots)
return set(self.parent.lots)
lots = list(self.parent.binding.device.lots)
return set(self.lots)
lots = sorted(lots, key=lambda x: x.created)
lots.reverse()
for lot in lots:
if lot.is_incoming:
return lot
return None
def __lt__(self, other):
return self.id < other.id

View File

@ -161,7 +161,7 @@
{% if erasure_hosts %}
<tr style="padding-top:5px;">
<td style="width:20%;">
<span>SNs; of sanitization server {{ erasure_hosts|length }}:</span>
<span>SNs of sanitization server:</span>
</td>
<td style="width:80%;">
{% for e in erasure_hosts %}