Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoices require a valid email if present #477

Open
Samsinite opened this issue May 13, 2019 · 3 comments
Open

Invoices require a valid email if present #477

Samsinite opened this issue May 13, 2019 · 3 comments

Comments

@Samsinite
Copy link

Hi, we are encountering a validation error on a contact when batch creating a set of invoices, apparently this requires that the email address is valid if one is present. Was actually surprised to see this error as there was no associated error when we saved the contact model. Even stranger is that the validation error is nested under the contact even though that contact was already created. I have the response xml that I can likely provide (as long as I remove sensitive information) if that helps. I am going to dig into the request xml to see what was sent over.

@CloCkWeRX
Copy link
Collaborator

Got the sample invalid email? We can either do a basic regex validation (contains @) or a more complex RFC based one; but if it doesn't match the underlying API perfectly; it might be better to do the simplest approach.

@CloCkWeRX CloCkWeRX added the bug label Jan 30, 2020
@rjaus
Copy link
Collaborator

rjaus commented Sep 23, 2021

Hey @Samsinite, a contact will always require a valid email if provided.

That appears to be the basis of this issue. An invoice relies on a valid contact, so that's going to fail if the contact is invalid.

I see two issues to fix here:

  1. Contact model in wrapper is not validating email address, as mentioned by @CloCkWeRX
  2. Validation error is not being caught an processed by the Contact record.

@rjaus
Copy link
Collaborator

rjaus commented Sep 23, 2021

Here is what the API response looks like in this case (single invoice, single contact):

<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ErrorNumber>10</ErrorNumber>
  <Type>ValidationException</Type>
  <Message>A validation exception occurred</Message>
  <Elements>
    <DataContractBase xsi:type="Invoice">
      <ValidationErrors>
        <ValidationError>
          <Message>Email address must be valid.</Message>
        </ValidationError>
      </ValidationErrors>
      <Contact>
        <ValidationErrors>
          <ValidationError>
            <Message>Email address must be valid.</Message>
          </ValidationError>
        </ValidationErrors>
        <ContactID>c344c7b4-3da8-4ec4-a54d-8407b3a359f0</ContactID>
        <ContactStatus>ACTIVE</ContactStatus>
        <Name>tester</Name>
        <EmailAddress>notvalid.com@asdf</EmailAddress>
        <Addresses>
          <Address>
            <AddressType>STREET</AddressType>
          </Address>
          <Address>
            <AddressType>POBOX</AddressType>
          </Address>
        </Addresses>
        <Phones>
          <Phone>
            <PhoneType>DEFAULT</PhoneType>
          </Phone>
          <Phone>
            <PhoneType>DDI</PhoneType>
          </Phone>
          <Phone>
            <PhoneType>FAX</PhoneType>
          </Phone>
          <Phone>
            <PhoneType>MOBILE</PhoneType>
          </Phone>
        </Phones>
        <UpdatedDateUTC>2021-09-23T00:34:40.7479588Z</UpdatedDateUTC>
        <IsSupplier>false</IsSupplier>
        <IsCustomer>false</IsCustomer>
      </Contact>
      <Date>2021-09-23T00:00:00</Date>
      <Status>DRAFT</Status>
      <LineAmountTypes>Exclusive</LineAmountTypes>
      <LineItems>
        <LineItem>
          <Description>Test</Description>
          <UnitAmount>10.00</UnitAmount>
          <TaxType>OUTPUT</TaxType>
          <TaxAmount>1.00</TaxAmount>
          <LineAmount>10.00</LineAmount>
          <Quantity>1.0000</Quantity>
          <LineItemID>03296a58-c5f7-48ff-aa83-bdfe3102457c</LineItemID>
        </LineItem>
      </LineItems>
      <SubTotal>10.00</SubTotal>
      <TotalTax>1.00</TotalTax>
      <Total>11.00</Total>
      <CurrencyCode>AUD</CurrencyCode>
      <Type>ACCREC</Type>
      <InvoiceID>00000000-0000-0000-0000-000000000000</InvoiceID>
      <InvoiceNumber>ORC1080</InvoiceNumber>
      <AmountDue>11.00</AmountDue>
      <AmountPaid>0.00</AmountPaid>
      <SentToContact>false</SentToContact>
      <CurrencyRate>1.0000000000</CurrencyRate>
      <HasErrors>true</HasErrors>
    </DataContractBase>
  </Elements>
</ApiException>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants