Package com.fourjs.report.facturx
Class AbstractInvoice
- java.lang.Object
-
- com.fourjs.report.facturx.AbstractInvoice
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
computeBT131
static boolean
debug
int
debugIndentationLevel
boolean
recompute
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static BigDecimal
assertNotNull(String lValueVariableClassName, String rValueVariableClassName, BigDecimal variable)
static AbstractInvoice
fromPDFFile(String fileName, boolean recompute)
Creates and Invoice instance from a Factur-X hybrid PDF document.static AbstractInvoice
fromXMLFile(String fileName, boolean recompute)
Creates and Invoice instance from a Factur-X XML document.String
getIndentedDebugPrefix(String prefix)
String
getXMLAsDataURL()
static String
joinVeryLongString(String[] chunks)
Deprecated.UseUtil.joinVeryLongString(java.lang.String[])
instead.static void
main(String[] args)
static LocalDate
parseDate(String s)
Deprecated.UseUtil.parseDate(java.lang.String)
instead.void
setRecompute(boolean value)
Controls the computation of computed fields like#getInvoiceTotalAmountWithoutVAT()
By default the values are always computed but in the case that the values were explicitly set (e.g.abstract void
toJUnitJavaSourceCode(PrintStream out, String packageName, String className, String referenceFilesDirectory)
Creates JUnit Java source code that will construct an Invoice instance identical with this Invoice from API calls and compare the produced XML against a reference file.void
toXML(PrintStream out)
Serializes to a Factur-X XML document that matches the profile specific XML Schema.abstract void
toXML(PrintWriter out)
Serializes to a Factur-X XML document that matches the profile specific XML Schema.
-
-
-
Method Detail
-
toXML
public void toXML(PrintStream out) throws IOException, FacturXException
Serializes to a Factur-X XML document that matches the profile specific XML Schema.- Parameters:
out
- the print stream to write to- Throws:
IOException
FacturXException
-
toXML
public abstract void toXML(PrintWriter out) throws IOException, FacturXException
Serializes to a Factur-X XML document that matches the profile specific XML Schema.- Parameters:
out
- the print stream to write to- Throws:
IOException
FacturXException
-
getXMLAsDataURL
public String getXMLAsDataURL() throws IOException, FacturXException
- Throws:
IOException
FacturXException
-
toJUnitJavaSourceCode
public abstract void toJUnitJavaSourceCode(PrintStream out, String packageName, String className, String referenceFilesDirectory) throws FacturXException
Creates JUnit Java source code that will construct an Invoice instance identical with this Invoice from API calls and compare the produced XML against a reference file.- Parameters:
out
- the print stream to write topackageName
- the package name to use in the package declarationclassName
- the name to use as class name for the test classreferenceFilesDirectory
- the directory in which the test expects the reference output xml file that is namedclassName+".xml"
- Throws:
FacturXException
-
setRecompute
public void setRecompute(boolean value)
Controls the computation of computed fields like#getInvoiceTotalAmountWithoutVAT()
By default the values are always computed but in the case that the values were explicitly set (e.g. after creating and instance via#fromXML(String,boolean)
), it might be desirable to obtain the explicitly set values instead.- Parameters:
value
- whether or not to ignore explicitly set values of computed fields and work with computed values instead
-
fromXMLFile
public static AbstractInvoice fromXMLFile(String fileName, boolean recompute) throws IOException
Creates and Invoice instance from a Factur-X XML document.- Parameters:
fileName
- the Factur-X XML file to read fromrecompute
- specifies whether or not computed fields are computed or the values from the file are used instead- Throws:
IOException
-
fromPDFFile
public static AbstractInvoice fromPDFFile(String fileName, boolean recompute) throws IOException
Creates and Invoice instance from a Factur-X hybrid PDF document.- Parameters:
fileName
- the Factur-X hybrid PDF file to read fromrecompute
- specifies whether or not computed fields are computed or the values from the file are used instead- Returns:
- an Invoice instance or null if the PDF does not contain a file attachment named "factur-x.xml".
- Throws:
IOException
-
assertNotNull
public static BigDecimal assertNotNull(String lValueVariableClassName, String rValueVariableClassName, BigDecimal variable) throws ComputationException
- Throws:
ComputationException
-
parseDate
public static LocalDate parseDate(String s) throws DateTimeParseException
Deprecated.UseUtil.parseDate(java.lang.String)
instead.parses dates in the Factur-x format YYYYMMDD- Throws:
DateTimeParseException
-
joinVeryLongString
public static String joinVeryLongString(String[] chunks)
Deprecated.UseUtil.joinVeryLongString(java.lang.String[])
instead.to be used for strings exceeding the compiler limit of 2^16 bytes for a string constant
-
-