Package com.helger.en16931.cii2ubl
Class AbstractCIIToUBLConverter<IMPLTYPE extends AbstractCIIToUBLConverter<IMPLTYPE>>
- java.lang.Object
-
- com.helger.en16931.cii2ubl.AbstractCIIToUBLConverter<IMPLTYPE>
-
- Type Parameters:
IMPLTYPE- The implementation type
- All Implemented Interfaces:
com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
- Direct Known Subclasses:
CIIToUBL21Converter,CIIToUBL22Converter,CIIToUBL23Converter
public abstract class AbstractCIIToUBLConverter<IMPLTYPE extends AbstractCIIToUBLConverter<IMPLTYPE>> extends Object implements com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
Base class for conversion from CII to UBL.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CARD_ACCOUNT_NETWORK_IDstatic StringDEFAULT_CUSTOMIZATION_IDstatic StringDEFAULT_PROFILE_IDstatic booleanDEFAULT_SWAP_PRICE_SIGN_IF_NEEDEDstatic booleanDEFAULT_SWAP_QUANTITY_SIGN_IF_NEEDEDstatic EUBLCreationModeDEFAULT_UBL_CREATION_MODEstatic StringDEFAULT_VAT_SCHEME
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCIIToUBLConverter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static com.helger.commons.error.IError_buildError(String[] aPath, String sErrorMsg)protected static <T extends com.helger.xsds.ccts.cct.schemamodule.AmountType>
T_copyAmount(un.unece.uncefact.data.standard.unqualifieddatatype._100.AmountType aAmount, T ret, String sDefaultCurrencyCode)protected static <T extends com.helger.xsds.ccts.cct.schemamodule.CodeType>
T_copyCode(un.unece.uncefact.data.standard.unqualifieddatatype._100.CodeType aCode, T ret)protected static <T extends com.helger.xsds.ccts.cct.schemamodule.IdentifierType>
T_copyID(un.unece.uncefact.data.standard.unqualifieddatatype._100.IDType aCIIID, T aUBLID)Copy all ID parts from a CII ID to a CCTS/UBL ID.protected static <T extends com.helger.xsds.ccts.cct.schemamodule.TextType>
T_copyName(un.unece.uncefact.data.standard.unqualifieddatatype._100.TextType aName, T ret)protected static <T extends com.helger.xsds.ccts.cct.schemamodule.QuantityType>
T_copyQuantity(un.unece.uncefact.data.standard.unqualifieddatatype._100.QuantityType aQuantity, T ret)protected static String_getDatePattern(String sFormat, com.helger.commons.error.list.IErrorList aErrorList)Get the pattern based on https://service.unece.org/trade/untdid/d16b/tred/tred2379.htmprotected static LocalDate_parseDate(un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType.DateTimeString aDateObj, com.helger.commons.error.list.IErrorList aErrorList)protected static LocalDate_parseDate(un.unece.uncefact.data.standard.unqualifieddatatype._100.DateTimeType.DateTimeString aDateObj, com.helger.commons.error.list.IErrorList aErrorList)protected static LocalDate_parseDate(un.unece.uncefact.data.standard.unqualifieddatatype._100.DateType.DateString aDateObj, com.helger.commons.error.list.IErrorList aErrorList)protected static com.helger.commons.state.ETriState_parseIndicator(un.unece.uncefact.data.standard.unqualifieddatatype._100.IndicatorType aIndicator, com.helger.commons.error.list.IErrorList aErrorList)protected static booleancanUseGlobalID(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._100.TradePartyType aParty)SerializableconvertCIItoUBL(File aFile, com.helger.commons.error.list.ErrorList aErrorList)Convert CII to UBLabstract SerializableconvertCIItoUBL(un.unece.uncefact.data.standard.crossindustryinvoice._100.CrossIndustryInvoiceType aCIIInvoice, com.helger.commons.error.list.ErrorList aErrorList)Convert CII to UBLprotected static com.helger.commons.collection.impl.ICommonsList<un.unece.uncefact.data.standard.unqualifieddatatype._100.IDType>getAllUsableGlobalIDs(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._100.TradePartyType aParty)StringgetCardAccountNetworkID()StringgetCustomizationID()StringgetProfileID()EUBLCreationModegetUBLCreationMode()StringgetVATScheme()protected static booleanifNotEmpty(Consumer<? super String> aConsumer, String aObj)protected static <T> booleanifNotNull(Consumer<? super T> aConsumer, T aObj)protected static com.helger.commons.state.ETriStateisInvoiceType(un.unece.uncefact.data.standard.crossindustryinvoice._100.CrossIndustryInvoiceType aCIIInvoice)protected static booleanisLT0Strict(BigDecimal aBD)protected static booleanisOriginatorDocumentReferenceTypeCode(String s)protected static booleanisPaymentMeansCodeCreditTransfer(String s)protected static booleanisPaymentMeansCodeDirectDebit(String s)protected static booleanisPaymentMeansCodeOtherKnown(String s)protected static booleanisPaymentMeansCodePaymentCard(String s)booleanisSwapPriceSignIfNeeded()booleanisSwapQuantitySignIfNeeded()protected static booleanisValidDocumentReferenceTypeCode(String s)protected static LocalDateparseDate(String sDate, String sFormat, com.helger.commons.error.list.IErrorList aErrorList)IMPLTYPEsetCardAccountNetworkID(String sCardAccountNetworkID)IMPLTYPEsetCustomizationID(String sCustomizationID)IMPLTYPEsetProfileID(String sProfileID)IMPLTYPEsetSwapPriceSignIfNeeded(boolean bSwapPriceSignIfNeeded)IMPLTYPEsetSwapQuantitySignIfNeeded(boolean bSwapQuantitySignIfNeeded)IMPLTYPEsetUBLCreationMode(EUBLCreationMode eCreationMode)IMPLTYPEsetVATScheme(String sVATScheme)protected voidswapQuantityAndPriceIfNeeded(boolean bLineExtensionAmountIsNegative, BigDecimal aQuantity, Consumer<BigDecimal> aQuantitySetter, BigDecimal aPriceAmount, Consumer<BigDecimal> aPriceAmountSetter)The goal is to have a positive price, because of EN validation rule BT-146.
-
-
-
Field Detail
-
DEFAULT_UBL_CREATION_MODE
public static final EUBLCreationMode DEFAULT_UBL_CREATION_MODE
-
DEFAULT_VAT_SCHEME
public static final String DEFAULT_VAT_SCHEME
- See Also:
- Constant Field Values
-
DEFAULT_CUSTOMIZATION_ID
public static final String DEFAULT_CUSTOMIZATION_ID
- See Also:
- Constant Field Values
-
DEFAULT_PROFILE_ID
public static final String DEFAULT_PROFILE_ID
- See Also:
- Constant Field Values
-
DEFAULT_CARD_ACCOUNT_NETWORK_ID
public static final String DEFAULT_CARD_ACCOUNT_NETWORK_ID
- See Also:
- Constant Field Values
-
DEFAULT_SWAP_QUANTITY_SIGN_IF_NEEDED
public static final boolean DEFAULT_SWAP_QUANTITY_SIGN_IF_NEEDED
- See Also:
- Constant Field Values
-
DEFAULT_SWAP_PRICE_SIGN_IF_NEEDED
public static final boolean DEFAULT_SWAP_PRICE_SIGN_IF_NEEDED
- See Also:
- Constant Field Values
-
-
Method Detail
-
ifNotNull
protected static <T> boolean ifNotNull(@Nonnull Consumer<? super T> aConsumer, @Nullable T aObj)
-
ifNotEmpty
protected static boolean ifNotEmpty(@Nonnull Consumer<? super String> aConsumer, @Nullable String aObj)
-
getUBLCreationMode
@Nonnull public final EUBLCreationMode getUBLCreationMode()
-
setUBLCreationMode
@Nonnull public final IMPLTYPE setUBLCreationMode(@Nonnull EUBLCreationMode eCreationMode)
-
setCustomizationID
@Nonnull public final IMPLTYPE setCustomizationID(@Nonnull String sCustomizationID)
-
setCardAccountNetworkID
@Nonnull public final IMPLTYPE setCardAccountNetworkID(@Nonnull String sCardAccountNetworkID)
-
isSwapQuantitySignIfNeeded
public final boolean isSwapQuantitySignIfNeeded()
-
setSwapQuantitySignIfNeeded
@Nonnull public final IMPLTYPE setSwapQuantitySignIfNeeded(boolean bSwapQuantitySignIfNeeded)
-
isSwapPriceSignIfNeeded
public final boolean isSwapPriceSignIfNeeded()
-
setSwapPriceSignIfNeeded
@Nonnull public final IMPLTYPE setSwapPriceSignIfNeeded(boolean bSwapPriceSignIfNeeded)
-
_buildError
@Nonnull protected static com.helger.commons.error.IError _buildError(@Nullable String[] aPath, String sErrorMsg)
-
_getDatePattern
@Nullable protected static String _getDatePattern(@Nonnull @Nonempty String sFormat, @Nonnull com.helger.commons.error.list.IErrorList aErrorList)
Get the pattern based on https://service.unece.org/trade/untdid/d16b/tred/tred2379.htm- Parameters:
sFormat- Format to use. May benull.aErrorList- The error list to be filled if an unsupported format is provided.- Returns:
nullif the format is unknown.
-
parseDate
@Nullable protected static LocalDate parseDate(@Nullable String sDate, @Nullable String sFormat, @Nonnull com.helger.commons.error.list.IErrorList aErrorList)
-
_parseDate
@Nullable protected static LocalDate _parseDate(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.DateTimeType.DateTimeString aDateObj, @Nonnull com.helger.commons.error.list.IErrorList aErrorList)
-
_parseDate
@Nullable protected static LocalDate _parseDate(@Nullable un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType.DateTimeString aDateObj, @Nonnull com.helger.commons.error.list.IErrorList aErrorList)
-
_parseDate
@Nullable protected static LocalDate _parseDate(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.DateType.DateString aDateObj, @Nonnull com.helger.commons.error.list.IErrorList aErrorList)
-
_parseIndicator
@Nonnull protected static com.helger.commons.state.ETriState _parseIndicator(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.IndicatorType aIndicator, @Nonnull com.helger.commons.error.list.IErrorList aErrorList)
-
_copyID
@Nullable protected static <T extends com.helger.xsds.ccts.cct.schemamodule.IdentifierType> T _copyID(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.IDType aCIIID, @Nonnull T aUBLID)
Copy all ID parts from a CII ID to a CCTS/UBL ID.- Parameters:
aCIIID- CII IDaUBLID- UBL ID- Returns:
- Created UBL ID
-
_copyName
@Nullable protected static <T extends com.helger.xsds.ccts.cct.schemamodule.TextType> T _copyName(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.TextType aName, @Nonnull T ret)
-
_copyCode
@Nullable protected static <T extends com.helger.xsds.ccts.cct.schemamodule.CodeType> T _copyCode(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.CodeType aCode, @Nonnull T ret)
-
_copyQuantity
@Nullable protected static <T extends com.helger.xsds.ccts.cct.schemamodule.QuantityType> T _copyQuantity(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.QuantityType aQuantity, @Nonnull T ret)
-
_copyAmount
@Nullable protected static <T extends com.helger.xsds.ccts.cct.schemamodule.AmountType> T _copyAmount(@Nullable un.unece.uncefact.data.standard.unqualifieddatatype._100.AmountType aAmount, @Nonnull T ret, @Nullable String sDefaultCurrencyCode)
-
isPaymentMeansCodeCreditTransfer
protected static boolean isPaymentMeansCodeCreditTransfer(@Nullable String s)
-
isPaymentMeansCodePaymentCard
protected static boolean isPaymentMeansCodePaymentCard(@Nullable String s)
-
isPaymentMeansCodeDirectDebit
protected static boolean isPaymentMeansCodeDirectDebit(@Nullable String s)
-
isPaymentMeansCodeOtherKnown
protected static boolean isPaymentMeansCodeOtherKnown(@Nullable String s)
-
isOriginatorDocumentReferenceTypeCode
protected static boolean isOriginatorDocumentReferenceTypeCode(@Nullable String s)
-
isValidDocumentReferenceTypeCode
protected static boolean isValidDocumentReferenceTypeCode(@Nullable String s)
-
isLT0Strict
protected static boolean isLT0Strict(@Nullable BigDecimal aBD)
-
canUseGlobalID
protected static boolean canUseGlobalID(@Nonnull un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._100.TradePartyType aParty)
-
getAllUsableGlobalIDs
@Nonnull protected static com.helger.commons.collection.impl.ICommonsList<un.unece.uncefact.data.standard.unqualifieddatatype._100.IDType> getAllUsableGlobalIDs(@Nonnull un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._100.TradePartyType aParty)
-
swapQuantityAndPriceIfNeeded
protected void swapQuantityAndPriceIfNeeded(boolean bLineExtensionAmountIsNegative, @Nonnull BigDecimal aQuantity, @Nonnull Consumer<BigDecimal> aQuantitySetter, @Nullable BigDecimal aPriceAmount, @Nullable Consumer<BigDecimal> aPriceAmountSetter)The goal is to have a positive price, because of EN validation rule BT-146. This method fiddles with Quantity and Price to align this as best as possible.- Parameters:
bLineExtensionAmountIsNegative- is the line sum negative?aQuantity- Existing line quantity.aQuantitySetter- Setter to change line quantityaPriceAmount- Optional line price amountaPriceAmountSetter- Optional setter to change line price amount
-
isInvoiceType
@Nonnull protected static com.helger.commons.state.ETriState isInvoiceType(@Nonnull un.unece.uncefact.data.standard.crossindustryinvoice._100.CrossIndustryInvoiceType aCIIInvoice)
-
convertCIItoUBL
@Nullable public Serializable convertCIItoUBL(@Nonnull File aFile, @Nonnull com.helger.commons.error.list.ErrorList aErrorList)
Convert CII to UBL- Parameters:
aFile- Source file with CII to be parsed. May not benull.aErrorList- Error list to be filled. May not benull.- Returns:
- The parsed Invoice or CreditNote as UBL 2.x. May be
nullin case of error.
-
convertCIItoUBL
@Nullable public abstract Serializable convertCIItoUBL(@Nonnull un.unece.uncefact.data.standard.crossindustryinvoice._100.CrossIndustryInvoiceType aCIIInvoice, @Nonnull com.helger.commons.error.list.ErrorList aErrorList)
Convert CII to UBL- Parameters:
aCIIInvoice- The CII invoice to be converted. May not benull. Ideally this is a valid CII invoice only and not some handcrafted domain object.aErrorList- Error list to be filled. May not benull.- Returns:
- The parsed
InvoiceTypeorCreditNoteType. May benullin case of error.
-
-