I have asked this question before and didn't receive satisfactory answer, so this time I'd try to be more specific.
I would like to implement a server in golang which outputs dynamic status updates in the form of svg. (Think "Build Passing/Failing" GitHub Badges.) The purpose is that one should be able to embed a link to the server's address in GitHub Readme and the Readme should update automatically depending on the server state.
Here's the golang code that I came up with but it doesn't seem to work with GitHub aggressive caching. Do I need to add more Cache-Control headers? Do I need to add ETag?
I'm using the following to embed the image in GitHub Readme.
[![Mine](http://58dcd0b5.ngrok.com/view)]()
Ideally, I would like to see the GitHub Readme change the image every time I load it -- flipping between the two images "correct"/"wrong". (This is just a proof of concept.)
package main
import (
"log"
"net/http"
_ "time"
)
var mymap map[string][]byte
var state bool = false
func viewHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("State %v", state)
state = !state
w.Header().Set("Content-Type", "image/svg+xml")
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
if state {
w.Write(mymap["correct"])
} else {
w.Write(mymap["wrong"])
}
}
func main() {
mymap = make(map[string][]byte)
mymap["correct"] = []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="104" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="104" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#4c1" d="M54 0h50v20H54z"/><path fill="url(#b)" d="M0 0h104v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="78" y="15" fill="#010101" fill-opacity=".3">correct</text><text x="78" y="14">correct</text></g></svg>`)
mymap["wrong"] = []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="99" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#e05d44" d="M54 0h45v20H54z"/><path fill="url(#b)" d="M0 0h99v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="75.5" y="15" fill="#010101" fill-opacity=".3">wrong</text><text x="75.5" y="14">wrong</text></g></svg>`)
mux := http.NewServeMux()
mux.HandleFunc("/view", viewHandler)
http.ListenAndServe(":8085", mux)
}
Here's what travis are serving for their images:
Age:0
Cache-Control:no-cache
Content-Length:0
Date:Mon, 30 Mar 2015 07:49:10 GMT
ETag:"88e168c2d5cdb30ee9af739765e78e4d"
Expires:Mon, 30 Mar 2015 07:49:10 GMT
Keep-Alive:timeout=10, max=48
Last-Modified:Wed, 07 Jan 2015 11:26:53 GMT
Timing-Allow-Origin:https://github.com
X-Timer:S1427701750.146025,VS0,VE156
It might be a good start to try these and see what works.
Here is a Github issue about it : https://github.com/github/markup/issues/224
Assets must include Cache-Control: no-cache and ETag headers. If a
badge is not updating, then it means they are not properly setting
these headers.
and
The assets may also need to include either an ETag or Expires header.
Fastly's docs on Cache-Control say that no-cache means "re-validate
before serving this content", but it doesn't specify what it does to
"re-validate". I'm guessing it is re-validating, but there's no
indication that the asset has changed, so it continues to serves the
cached asset.
An ETag would be the biggest win, since it would guarantee that the
cache gets refreshed when it changes, but still saves bandwidth.
Following this commit to shields.io server, I made the following changes to the above code and it works now.
w.Header().Set("Date", date)
w.Header().Set("Expires", date)
For completeness (and in case someone wants to try it out), here's the complete code. (Also on GitHub.)
package main
import (
"log"
"net/http"
"time"
)
var mymap map[string][]byte
var state bool = false
func viewHandler(w http.ResponseWriter, r *http.Request) {
date := time.Now().Format(http.TimeFormat)
log.Printf("%v", date)
log.Printf("State %v", state)
state = !state
w.Header().Set("Content-Type", "image/svg+xml")
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Date", date)
w.Header().Set("Expires", date)
if state {
w.Write(mymap["correct"])
} else {
w.Write(mymap["wrong"])
}
}
func main() {
mymap = make(map[string][]byte)
mymap["correct"] = []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="104" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="104" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#4c1" d="M54 0h50v20H54z"/><path fill="url(#b)" d="M0 0h104v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="78" y="15" fill="#010101" fill-opacity=".3">correct</text><text x="78" y="14">correct</text></g></svg>`)
mymap["wrong"] = []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="99" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#e05d44" d="M54 0h45v20H54z"/><path fill="url(#b)" d="M0 0h99v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="75.5" y="15" fill="#010101" fill-opacity=".3">wrong</text><text x="75.5" y="14">wrong</text></g></svg>`)
mux := http.NewServeMux()
mux.HandleFunc("/view", viewHandler)
log.Println("Server started. Listening on 8085...")
http.ListenAndServe(":8085", mux)
}
Related
I have to create multiple XY-line charts with different dataset using same chart report template and I also have to use JRBeanCollectionDatasource for it.
Requirements:
1) Should be done using JRBeanCollectionDatasource.
2) Have to use the same chart report template to create multiple charts.
3) Number of charts are not fixed (Here I have problem giving names to Report Parameter in java). Because in ReportParametersMap, they can only have unique key name .
Java:
Coordinates.java
private Number series;
private Number xCoordinate;
private Number yCoordinate;
//Getters & Setters
GenerateReport.java
I am working with Report Book and each report template of the report book is considered as a sub-report. So I am passing XYChartDataSource(java.util.List) to master report book and I would map this parameter with the subreport by using
new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{XYChartDataSource}) as a Datasource Expression.
and in Subreport, I have created a parameter XYChartDataSource(java.util.List) and created fields (series,xCoordinate,yCoordinate) in MainDataset ( used in chart)
List<List<Coordinates>> allchartData = new ArrayList<>();
List<Coordinates> chartData = new ArrayList<>();
chartData.add(new Coordinates(2.08, xCoordinate, yCoordinate));
chartData.add(new Coordinates(2.08, xCoordinate, yCoordinate));
chartData.add(new Coordinates(2.08, xCoordinate, yCoordinate));
allchartData.add(chartData);
.
.
.
chartData.add(new Coordinates(2.12, xCoordinate, yCoordinate));
chartData.add(new Coordinates(2.12, xCoordinate, yCoordinate));
chartData.add(new Coordinates(2.12, xCoordinate, yCoordinate));
allchartData.add(chartData);
.
.
.
for (int i = 0; i < baselineChartData.size(); i++) {
parameters.put("XYChartDataSource", allchartData.get(i));
}
main_report_book.jrxml
<parameter name="XYChartDataSource" class="java.util.List"/>
<part uuid="5e668430-9acd-4835-be21-f4e2902ce33d">
<p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
<subreportParameter name="REPORT_DATA_SOURCE">
<subreportParameterExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{XYChartDataSource})]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/sub_chart.jasper"]]></subreportExpression>
</p:subreportPart>
</part>
sub_chart.jrxml
<parameter name="XYChartDataSource" class="java.util.List"/>
<field name="xCoordinate" class="java.lang.Double"/>
<field name="yCoordinate" class="java.lang.Double"/>
<field name="series" class="java.lang.Double"/>
<summary>
<band height="405">
<xyLineChart>
<chart evaluationTime="Report" bookmarkLevel="1">
<reportElement x="30" y="98" width="525" height="230" uuid="627d87d6-b675-409c-accb-b2bb3ffb9c80">
<property name="net.sf.jasperreports.chart.domain.axis.tick.interval" value="1"/>
</reportElement>
<chartTitle/>
<chartSubtitle/>
<chartLegend position="Right"/>
</chart>
<xyDataset>
<xySeries autoSort="true">
<seriesExpression><![CDATA[$F{series}]]></seriesExpression>
<xValueExpression><![CDATA[$F{xCoordinate}]]></xValueExpression>
<yValueExpression><![CDATA[$F{yCoordinate}]]></yValueExpression>
</xySeries>
</xyDataset>
<linePlot isShowShapes="false">
<plot/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</linePlot>
</xyLineChart>
</textField>
</band>
</summary>
Current Output:
only one chart is being printed, using the regular method.
Expected Output:
Here I am showing two charts(could be more in actual output) , which needs to be generated from same report template in the SAME PDF REPORT:
chart1
chart2
You problem is here:
for (int i = 0; i < baselineChartData.size(); i++) {
parameters.put("XYChartDataSource", allchartData.get(i));
}
Your parameter "XYChartDataSource" will contain last entry in your List, you replace each time in loop see Map.put(K key,V value))
What we need instead is the whole list
parameters.put("XYChartDataSource", allchartData);
However now we can't access directly the List<Coordinates>
On solution to not change your current subreport is to insert another subreport in the middle which will iterate your List<List<Coordinates>> in detail band.
The structure will be
Pass List<List<Coordinates>> allchartData as datasource to this new subreport (sub_charts.jrxml)
Define the field _THIS which is List<Coordinates> in subreport (hence it's iterating your List<List<Coordinates>>)
In detail band include current sub_chart.jrxml and pass $F{_THIS} as datasource
sub_charts.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="sub_charts" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bc8c76ba-0b85-4522-bf67-4c62ae87202b">
<field name="_THIS" class="java.util.List">
<fieldDescription>_THIS</fieldDescription>
</field>
<detail>
<band height="63" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="550" height="60" uuid="b0e761bf-fe02-4a0a-bafb-32d6831b7a13"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{_THIS})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/sub_chart.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
Remember to call this new subreport in your main_report_book.jrxml.
<subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/sub_charts.jasper"]]></subreportExpression>
The OP Dhruvil Thaker did this great graphical representation of this answer.
I'm using Jasper Reports to build a simple report pdf. I have a JSON file that looks like this:
{"employees": [
{"firstName" : "John", "lastName" : "Doe"},
{"firstName" : "Anna", "lastName" : "Smith"},
{"firstName" : "Peter", "lastName" : "Jones"}
]}
And I'm trying to read it in like this:
File file = new File("E:/Workspaces/jasperPDFreport/src/main/resources/emp.json");
JsonDataSource datasource = new JsonDataSource(file);
JasperDesign jasperDesign = JRXmlLoader.load("E:/Workspaces/jasperPDFreport/src/main/resources/jsonTemplate.jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
Map parameters = new HashMap();
JasperPrint jasperPrint;
jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, datasource);
JasperExportManager.exportReportToPdfFile(jasperPrint, "BasicReport.pdf");
JasperViewer.viewReport(jasperPrint);
However my the values from the JSON file are not passed to my pdf.
This is my Template:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1 -->
<!-- 2015-10-22T13:45:32 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9e494ebe-c1fb-4448-bcee-38994e9720f7">
<!--property name="net.sf.jasperreports.json.source" value="emp.json"/-->
<queryString language="json">
<![CDATA[employees]]>
</queryString>
<field name="firstName" class="java.lang.String">
<fieldDescription><![CDATA[firstName]]></fieldDescription>
</field>
<field name="lastName" class="java.lang.String">
<fieldDescription><![CDATA[lastName]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="100" y="0" width="100" height="30" uuid="02b279da-3795-4655-8571-5a36a3ef378c"/>
<textFieldExpression><![CDATA[$F{firstName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="671e61ad-8d8f-48cb-969f-78c05a516398"/>
<text><![CDATA[firstName]]></text>
</staticText>
<textField>
<reportElement x="100" y="30" width="100" height="30" uuid="9d53f46f-a252-48b3-9213-8c3092c29f49"/>
<textFieldExpression><![CDATA[$F{lastName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="30" width="100" height="30" uuid="3b49affb-685a-4df2-a872-c0e6fdcab94b"/>
<text><![CDATA[lastName]]></text>
</staticText>
</band>
</detail>
</jasperReport>
Now you see the commented out line
property name="net.sf.jasperreports.json.source" value="emp.json"
If I comment this in, everything works as intended, I don't want to hard code my JSON values into the template, because later on I want to get them from a rest service, that's not ready yet. I do not understand, why the values are not getting parsed into the report, instead i just get two null values.
From JasperReports - JSON Data Source Sample (version 6.4.3)
The built-in JSON query executer (see the JsonQueryExecuter class) is a tool that uses the query string to produce a JsonDataSource instance, based on specific built-in parameters (or equivalent report properties). This query executer is registered via JsonQueryExecuterFactory factory class.
In order to prepare the data source, the JSON query executer looks for the JSON_INPUT_STREAM parameter that contains the JSON source objects in the form of an java.io.InputStream. If no JSON_INPUT_STREAM parameter is provided, then the query executer looks for the alternate net.sf.jasperreports.json.source String parameter or report property that stores the path to the location of the JSON source file.
JsonQueryExecuter runs the query over the input source and stores the result in an in-memory JsonDataSource object.
So if you do not want to use:
<property name="net.sf.jasperreports.json.source" value="emp.json"/>
You need to pass the file as java.io.InputStream in the parameter JSON_INPUT_STREAM
Hence you are currently passing it as datasource you should try something like this
params.put(JsonQueryExecuterFactory.JSON_INPUT_STREAM, new FileInputStream(file));
JasperFillManager.fillReportToFile(jasperReport, params);
If you instead like to use the new JsonQLQueryExecuterFactory JSONQL Data Source
params.put(JsonQLQueryExecuterFactory.JSON_INPUT_STREAM, new FileInputStream(file));
JasperFillManager.fillReportToFile(jasperReport, params);
If you pass your json string as InputStream then it will works.
String reportContents = "{}" //your json
InputStream is = new ByteArrayInputStream(reportContent.getBytes());
Map params = new HashMap();
params.put(JsonQueryExecuterFactory.JSON_INPUT_STREAM, is);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params);
Take a look here for data source implementation that wraps a collection of JavaBean objects.
List<YourClass> yourBeanCollection = queryDataFromJSON();
JRDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(yourBeanCollection);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
reportParams, beanCollectionDataSource);
and in the report template import java.util and declare the collection which you "injected" in the report
<import value="java.util.*"/>
<field name="yourBeanCollection" class="java.util.List"/>
also take a look here for an example
We are building an application using IPP v3 that will sync invoices from our SaaS app to QBOE (and hopefully QBD). The problem are are encountering is with replicating the sales on our invoices with the invoices created in quickbooks.
Specifically, our invoices can have line items which are not taxable (each state is different in terms of which items are taxed and at what rate). Also there are many times both state, city and county taxes, some of which apply to some line items and not to others.
It appears for the IPP v3 US version, taxes must be global to the invoice?
I think that all of this could be solved if we could just override the total tax amount for the invoice. Documentations seems to indicate that API supports that. However, all my attempts were ignored. It's either no Tax or default tax rate (in percentage). That means that we can't override totals or enter fixed taxes.
Another option would be to add an extra line to the invoice named "Tax Name" and the value. The invoice total would be correct but Tax Reports on quickbooks wouldn't?
I would really like a straight answer like "tax amount cannot be overridden through the API" just to be sure.
I would also like to know if Intuit plans to support that feature in a near future?
There are fields in the API like "PercentBased" (which can be set to true or false) that seem to indicate that fixed amounts can be set. But these fields are completely ignored when I try to use them.
Any help or future guidance on this would be greatly appreciate as it pertains to IPP v3 for QBOE / QBD.
Here's our XML request
<?xml version='1.0' encoding='utf-8'?>
<IntuitBatchRequest xmlns:ns2="http://www.intuit.com/sb/cdm/qbo"
xmlns="http://schema.intuit.com/finance/v3">
<BatchItemRequest bId="bid1" operation="create">
<Invoice>
<DocNumber>2459999</DocNumber>
<TxnDate>2012-12-10</TxnDate>
<GlobalTaxCalculation>TaxIncluded</GlobalTaxCalculation>
<Line>
<DetailType>SalesItemLineDetail</DetailType>
<Amount>200</Amount>
<SalesItemLineDetail>
<TaxCodeRef>TAX</TaxCodeRef>
<ServiceDate>2012-12-10</ServiceDate>
</SalesItemLineDetail>
<Description>Test</Description>
<ItemRef>1</ItemRef>
</Line>
<CustomerRef>66</CustomerRef>
<TxnTaxDetail>
<TaxLine>
<DetailType>TaxLineDetail</DetailType>
<Amount>13.00</Amount>
<TaxLineDetail>
<NetAmountTaxable>200.00</NetAmountTaxable>
<TaxPercent>6.50</TaxPercent>
<TaxRateRef>1</TaxRateRef>
<PercentBased>true</PercentBased>
</TaxLineDetail>
</TaxLine>
</TxnTaxDetail>
</Invoice>
</BatchItemRequest>
</IntuitBatchRequest>
You can override the tax amount in the Taxline in TxnTaxDetail-
Eg:
Includes tax # 20% on 16.67 = 3.33. we would expect the request to include following tax details
"TxnTaxDetail": {
"TotalTax":3.33,
"TaxLine":[
{
"Amount":3.33,
"DetailType": "TaxLineDetail",
"TaxLineDetail": {
"TaxRateRef": {
"value":"4"
},
"PercentBased":true,
"TaxPercent": 20,
"NetAmountTaxable": 16.67
"GlobalTaxCalculation": "TaxIncludes",...
Please refer-
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v3/020_key_concepts/0700_other_topics#TxnTaxDetail
EDIT:
Adding the sample request and response xml. Just set the following tags.
<TxnTaxDetail>
<TxnTaxCodeRef>
<TotalTax>
</TxnTaxDetail>
Do not set the Taxline as QBO recalculates the tax based on the details sent in the request. So in response you’ll get the recalculated amount based in the TaxPercent specified.
Request sample-
<?xml version="1.0"?>
<Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schema.intuit.com/finance/v3">
<TxnDate>2013-10-11+05:30</TxnDate>
<PrivateNote>This is a private note</PrivateNote>
<Line>
<Description>Invoice line description.</Description>
<Amount>900</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<SalesItemLineDetail>
<ItemRef name="Bat">2</ItemRef>
<UnitPrice>90</UnitPrice>
<Qty>10</Qty>
<TaxCodeRef>TAX</TaxCodeRef>
<ServiceDate>2013-10-11+05:30</ServiceDate>
</SalesItemLineDetail>
</Line>
<TxnTaxDetail>
<TxnTaxCodeRef name="StateSalesTax">8</TxnTaxCodeRef>
<TotalTax>450</TotalTax>
</TxnTaxDetail>
<AutoDocNumber>true</AutoDocNumber>
<CustomerRef name="5748584cc7d64bb18a0e">23</CustomerRef>
<BillAddr>
<Line1>123 Main St.</Line1>
<Line2>Unit 506</Line2>
<City>Brockton</City>
<Country>United States</Country>
<CountrySubDivisionCode>MA</CountrySubDivisionCode>
<PostalCode>02301</PostalCode>
<Note>Billing Address Note</Note>
</BillAddr>
<ShipAddr>
<Line1>100 Fifth Ave.</Line1>
<City>Waltham</City>
<Country>United States</Country>
<CountrySubDivisionCode>MA</CountrySubDivisionCode>
<PostalCode>02452</PostalCode>
<Note>Shipping Address Note</Note>
</ShipAddr>
<SalesTermRef name="Due on receipt">1</SalesTermRef>
<DueDate>2013-11-10+05:30</DueDate>
<GlobalTaxCalculation>TaxInclusive</GlobalTaxCalculation>
<ARAccountRef name="Accounts Receivable (A/R)">32</ARAccountRef>
</Invoice>
Response sample-
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-10-18T01:50:19.576-07:00">
<Invoice domain="QBO" sparse="false">
<Id>50</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2013-10-18T01:50:20-07:00</CreateTime>
<LastUpdatedTime>2013-10-18T01:50:20-07:00</LastUpdatedTime>
</MetaData>
<DocNumber>1037</DocNumber>
<TxnDate>2013-10-11</TxnDate>
<PrivateNote>This is a private note</PrivateNote>
<Line>
<Id>1</Id>
<LineNum>1</LineNum>
<Description>Invoice line test</Description>
<Amount>900.00</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<SalesItemLineDetail>
<ItemRef name="Bat">2</ItemRef>
<UnitPrice>90</UnitPrice>
<Qty>10</Qty>
<TaxCodeRef>TAX</TaxCodeRef>
<ServiceDate>2013-10-11</ServiceDate>
</SalesItemLineDetail>
</Line>
<Line>
<Amount>900.00</Amount>
<DetailType>SubTotalLineDetail</DetailType>
<SubTotalLineDetail />
</Line>
<TxnTaxDetail>
<TxnTaxCodeRef>8</TxnTaxCodeRef>
<TotalTax>450.00</TotalTax>
<TaxLine>
<Amount>450.00</Amount>
<DetailType>TaxLineDetail</DetailType>
<TaxLineDetail>
<TaxRateRef>18</TaxRateRef>
<PercentBased>true</PercentBased>
<TaxPercent>2.5</TaxPercent>
<NetAmountTaxable>900.00</NetAmountTaxable>
</TaxLineDetail>
</TaxLine>
</TxnTaxDetail>
<CustomerRef name="5748584cc7d64bb18a0e">23</CustomerRef>
<BillAddr>
<Id>78</Id>
<Line1>123 Main St.</Line1>
<Line2>Unit 506</Line2>
<City>Brockton</City>
<Country>United States</Country>
<CountrySubDivisionCode>MA</CountrySubDivisionCode>
<PostalCode>02301</PostalCode>
<Lat>42.0829092</Lat>
<Long>-71.01995200000002</Long>
</BillAddr>
<ShipAddr>
<Id>79</Id>
<Line1>100 Fifth Ave.</Line1>
<City>Waltham</City>
<Country>United States</Country>
<CountrySubDivisionCode>MA</CountrySubDivisionCode>
<PostalCode>02452</PostalCode>
<Lat>42.3933303</Lat>
<Long>-71.256777</Long>
</ShipAddr>
<SalesTermRef>1</SalesTermRef>
<DueDate>2013-11-10</DueDate>
<TotalAmt>1350.00</TotalAmt>
<ApplyTaxAfterDiscount>false</ApplyTaxAfterDiscount>
<PrintStatus>NeedToPrint</PrintStatus>
<EmailStatus>NotSet</EmailStatus>
<Balance>1350.00</Balance>
<Deposit>0</Deposit>
<AllowIPNPayment>false</AllowIPNPayment>
<AllowOnlinePayment>false</AllowOnlinePayment>
</Invoice>
</IntuitResponse>
EDIT for Global-
Ok, I retested this fr Global.
I can override amounts for individual taxlines and then final taxamount-
here is an invoice update request -
I changed the following tags-
<TxnTaxDetail>
<TotalTax>2.90</TotalTax>
and then in one of the taxlines
<TaxLine>
<Amount>0.70</Amount>
and then in the final invoice amounts
<TotalAmt>79.90</TotalAmt>
<Balance>79.90</Balance>
<Invoice xmlns="http://schema.intuit.com/finance/v3" domain="QBO" sparse="false">
<Id>1</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2015-01-30T09:32:06-08:00</CreateTime>
<LastUpdatedTime>2015-01-30T09:32:06-08:00</LastUpdatedTime>
</MetaData>
<DocNumber>1001</DocNumber>
<TxnDate>2015-01-30</TxnDate>
<CurrencyRef name="Canadian Dollar">CAD</CurrencyRef>
<Line>
<Id>1</Id>
<LineNum>1</LineNum>
<Amount>33.00</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<SalesItemLineDetail>
<ItemRef name="Hours">2</ItemRef>
<UnitPrice>33</UnitPrice>
<Qty>1</Qty>
<TaxCodeRef>7</TaxCodeRef>
</SalesItemLineDetail>
</Line>
<Line>
<Id>2</Id>
<LineNum>2</LineNum>
<Amount>44.00</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<SalesItemLineDetail>
<ItemRef name="Sales">1</ItemRef>
<UnitPrice>44</UnitPrice>
<Qty>1</Qty>
<TaxCodeRef>5</TaxCodeRef>
</SalesItemLineDetail>
</Line>
<Line>
<Amount>77.00</Amount>
<DetailType>SubTotalLineDetail</DetailType>
<SubTotalLineDetail />
</Line>
<TxnTaxDetail>
<TotalTax>2.90</TotalTax>
<TaxLine>
<Amount>2.20</Amount>
<DetailType>TaxLineDetail</DetailType>
<TaxLineDetail>
<TaxRateRef>6</TaxRateRef>
<PercentBased>true</PercentBased>
<TaxPercent>5</TaxPercent>
<NetAmountTaxable>44.00</NetAmountTaxable>
</TaxLineDetail>
</TaxLine>
<TaxLine>
<Amount>0.70</Amount>
<DetailType>TaxLineDetail</DetailType>
<TaxLineDetail>
<TaxRateRef>15</TaxRateRef>
<PercentBased>true</PercentBased>
<TaxPercent>2</TaxPercent>
<NetAmountTaxable>33.00</NetAmountTaxable>
</TaxLineDetail>
</TaxLine>
</TxnTaxDetail>
<CustomerRef name="dd">1</CustomerRef>
<SalesTermRef>3</SalesTermRef>
<DueDate>2015-03-01</DueDate>
<GlobalTaxCalculation>TaxExcluded</GlobalTaxCalculation>
<TotalAmt>79.90</TotalAmt>
<PrintStatus>NotSet</PrintStatus>
<EmailStatus>NotSet</EmailStatus>
<Balance>79.90</Balance>
<Deposit>0</Deposit>
<AllowIPNPayment>false</AllowIPNPayment>
<AllowOnlinePayment>false</AllowOnlinePayment>
<AllowOnlineCreditCardPayment>false</AllowOnlineCreditCardPayment>
<AllowOnlineACHPayment>false</AllowOnlineACHPayment>
I am trying to use barcode in JasperReports for which I am using the barcode4j jar.
The jars that i am using are:
barcode4j-2.0.jar
commons-beanutils.jar
commons-codec-1.6.jar
commons-collections.jar
commons-digester-2.0.jar
commons-lang-2.0.jar
commons-logging.jar
commons-net-1.2.2.jar
commons-validator.jar
db2jcc.jar
db2jcc_license_cu.jar
itext-2.1.7.jar
jasperreports-4.5.0.jar
log4j-1.2.8.jar
poi-3.8-20120326.jar
The jrxml file content where I am using barcode is as given below:
<title>
<band height="125">
<frame>
<reportElement x="0" y="0" width="555" height="40" />
<componentElement>
<reportElement style="Barcode" x="5" y="5" width="400" height="30"/>
<c:Code39 xmlns:c="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<c:codeExpression>$F{OPA_ACK_NO_PK}</c:codeExpression>
</c:Code39>
</componentElement>
</frame>
</band>
</title>
But I am getting the following error:
net.sf.jasperreports.engine.JRRuntimeException: Could not resolve style(s): Barcode4j
at net.sf.jasperreports.engine.fill.JRFillObjectFactory.checkUnresolvedReferences(JRFillObjectFactory.java:1577)
at net.sf.jasperreports.engine.fill.JRFillObjectFactory.setStyles(JRFillObjectFactory.java:1504)
at net.sf.jasperreports.engine.fill.JRBaseFiller.loadStyles(JRBaseFiller.java:912)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:804)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:746)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at Report.Test.main(Test.java:162)
Please guide me as to what am I doing wrong?
After removing the comment for Barcode style tag, i got rid of that error and got another exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/batik/bridge/UserAgent
at net.sf.jasperreports.components.barcode4j.BarcodeSVGImageProducer.createImage(BarcodeSVGImageProducer.java:69)
at net.sf.jasperreports.components.barcode4j.BarcodeFillComponent.setBarcodeImage(BarcodeFillComponent.java:149)
at net.sf.jasperreports.components.barcode4j.BarcodeFillComponent.fill(BarcodeFillComponent.java:113)
at net.sf.jasperreports.engine.fill.JRFillComponentElement.fill(JRFillComponentElement.java:148)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.fillElements(JRFillElementContainer.java:570)
at net.sf.jasperreports.engine.fill.JRFillFrame.fill(JRFillFrame.java:276)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.fillElements(JRFillElementContainer.java:570)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:406)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:352)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:323)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:257)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:746)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at Report.Test.main(Test.java:169)
I added the required batik, crimson, xerces and xercesImpl jars. But I am getting the following error:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.batik.bridge.ViewBox.getPreserveAspectRatioTransform([FSZFF)Ljava/awt/geom/AffineTransform; from class net.sf.jasperreports.renderers.BatikRenderer
at net.sf.jasperreports.renderers.BatikRenderer.render(BatikRenderer.java:123)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1405)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:757)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportFrame(JRPdfExporter.java:2554)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:765)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:721)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:635)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:383)
at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:122)
at Report.Test.main(Test.java:172)
You should add library batik-bridge:
<dependency>
<groupId>batik</groupId>
<artifactId>batik-bridge</artifactId>
<version>1.6-1</version>
</dependency>
Yesterday i had exactly the same problem, i succeded to resolve it by using:
<componentElement>
<reportElement x="311" y="166" width="180" height="10"/>
<jr:barbecue xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" type="Code39 (Extended)" drawText="false" checksumRequired="false">
<jr:codeExpression><![CDATA[$P{barcode}]]></jr:codeExpression>
</jr:barbecue>
</componentElement>
For me adding batik-bridge with below dependency to project pom.xml worked:
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-bridge</artifactId>
<version>1.9.1</version>
</dependency>
I have a strange problem with Jasper Report and XML data sources. I have two reports that works great inside iReport (a preview shows all correct data), but when I run the report with JasperRunManager.runReportToPdfFile, the values show up as null. Funny thing is that one of the two reports have sub reports, and in the sub reports, everything shows up correctly!
I'm using XPath with a query like this:
<queryString language="xPath">
<![CDATA[/rosterArray/list/studentRoster]]>
</queryString>
and I only have one field:
<field name="studentName" class="java.lang.String">
<fieldDescription><![CDATA[studentName]]></fieldDescription>
</field>
And display it:
<detail>
<band height="30" splitType="Stretch">
<textField>
<reportElement x="10" y="6" width="188" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{studentName}]]></textFieldExpression>
</textField>
</band>
</detail>
XML looks like this:
<rosterArray>
<list>
<studentRoster>
<studentName>Robert, Pascal</studentName>
</studentRoster>
</list>
</rosterArray>
And the code to create the generated report:
File xmlFileName = new File(xmlDSFileName());
JRXmlDataSource xmlDS = new JRXmlDataSource(xmlFileName);
xmlDS.setDatePattern("yyyy-mm-dd HH:mm:ss.S z");
File destFile = File.createTempFile(compiledReportName, ".pdf");
String inputFileName = PathUtilities.pathToReport(compiledReportName);
JasperRunManager.runReportToPdfFile(inputFileName, destFile.getPath(), parameters, dataSource);
When you create JRXmlDataSource object, you have to add the xpath select expression defined in querystring tag. In your case, it should be:
JRXmlDataSource xmlDS = new JRXmlDataSource(xmlFileName, "/rosterArray/list/studentRoster");
Regards.