SQL data model - INVOIC description

SQL Tables description - INVOIC

Abstract

This paragraph describes the INVOIC (invoices) tables hierarchy and fields stored in the original "EdiPax+net+web-eancom.mdb".
Use Microsoft Access "tools/relation" menu or any other compatible tool to browse table relations (primary key, foreign key, integrity) and table structures.

Total (MOA), Taxes (TAX) and Allowances and Charges (ALC) at item level
This "basic" package  includes 1 "Allowance or Charge", 3 "amounts" (Gross line item, Discount amount, Line item amount)  and 2 taxes (VAT and recupel) fields at item level. The Allowance or Charge code (type) is left free, that is, you can process any Allowance or Charge type, 1 per line. You may however include as many lines as needed !

Total (MOA), Taxes (TAX) and Allowances and Charges (ALC) at document(invoice) level
Full relational model, with all possibilities. Mandatory values are reported beside the table field description.

Totals and Taxes calculation
When creating invoices, totals and tax totals are mandatory. The EdiPax engine will calculate / create those values if not present.
That is if you want to use this feature, you must leave the INVOIC_taxes and INVOIC_totals table empty. The tool will not add records to those tables, it will just add calculated values to the EDIFACT output.
Woudl the calculated value not be correct or detailed enough, you can force values - just fill in the fields. Be sure to use the correct EDIFACT values for mandatory EDIFACT fields.

remark : "Comment" fields must be 255 character long, minimum to accomodate EDIFACT FTX segment.

SQL validation rules
1. Incoming messages
Some SQL fields are defined as "not null" which means an SQL exception will occur wold the field be missing in the EDIFACT document.
2. Outgoing messages
Some SQL fields are defined as "not null" which means an error will occur would your application not supply the required fields.
Some fields are option or must be present in some given case (business rules). EdiPax will report those errors in the status field.

Table UNB

Common table for UNB segment.

Table UNH

Common table for UNH segment. FK_UNB is related to UNB.PK_UNB.

Table INVOIC_header

Database item name Description
PK_BGMprimary key (autonumber)
Audit numberunique internal key - refer to UpdateBatch - audit number
Interchange reference numberrequired, EDIFACT mandatory interchange unique reference
Message reference numberrequired, EDIFACT mandatory message unique reference inside interchange
Document reference numberrequired, mandatory document reference inside the messages, unique key per sender
Document typeinvoice, credit note
Invoice numberrequired, mandatory document reference inside the messages, unique key per sender
Reference typeCD = Credit, DL = debit or IV = invoice
ReferenceCredit, debit or invoice number
Message functionOriginal (code=9) or duplicate
Document daterequired
Invoice daterequired
Delivery date
Service completed date
Accounting value date
Account numberbank account number to pay
Order numberreference to the order unique key
Order dateoption
Vendor order numberoption
Vendor order dateoption
Despatch advice numberoption
Despatch advice dateoption
Currency referenceoption if not EURO
Currency targetoption
Exchange rateoption
Exchange rate dateoption
Payment periodsoption, number of period
Payment periodoption, coded, period type (week, months,..)
Payment codeoption, coded
Payment dateoption, coded
Payment relationoption, coded
Payment typeoption, coded
Payment meansoption, coded
Reference paymentoption, payment / bank transfer reference (RFF)
Discount rateoption
Number line itemsControl total - number of LIN elements
Number invoice linesControl total - number of invoice lines, some LIN could be comments or sublines
Commentoption
Seller name, code, street, zip,city , country, registry, vat, bank account, bank countrySeller information - refer to party table
Supplier name, code, street, zip,city , country, registry, vat, bank account, bank countrySupplier information - refer to party table
Buyer name, code, street, zip,city , country, vatBuyer information - refer to party table
Delivery party name, code, street, zip,city , countryDelivery information - refer to party table
Contact name, code, street, zip,city , country, personContact information - refer to party table
Statusrecord flow status
FK_UNHforeign key, pointer to UNH.PK_UNH

Table INVOIC_items

Database item name Description
PK_LINprimary key (autonumber)
Invoice lineMandatory. Contains information as received. Generated by EdiPax on new documents
Item numberEAN or product code - mandatory
GTINgeneral trade identification number (EAN code)
Item identificationEAN code if not in GTIN
Item code listEAN (code 9) or private
Item descriptionItem description - mandatory
Item description2Item description - option
Item agencyMandatory if not UN or EAN
Comment
Product identification
Order numberreference to orders unique key, if different from Order number in header
Order linereference to orders item unique key - to use if several invoices to match 1 order
Delivery date
Order quantity
Invoice quantityrequired
Delivery quantityrecommanded
Despatch quantity
CU in TUNumber of customer units in one trade unit
Line item amountrequired, amount charge, including ALC
Discount rate
Discount amount can be equal to amount * discount or any fix amount
Gross line itemgroos amount, with ALC or discount
Price qualifierrequired, AAB - gross prices - UNTED 5125
Pricerequired
Price typeUNTED 5375
Price specificationPrice type qualifier - UNTED 5387
Price measurerequired, PCE = piece - UNTED 6411
Unit price basisnumber of units in the price ...
Tax exemptionrequired if not tax rate is specified BMF100 codes - UNTED 5279
Tax ratealphanumeric - can contain numeric values like 21.0  or 21
Tax basis
Tax amountoption - required if "Tax rate" is not numeric, or no tax rate specified
ALC qualifierA (Allowance) or C (Charge) - UNTED 5463
ALC codeany special service UN code (discount,..) - UNTED 7161
ALC amountrequired if ALC segement is used
Recupelenvironmental tax (special charge)
Statusrecord flow status
FK_BGMforeign key to INVOIC_header.PK_BGM

Table INVOIC_LIN05 - sublines

Database item nameDescription
PK_LIN05primary key (autonumber)
subLinesubLine indicator. Value should be 1
Add info5allocation key
Add info6allocation key
Add info7allocation key
Add info8allocation key
Add info9allocation key
Add info10allocation key
Add info11allocation key
Add info12allocation key
ac_agencyallocation key agency
Lineinvoice line number, alphanumeric, in sequence
Tax raterequired, alphanumeric
Amount netrequired
Fromfrom location
Toto location
Period startperiod service performed
Period end
Service datedate and time service performed
Service durationduration of a service
Service duration unit803=week, 804=day, 805=hour, 806=min, 807=sec
Comment
Quantity itemsrequired, number of items / number of units
Quantity items unitrequired, unit (PCE = piece,..) - UNTED 6411
Quantity chargednumber of units charged
Quantity charged unitcharge quantity unit (PCE = piece, SEC = second, ..) - UNTED 6411
ALC code
Reference
parentinternal code, pointer toward INVOIC_items.Invoice Line parent
Statusrecord flow status
FK_LINforeign key to INVOIC_items.PK_LIN

Table INVOIC_alc

Contains allowance and charges (transport, discount and other services)
Database item nameDescription
PK_ALCprimary key (autonumber)
Alc Qualifierrequired, must be A (allowance) or C (charge)
Alc special service required, special services, any UN or BMF100 values from UNTED 7162 table
Discount amount - discount rate * total- code EDIFACT 52, MOA at the end of the message, not mandatory
Cash discount - invoice footer, additional discount - code EDIFACT 21
Quantity discount allowance - discount on quantity, EURO - code EDIFACT QD
Promotional discount allowance - discount on quantity, EURO - code EDIFACT PAE
Freight charge - transport or freight on goods, EURO - code EDIFACT FC
Discount allowance - = discount rate *Line item amount -should match Payment term / discount, EURO - code EDIFACT DI
Alc amountrequired
Tax qualifierrequired, 7 or 3 - other code accepted
Tax typerequired, VAT or ENV
Tax idoption, exemption code - mandatory if [Tax category] =  E(Exempt)
Tax raterequired - can be 0 or null if Tax id is specified
Tax categoryS = standard rate, E = Exempt
Tax basis qualifierrequired, 23 = Charge amount, 109 = Payment discount amount, 204 = Allowance amount - must match Alc qualifier ( C = 23, A = 204 or 109
Tax BasisVat Basis, Allowance or Charge amount
Tax amountoption, mandatory if rate is not numeric - positive or negative
Statusrecord flow status
FK_BGMforeign key to INVOIC_header.PK_BGM

Table INVOIC_totals

All total items, at document (invoice) level. We recommend to use 6 codes. You may set values to 0 if amount (zero) is considered as significant.
Database item nameDescription
PK_MOAprimary key (autonumber)
Amount qualifier Total line items amount - Gross value, before document level discount, transport and any other charge, code EDIFACT 79
Invoice amount - including VAT, code EDIFACT 77 or 86
VAT basis - code EDIFACT 79
VAT amount - code EDIFACT 150
Total duty/tax/fee 176
Tax amount - code EDIFACT 124
Total charges, allowance - option, code EDIFACT 131
Amount due - option, code EDIFACT 9, deduct prepaid amount(s)
Amountrequired
C51603option
C51604option
C51605option
Statusrecord flow status
FK_BGMforeign key to INVOIC_header.PK_BGM

Table INVOIC_taxes

Tax detail, 1 record per tax class or tax rate. The tax basis and tax amount must be specified.
Database item nameDescription
PK_TAXprimary key (autonumber)
Tax Qualifiervalue = 7, required
Tax typerequired, VAT (value added taxe) or ENV (environmental) are common, any valid UN code accepted
Tax raterequired,alphanumeric value. When VAT tax, we recommend to put the numeric value (ex : 21)
Tax exemption When exempt, tax rate must be null or equal to 0
Tax basisrequired. Can be 0
Tax amountoption, must be not null if Tax Basis is null (fix amount tax)
Statusrecord flow status
FK_BGMforeign key to INVOIC_header.PK_BGM

Table Party

One record per party (buyer, supplier, invoicee, delivery party, bank,...)
Database item nameDescription
PK_PARTYprimary key, autonumber
Qualifierrequired
Coderequired
Belgian tax authorities : an invoice is always sent by the Supplier tothe Buyer (code EDIFACT SU -> BY)
EAN code, part of the new record selection process - review the query "INVOICselectNew" query to check relations
We may mention DP (delivery party)
Nameoption for EAN00n, required legal obligation for BMF100
Address 1option for EAN00n, required legal obligation for BMF100
Address 2
Cityoption for EAN00n, required legal obligation for BMF100
Zipoption for EAN00n, required legal obligation for BMF100
Country
Registry
Vatrequired for supplier, buyer and invoicee
Bank account
Bank country
Factor ID
Contact
Telephone
Fax
Email
Statusrecord flow status
FK_BGMforeign key to INVOIC_header.PK_BGM

See also