Finvoice specific logic

Background

When invoice recipient details (InvoiceRecipientPartyDetails) are provided, we expect it to be the entity who should receive the invoice (via e-invoice, email or print).
There are requirements in Maventa side what details the entity should have in order to route it successfully:

  • Party name AND
  • Electronic address OR
  • Organisation number OR
  • Postal address (lines: post office, post code AND country code) OR
  • Email address

Issue

Invoice recipient details (InvoiceRecipientPartyDetails) are sometimes incomplete.

Fix

Complement invoice recipient from buyer details (BuyerPartyDetails) in Finvoice 1.x/2.x/3.0 versions if possible.

When

Invoice recipient details are complemented with buyer details when:

  • When invoice recipient does not have enough details (see requirements above)
  • When all given invoice recipient details match with buyer details (byte by byte, e.g NAME is not the same as Name)
  • When one or more invoice recipient details match with buyer details, but some of the values are different.
    • Allowed deviating details are:
      • Site code
      • Department
      • Contact person name
      • Contact person function
      • Contact person department
      • Email address
      • Phone number
  • When invoice recipient has only one detail given
    • Allowed details are:
      • Email address
      • Contact person name
      • Invoice recipient organisation unit number (OVT)
    • Email address and contact person name are considered as complementing details to be added on top of the buyer details
    • With OVT number there are several rules and conditions when it’s assumed to belong to buyer:
      • Buyer does not have OVT number
      • SOAP/To identifier or MesasgeTransmissionDetails/MessageReceiver/ToIdentifier does not exist or is equal with value
  • When none of invoice recipient details match with buyer, or buyer does not have these values
    • Allowed details are:
      • Site code
      • Department
      • Contact person name
      • Contact person function
      • Contact person department
      • Email address
      • Phone number

Other

Invoice recipient details are not complemented with buyer details when:

  • When invoice recipient has only following details (one or all)
    • Address post office (town)
    • Address post code
    • Address country code
    • Address country name

Example

<?xml version="1.0" encoding="ISO-8859-15"?>
<Finvoice Version="1.3">
  <InvoiceRecipientCommunicationDetails>
    <InvoiceRecipientPhoneNumberIdentifier>123456</InvoiceRecipientPhoneNumberIdentifier>
    <InvoiceRecipientEmailaddressIdentifier>email@email.com</InvoiceRecipientEmailaddressIdentifier>
  </InvoiceRecipientCommunicationDetails>
  <BuyerPartyDetails>
    <BuyerPartyIdentifier>3333333-3</BuyerPartyIdentifier>
    <BuyerOrganisationName>Name1</BuyerOrganisationName>
    <BuyerOrganisationName>Name2</BuyerOrganisationName>
    <BuyerOrganisationTaxCode>FI33333333</BuyerOrganisationTaxCode>
    <BuyerPostalAddressDetails>
      <BuyerStreetName>StreetName</BuyerStreetName>
      <BuyerTownName>TownName</BuyerTownName>
      <BuyerPostCodeIdentifier>11111</BuyerPostCodeIdentifier>
      <CountryCode>FI</CountryCode>
      <CountryName>Finland</CountryName>
    </BuyerPostalAddressDetails>
  </BuyerPartyDetails>
  <BuyerCommunicationDetails>
    <BuyerPhoneNumberIdentifier>123456</BuyerPhoneNumberIdentifier>
    <BuyerEmailaddressIdentifier>email@email.com</BuyerEmailaddressIdentifier>
  </BuyerCommunicationDetails>
  <InvoiceDetails>
    <InvoiceTypeCode>INV01</InvoiceTypeCode>
  </InvoiceDetails>
</Finvoice>

Output

<?xml version="1.0" encoding="ISO-8859-15"?>
<Finvoice Version="1.3">
  <InvoiceRecipientPartyDetails>
    <InvoiceRecipientPartyIdentifier>3333333-3</InvoiceRecipientPartyIdentifier>
    <InvoiceRecipientOrganisationName>Name1</InvoiceRecipientOrganisationName>
    <InvoiceRecipientOrganisationName>Name2</InvoiceRecipientOrganisationName>
    <InvoiceRecipientOrganisationTaxCode>FI33333333</InvoiceRecipientOrganisationTaxCode>
    <InvoiceRecipientPostalAddressDetails>
      <InvoiceRecipientStreetName>StreetName</InvoiceRecipientStreetName>
      <InvoiceRecipientTownName>TownName</InvoiceRecipientTownName>
      <InvoiceRecipientPostCodeIdentifier>11111</InvoiceRecipientPostCodeIdentifier>
      <CountryCode>FI</CountryCode>
      <CountryName>Finland</CountryName>
    </BuyerPostalAddressDetails>
  </InvoiceRecipientPartyDetails>
  <InvoiceRecipientCommunicationDetails>
    <InvoiceRecipientPhoneNumberIdentifier>123456</InvoiceRecipientPhoneNumberIdentifier>
    <InvoiceRecipientEmailaddressIdentifier>email@email.com</InvoiceRecipientEmailaddressIdentifier>
  </InvoiceRecipientCommunicationDetails>
  <BuyerPartyDetails>
    <BuyerPartyIdentifier>3333333-3</BuyerPartyIdentifier>
    <BuyerOrganisationName>Name1</BuyerOrganisationName>
    <BuyerOrganisationName>Name2</BuyerOrganisationName>
    <BuyerOrganisationTaxCode>FI33333333</BuyerOrganisationTaxCode>
    <BuyerPostalAddressDetails>
      <BuyerStreetName>StreetName</BuyerStreetName>
      <BuyerTownName>TownName</BuyerTownName>
      <BuyerPostCodeIdentifier>11111</BuyerPostCodeIdentifier>
      <CountryCode>FI</CountryCode>
      <CountryName>Finland</CountryName>
    </BuyerPostalAddressDetails>
  </BuyerPartyDetails>
  <BuyerCommunicationDetails>
    <BuyerPhoneNumberIdentifier>123456</BuyerPhoneNumberIdentifier>
    <BuyerEmailaddressIdentifier>email@email.com</BuyerEmailaddressIdentifier>
  </BuyerCommunicationDetails>
  <InvoiceDetails>
    <InvoiceTypeCode>INV01</InvoiceTypeCode>
  </InvoiceDetails>
</Finvoice>