This repository has been archived by the owner on Jun 8, 2022. It is now read-only.
/
EDIXMLInvoiceBean.java
498 lines (438 loc) · 19.4 KB
/
EDIXMLInvoiceBean.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
/*
*
* * #%L
* * %%
* * Copyright (C) <current year> metas GmbH
* * %%
* * This program is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as
* * published by the Free Software Foundation, either version 2 of the
* * License, or (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* *
* * You should have received a copy of the GNU General Public
* * License along with this program. If not, see
* * <http://www.gnu.org/licenses/gpl-2.0.html>.
* * #L%
*
*/
package de.metas.edi.esb.bean.invoice;
import de.metas.edi.esb.commons.Constants;
import de.metas.edi.esb.jaxb.*;
import de.metas.edi.esb.pojo.common.MeasurementUnit;
import de.metas.edi.esb.pojo.invoice.ObjectFactory;
import de.metas.edi.esb.pojo.invoice.*;
import de.metas.edi.esb.pojo.invoice.qualifier.*;
import de.metas.edi.esb.route.AbstractEDIRoute;
import de.metas.edi.esb.route.exports.XMLInvoiceRoute;
import org.apache.camel.Exchange;
import org.apache.camel.RuntimeCamelException;
import org.apache.commons.lang.StringUtils;
import org.milyn.payload.JavaSource;
import java.text.DecimalFormat;
import java.util.Comparator;
import static de.metas.edi.esb.commons.Util.*;
public class EDIXMLInvoiceBean
{
public static final String METHOD_createXMLEDIData = "createXMLEDIData";
private static final ObjectFactory INVOICE_objectFactory = new ObjectFactory();
//Credit note - metasfresh "ARC" base doc type and "CR" sub doc type
private static final int DOC_CRNO_ID = 83;
//Credit note - metasfresh "ARC" base doc type and "CQ", "CS" sub doc types
private static final int DOC_CRNO2_ID = 381;
//Commercial invoice - metasfresh "ARI" base doc type
private static final int DOC_CMIV_ID = 380;
// Debit note - metasfresh "ARI" base doc type and "AQ" sub doc type
private static final int DOC_DBNO_ID = 383;
// Debit note - metasfresh "ARI" base doc type and "AP" sub doc type
private static final int DOC_DBNO2_ID = 84;
public void createXMLEDIData(final Exchange exchange)
{
final EDICctopInvoicVType xmlCctopInvoice = exchange.getIn().getBody(EDICctopInvoicVType.class);
final Document document = createDocument(exchange, xmlCctopInvoice);
final JavaSource source = new JavaSource(document);
exchange.getIn().setBody(source, Document.class);
}
private Document createDocument(final Exchange exchange, final EDICctopInvoicVType invoice)
{
final DecimalFormat decimalFormat = exchange.getProperty(Constants.DECIMAL_FORMAT, DecimalFormat.class);
final String isTest = exchange.getProperty(XMLInvoiceRoute.EDI_XML_INVOICE_IS_TEST, String.class);
final String partnerId = exchange.getProperty(XMLInvoiceRoute.EDI_XML_PARTNER_ID, String.class);
final String ownerId = exchange.getProperty(XMLInvoiceRoute.EDI_XML_OWNER_ID, String.class);
final String applicationRef = exchange.getProperty(XMLInvoiceRoute.EDI_XML_APPLICATION_REF, String.class);
final Document document = INVOICE_objectFactory.createDocument();
final Xrech4H xrech4H = INVOICE_objectFactory.createXrech4H();
final HEADERXrech headerXrech = INVOICE_objectFactory.createHEADERXrech();
headerXrech.setTESTINDICATOR(isTest);
headerXrech.setPARTNERID(partnerId);
headerXrech.setAPPLICATIONREF(applicationRef);
headerXrech.setOWNERID(ownerId);
final String documentId = invoice.getInvoiceDocumentno();
headerXrech.setDOCUMENTID(documentId);
DocumentType documentType = mapDocumentType(invoice.getEancomDoctype());
if (documentType == null)
{
throw new RuntimeCamelException("Could not identify document type");
}
headerXrech.setDOCUMENTTYP(documentType.name());
headerXrech.setDOCUMENTFUNCTION(DocumentFunction.ORIG.name());
final String dateFormat = (String)exchange.getProperty(AbstractEDIRoute.EDI_ORDER_EDIMessageDatePattern);
mapDates(invoice, headerXrech, dateFormat);
mapReferences(invoice, headerXrech);
mapAddresses(invoice, headerXrech);
final HCURR1 currency = INVOICE_objectFactory.createHCURR1();
currency.setDOCUMENTID(documentId);
currency.setCURRENCYQUAL(CurrencyQual.INVO.name());
currency.setCURRENCYCODE(invoice.getISOCode());
headerXrech.getHCURR1().add(currency);
mapPaymentTerms(invoice, decimalFormat, headerXrech, dateFormat);
mapAlCh(invoice, decimalFormat, headerXrech);
mapDetails(invoice, decimalFormat, headerXrech);
final TRAILR docTrailer = INVOICE_objectFactory.createTRAILR();
docTrailer.setDOCUMENTID(documentId);
docTrailer.setCONTROLQUAL(ControlQual.LINE.name());
docTrailer.setCONTROLVALUE(formatNumber(invoice.getEDICctopInvoic500V().size(), decimalFormat));
mapTrailer(invoice, decimalFormat, docTrailer);
xrech4H.setHEADER(headerXrech);
xrech4H.setTRAILR(docTrailer);
document.getXrech4H().add(xrech4H);
return document;
}
private DocumentType mapDocumentType(final String eancomDocType)
{
int incomingDocType = Integer.parseInt(eancomDocType);
DocumentType documentType = null;
if (incomingDocType == DOC_CRNO_ID || incomingDocType == DOC_CRNO2_ID)
{
documentType = DocumentType.CRNO;
}
else if (incomingDocType == DOC_DBNO_ID || incomingDocType == DOC_DBNO2_ID)
{
documentType = DocumentType.DBNO;
}
else if (incomingDocType == DOC_CMIV_ID)
{
documentType = DocumentType.CMIV;
}
return documentType;
}
private void mapTrailer(final EDICctopInvoicVType invoice, final DecimalFormat decimalFormat, final TRAILR docTrailer)
{
String documentId = docTrailer.getDOCUMENTID();
final TAMOU1 trailerLinesAmount = INVOICE_objectFactory.createTAMOU1();
trailerLinesAmount.setDOCUMENTID(documentId);
trailerLinesAmount.setAMOUNTQUAL(AmountQual.TLIN.name());
trailerLinesAmount.setAMOUNT(formatNumber(invoice.getTotalLines(), decimalFormat));
trailerLinesAmount.setCURRENCY(invoice.getISOCode());
docTrailer.getTAMOU1().add(trailerLinesAmount);
final TAMOU1 trailerAmount = INVOICE_objectFactory.createTAMOU1();
trailerAmount.setDOCUMENTID(documentId);
trailerAmount.setAMOUNTQUAL(AmountQual.TINV.name());
trailerAmount.setAMOUNT(formatNumber(invoice.getGrandTotal(), decimalFormat));
trailerAmount.setCURRENCY(invoice.getISOCode());
docTrailer.getTAMOU1().add(trailerAmount);
final TAMOU1 trailerTaxAmount = INVOICE_objectFactory.createTAMOU1();
trailerTaxAmount.setDOCUMENTID(documentId);
trailerTaxAmount.setAMOUNTQUAL(AmountQual.TZAX.name());
trailerTaxAmount.setAMOUNT(formatNumber(invoice.getTotalvat(), decimalFormat));
trailerTaxAmount.setCURRENCY(invoice.getISOCode());
docTrailer.getTAMOU1().add(trailerTaxAmount);
for (final EDICctop901991VType xmlCctop901991V : invoice.getEDICctop901991V())
{
final TTAXI1 trailerTax = INVOICE_objectFactory.createTTAXI1();
trailerTax.setDOCUMENTID(documentId);
trailerTax.setTAXQUAL(TaxQual.VATX.name());
trailerTax.setTAXRATE(formatNumber(xmlCctop901991V.getRate(), decimalFormat));
trailerTax.setTAXAMOUNT(formatNumber(xmlCctop901991V.getTaxAmt(), decimalFormat));
trailerTax.setTAXABLEAMOUNT(formatNumber(xmlCctop901991V.getTaxBaseAmt(), decimalFormat));
docTrailer.getTTAXI1().add(trailerTax);
}
}
private void mapDetails(final EDICctopInvoicVType invoice, final DecimalFormat decimalFormat, final HEADERXrech headerXrech)
{
invoice.getEDICctopInvoic500V().sort(Comparator.comparing(EDICctopInvoic500VType::getLine));
String documentId = headerXrech.getDOCUMENTID();
for (final EDICctopInvoic500VType xmlCctopInvoic500V : invoice.getEDICctopInvoic500V())
{
final DETAILXrech detailXrech = INVOICE_objectFactory.createDETAILXrech();
detailXrech.setDOCUMENTID(documentId);
final String lineNumber = formatNumber(xmlCctopInvoic500V.getLine(), decimalFormat);
detailXrech.setLINENUMBER(lineNumber);
final DPRIN1 productInfo = INVOICE_objectFactory.createDPRIN1();
productInfo.setDOCUMENTID(documentId);
productInfo.setLINENUMBER(lineNumber);
productInfo.setPRODUCTQUAL(ProductQual.BUYR.name());
productInfo.setPRODUCTID(xmlCctopInvoic500V.getVendorProductNo());
detailXrech.getDPRIN1().add(productInfo);
final DPRIN1 productUpc = INVOICE_objectFactory.createDPRIN1();
productUpc.setDOCUMENTID(documentId);
productUpc.setLINENUMBER(lineNumber);
productUpc.setPRODUCTQUAL(ProductQual.GTIN.name());
productUpc.setPRODUCTID(xmlCctopInvoic500V.getUPC());
detailXrech.getDPRIN1().add(productUpc);
final DPRIN1 productSupl = INVOICE_objectFactory.createDPRIN1();
productSupl.setDOCUMENTID(documentId);
productSupl.setLINENUMBER(lineNumber);
productSupl.setPRODUCTQUAL(ProductQual.SUPL.name());
productSupl.setPRODUCTID(xmlCctopInvoic500V.getValue());
detailXrech.getDPRIN1().add(productSupl);
final DPRDE1 productDescr = INVOICE_objectFactory.createDPRDE1();
productDescr.setDOCUMENTID(documentId);
productDescr.setLINENUMBER(lineNumber);
productDescr.setPRODUCTDESCQUAL(ProductDescQual.PROD.name());
productDescr.setPRODUCTDESCTEXT(xmlCctopInvoic500V.getProductDescription());
//use consumer unit and german language as default
productDescr.setPRODUCTDESCTYPE(ProductDescType.CU.name());
productDescr.setPRODUCTDESCLANG(ProductDescLang.DE.name());
detailXrech.getDPRDE1().add(productDescr);
final DQUAN1 invoicedQuantity = INVOICE_objectFactory.createDQUAN1();
invoicedQuantity.setDOCUMENTID(documentId);
invoicedQuantity.setLINENUMBER(lineNumber);
invoicedQuantity.setQUANTITYQUAL(QuantityQual.INVO.name());
MeasurementUnit measurementUnit = MeasurementUnit.fromCUOM(xmlCctopInvoic500V.getEancomUom());
if (measurementUnit != null)
{
invoicedQuantity.setMEASUREMENTUNIT(measurementUnit.name());
}
invoicedQuantity.setQUANTITY(formatNumber(xmlCctopInvoic500V.getQtyInvoiced(), decimalFormat));
detailXrech.getDQUAN1().add(invoicedQuantity);
final DAMOU1 amount = INVOICE_objectFactory.createDAMOU1();
amount.setDOCUMENTID(documentId);
amount.setLINENUMBER(lineNumber);
amount.setAMOUNTQUAL(AmountQual.ANET.name());
amount.setAMOUNT(formatNumber(xmlCctopInvoic500V.getLineNetAmt(), decimalFormat));
amount.setCURRENCY(xmlCctopInvoic500V.getISOCode());
detailXrech.getDAMOU1().add(amount);
final DPRIC1 price = INVOICE_objectFactory.createDPRIC1();
price.setDOCUMENTID(documentId);
price.setLINENUMBER(lineNumber);
price.setPRICEQUAL(PriceQual.NETT.name());
price.setPRICE(formatNumber(xmlCctopInvoic500V.getPriceActual(), decimalFormat));
price.setPRICESPEC(PriceSpecCode.NETP.name());
MeasurementUnit priceMeasurementUnit = MeasurementUnit.fromCUOM(xmlCctopInvoic500V.getEanComPriceUOM());
if (priceMeasurementUnit != null)
{
price.setPRICEMEASUREUNIT(priceMeasurementUnit.name());
}
detailXrech.getDPRIC1().add(price);
if (xmlCctopInvoic500V.getOrderLine() != null)
{
final DREFE1 reference = INVOICE_objectFactory.createDREFE1();
reference.setDOCUMENTID(documentId);
reference.setLINENUMBER(lineNumber);
reference.setREFERENCEQUAL(ReferenceQual.ORBU.name());
reference.setREFERENCE(xmlCctopInvoic500V.getOrderPOReference());
reference.setREFERENCELINE(xmlCctopInvoic500V.getOrderLine().toString());
detailXrech.getDREFE1().add(reference);
}
final DTAXI1 tax = INVOICE_objectFactory.createDTAXI1();
tax.setDOCUMENTID(documentId);
tax.setLINENUMBER(lineNumber);
tax.setTAXQUAL(TaxQual.VATX.name());
tax.setTAXRATE(formatNumber(xmlCctopInvoic500V.getRate(), decimalFormat));
tax.setTAXAMOUNT(formatNumber(xmlCctopInvoic500V.getTaxAmtInfo(), decimalFormat));
tax.setTAXABLEAMOUNT(formatNumber(xmlCctopInvoic500V.getLineNetAmt(), decimalFormat));
detailXrech.setDTAXI1(tax);
headerXrech.getDETAIL().add(detailXrech);
}
}
private void mapAlCh(final EDICctopInvoicVType invoice, final DecimalFormat decimalFormat, final HEADERXrech headerXrech)
{
for (final EDICctop901991VType xmlCctop901991V : invoice.getEDICctop901991V())
{
final HALCH1 alch = INVOICE_objectFactory.createHALCH1();
alch.setDOCUMENTID(headerXrech.getDOCUMENTID());
alch.setAMOUNT(formatNumber(xmlCctop901991V.getTotalAmt(), decimalFormat));
alch.setTAXRATE(formatNumber(xmlCctop901991V.getRate(), decimalFormat));
alch.setTAXAMOUNT(formatNumber(xmlCctop901991V.getTaxAmt(), decimalFormat));
alch.setTAXCODE(TaxQual.VATX.name());
alch.setTAXABLEAMOUNT(formatNumber(xmlCctop901991V.getTaxBaseAmt(), decimalFormat));
headerXrech.getHALCH1().add(alch);
}
}
private void mapPaymentTerms(final EDICctopInvoicVType invoice, final DecimalFormat decimalFormat, final HEADERXrech headerXrech, final String dateFormat)
{
for (final EDICctop120VType xmlCctop120V : invoice.getEDICctop120V())
{
final HPAYT1 paymentTerm = INVOICE_objectFactory.createHPAYT1();
paymentTerm.setDOCUMENTID(headerXrech.getDOCUMENTID());
paymentTerm.setTIMEREFERENCE(ReferenceQual.INVO.name());
paymentTerm.setTIMEPERIODQUANTITY(formatNumber(xmlCctop120V.getNetDays(), decimalFormat));
if (xmlCctop120V.getNetdate() != null)
{
paymentTerm.setTERMSQUAL(TermsQual.FIXD.name());
paymentTerm.setTERMSDATEFROM(toFormattedStringDate(toDate(xmlCctop120V.getNetdate()), dateFormat));
}
else
{
paymentTerm.setTIMERELATION(TimeRelation.AFTR.name());
paymentTerm.setTIMEPERIODTYPE(TimePeriodType.DAYS.name());
paymentTerm.setTERMSQUAL(TermsQual.BASE.name());
}
headerXrech.getHPAYT1().add(paymentTerm);
}
for (final EDICctop140VType xmlCctop140V : invoice.getEDICctop140V())
{
final HPAYT1 paymentTerm = INVOICE_objectFactory.createHPAYT1();
paymentTerm.setDOCUMENTID(headerXrech.getDOCUMENTID());
paymentTerm.setTERMSQUAL(TermsQual.DISC.name());
paymentTerm.setTIMEREFERENCE(ReferenceQual.INVO.name());
paymentTerm.setTIMERELATION(TimeRelation.AFTR.name());
paymentTerm.setTIMEPERIODTYPE(TimePeriodType.DAYS.name());
paymentTerm.setTIMEPERIODQUANTITY(formatNumber(xmlCctop140V.getDiscountDays(), decimalFormat));
paymentTerm.setDISCOUNTPERCENT(formatNumber(xmlCctop140V.getDiscount(), decimalFormat));
headerXrech.getHPAYT1().add(paymentTerm);
}
}
private void mapAddresses(EDICctopInvoicVType invoice, HEADERXrech headerXrech)
{
for (final EDICctop119VType xmlCctop119V : invoice.getEDICctop119V())
{
if (isEmpty(xmlCctop119V.getGLN()))
{
throw new RuntimeCamelException(xmlCctop119V + " must have a GLN");
}
if (isEmpty(xmlCctop119V.getEancomLocationtype()))
{
throw new RuntimeCamelException(xmlCctop119V + " must have a location type");
}
final HADRE1 address = INVOICE_objectFactory.createHADRE1();
address.setDOCUMENTID(headerXrech.getDOCUMENTID());
EancomLocationQual eancomLocationQual = EancomLocationQual.valueOf(xmlCctop119V.getEancomLocationtype());
AddressQual addressQual = mapAddressQual(eancomLocationQual);
if (addressQual == null)
{
throw new RuntimeCamelException(xmlCctop119V + " could not identify address qualifier");
}
address.setADDRESSQUAL(addressQual.name());
address.setPARTYIDGLN(xmlCctop119V.getGLN());
if (!isEmpty(xmlCctop119V.getAddress1()))
{
address.setSTREET1(xmlCctop119V.getAddress1());
address.setSTREET2(xmlCctop119V.getAddress2());
}
else
{
if (isEmpty(xmlCctop119V.getAddress2()))
{
throw new RuntimeCamelException(xmlCctop119V + " must have at least one filled address");
}
address.setSTREET1(xmlCctop119V.getAddress2());
}
if (!isEmpty(xmlCctop119V.getName()))
{
address.setNAME1(xmlCctop119V.getName());
address.setNAME2(xmlCctop119V.getName2());
}
else
{
if (isEmpty(xmlCctop119V.getName2()))
{
throw new RuntimeCamelException(xmlCctop119V + " must have at least one filled name");
}
address.setNAME1(normalize(xmlCctop119V.getName2()));
}
address.setCITY(xmlCctop119V.getCity());
address.setPOSTALCODE(xmlCctop119V.getPostal());
address.setCOUNTRY(xmlCctop119V.getCountryCode());
if (addressQual == AddressQual.SUPL && isEmpty(xmlCctop119V.getVATaxID()))
{
throw new RuntimeCamelException(xmlCctop119V + " must have a VATTaxID");
}
if (addressQual == AddressQual.SUPL || (addressQual == AddressQual.BUYR && StringUtils.isNotEmpty(xmlCctop119V.getVATaxID())))
{
final HRFAD1 ref = INVOICE_objectFactory.createHRFAD1();
ref.setDOCUMENTID(headerXrech.getDOCUMENTID());
ref.setADDRESSQUAL(addressQual.name());
ref.setREFERENCEQUAL(ReferenceQual.VATR.name());
ref.setREFERENCE(xmlCctop119V.getVATaxID());
address.getHRFAD1().add(ref);
}
if (addressQual == AddressQual.SUPL)
{
// copy and create ISSI (Issuer of invoice) address
final HADRE1 issiAddress = INVOICE_objectFactory.createHADRE1();
issiAddress.setDOCUMENTID(headerXrech.getDOCUMENTID());
issiAddress.setADDRESSQUAL(AddressQual.ISSI.name());
issiAddress.setPARTYIDGLN(address.getPARTYIDGLN());
issiAddress.setSTREET1(address.getSTREET1());
issiAddress.setSTREET2(address.getSTREET2());
issiAddress.setNAME1(address.getNAME1());
issiAddress.setNAME2(address.getNAME2());
issiAddress.setCITY(address.getCITY());
issiAddress.setPOSTALCODE(address.getPOSTALCODE());
issiAddress.setCOUNTRY(address.getCOUNTRY());
headerXrech.getHADRE1().add(issiAddress);
}
headerXrech.getHADRE1().add(address);
}
}
private AddressQual mapAddressQual(final EancomLocationQual eancomLocationQual)
{
AddressQual addressQual = null;
switch (eancomLocationQual)
{
case DP:
{
addressQual = AddressQual.DELV;
break;
}
case IV:
{
addressQual = AddressQual.IVCE;
break;
}
case BY:
{
addressQual = AddressQual.BUYR;
break;
}
case SU:
{
addressQual = AddressQual.SUPL;
break;
}
case SN:
{
addressQual = AddressQual.ULCO;
break;
}
}
return addressQual;
}
private void mapReferences(final EDICctopInvoicVType invoice, final HEADERXrech headerXrech)
{
final HREFE1 orderRef = INVOICE_objectFactory.createHREFE1();
orderRef.setDOCUMENTID(headerXrech.getDOCUMENTID());
orderRef.setREFERENCEQUAL(ReferenceQual.ORBU.name());
orderRef.setREFERENCE(invoice.getPOReference());
final HREFE1 despatchAdvRef = INVOICE_objectFactory.createHREFE1();
despatchAdvRef.setDOCUMENTID(headerXrech.getDOCUMENTID());
despatchAdvRef.setREFERENCEQUAL(ReferenceQual.DADV.name());
despatchAdvRef.setREFERENCE(invoice.getShipmentDocumentno());
headerXrech.getHREFE1().add(orderRef);
headerXrech.getHREFE1().add(despatchAdvRef);
}
private void mapDates(final EDICctopInvoicVType invoice, final HEADERXrech headerXrech, final String dateFormat)
{
final HDATE1 documentDate = INVOICE_objectFactory.createHDATE1();
documentDate.setDOCUMENTID(headerXrech.getDOCUMENTID());
documentDate.setDATEQUAL(DateQual.CREA.name());
documentDate.setDATEFROM(toFormattedStringDate(toDate(invoice.getDateInvoiced()), dateFormat));
final HDATE1 deliveryDate = INVOICE_objectFactory.createHDATE1();
deliveryDate.setDOCUMENTID(headerXrech.getDOCUMENTID());
deliveryDate.setDATEQUAL(DateQual.DELV.name());
deliveryDate.setDATEFROM(toFormattedStringDate(toDate(invoice.getMovementDate()), dateFormat));
final HDATE1 valueDate = INVOICE_objectFactory.createHDATE1();
valueDate.setDOCUMENTID(headerXrech.getDOCUMENTID());
valueDate.setDATEQUAL(DateQual.VALU.name());
valueDate.setDATEFROM(toFormattedStringDate(toDate(invoice.getDateInvoiced()), dateFormat));
headerXrech.getHDATE1().add(documentDate);
headerXrech.getHDATE1().add(deliveryDate);
headerXrech.getHDATE1().add(valueDate);
}
}