Changeset - 4305d0a2b491
[Not reviewed]
0 1 0
Lance Edgar (lance) - 3 years ago 2021-10-03 18:24:28
lance@edbob.org
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
1 file changed with 22 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rattail/batch/custorder.py
Show inline comments
 
@@ -98,25 +98,46 @@ class CustomerOrderBatchHandler(BatchHandler):
 
        # update phone/email per new contact
 
        batch.phone_number = None
 
        batch.email_address = None
 
        if customer_required:
 
            batch.phone_number = clientele.get_first_phone_number(customer)
 
            batch.email_address = clientele.get_first_email_address(customer)
 
        else:
 
            batch.phone_number = person.first_phone_number()
 
            batch.email_address = person.first_email_address()
 

	
 
        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):
 
        """
 
        Unassign the customer and/or person "contact" for the order.
 
        """
 
        batch.customer = None
 
        batch.person = None
 
        batch.phone_number = None
 
        batch.email_address = None
 

	
 
        session = self.app.get_session(batch)
 
        session.flush()
0 comments (0 inline, 0 general)