From 4305d0a2b4916b76ac29eaca9e38f1df84d68837 2021-10-03 18:24:28 From: Lance Edgar Date: 2021-10-03 18:24:28 Subject: [PATCH] Add `get_contact_notes()` method for custorder batch handler not sure if this is quite the right approach, but better than we had before at least. may need to get certain "notes" independently, e.g. "customer has invalid phone/email" type flags --- diff --git a/rattail/batch/custorder.py b/rattail/batch/custorder.py index b5f404c42167f02484c3024cd55a2695c53f3c8f..55cbdacf8533c8fa52332c7ba56b9cf5b3fba920 100644 --- a/rattail/batch/custorder.py +++ b/rattail/batch/custorder.py @@ -107,7 +107,28 @@ class CustomerOrderBatchHandler(BatchHandler): session = self.app.get_session(batch) session.flush() - session.refresh(batch) + + def get_contact_notes(self, batch): + """ + Get extra "contact notes" which should be made visible to the + user who is entering the new order. + """ + notes = [] + customer_required = self.new_order_requires_customer() + + invalid = False + if customer_required: + if batch.customer: + invalid = [email for email in batch.customer.emails + if email.invalid] + else: + if batch.person: + invalid = [email for email in batch.person.emails + if email.invalid] + if invalid: + notes.append("Customer has one or more invalid email addresses on file.") + + return notes def unassign_contact(self, batch, **kwargs): """