|
@@ -45,8 +45,7 @@ namespace TCCInvoice
|
|
|
|
|
|
#region Constants
|
|
|
private const string SELLER_ID = "83196607";
|
|
|
- private const string UNKNOWN_BUYER_NAME = " "; // 未查詢到的營業人名稱
|
|
|
- private const string DEFAULT_BUYER_NAME = "xxxx"; // 一般消費者
|
|
|
+ private const string UNKNOWN_BUYER_NAME = "----"; // 未查詢到營業人名稱或一般消費者
|
|
|
private const string DEFAULT_BUYER_ID = "0000000000";
|
|
|
private const int FREE_ZERO_TAX_SALES_AMOUNT = 0;
|
|
|
private const string INVOICE_TYPE = "07";
|
|
@@ -99,7 +98,7 @@ namespace TCCInvoice
|
|
|
|
|
|
if (buyerId.Equals(DEFAULT_BUYER_ID)) // 一般消費者
|
|
|
{
|
|
|
- buyerName = DEFAULT_BUYER_NAME;
|
|
|
+ buyerName = UNKNOWN_BUYER_NAME;
|
|
|
}
|
|
|
else // 有統編
|
|
|
{
|
|
@@ -203,31 +202,34 @@ namespace TCCInvoice
|
|
|
string invoiceDate, string invoiceTime, string carrierNumber);
|
|
|
public event InvoiceGenerateEventHandler InvoiceGenerated;
|
|
|
|
|
|
+ public delegate void InvoiceFailEventHandler(string dataNumber, string description);
|
|
|
+ public event InvoiceFailEventHandler InvoiceGenerationFailed;
|
|
|
+
|
|
|
private void InvoiceXmlCreated(object sender, FileSystemEventArgs e)
|
|
|
{
|
|
|
- string datanumber = null;
|
|
|
- string invoicenumber = null;
|
|
|
- string invoicedate = null;
|
|
|
- string invoicetime = null;
|
|
|
- string carriernumber = null;
|
|
|
-
|
|
|
XDocument xDoc = XDocument.Load(e.FullPath);
|
|
|
|
|
|
string status = xDoc.Descendants("Status").ElementAt(0).Value;
|
|
|
if (status == "1")
|
|
|
{
|
|
|
- invoicenumber = xDoc.Descendants("InvoiceNumber").ElementAt(0).Value;
|
|
|
- datanumber = xDoc.Descendants("DataNumber").ElementAt(0).Value;
|
|
|
- invoicedate = xDoc.Descendants("InvoiceDate").ElementAt(0).Value;
|
|
|
- invoicetime = xDoc.Descendants("InvoiceTime").ElementAt(0).Value;
|
|
|
- // carriernumber = xDoc.Descendants("CarrierId1").ElementAt(0).Value;
|
|
|
+ string invoicenumber = xDoc.Descendants("InvoiceNumber").ElementAt(0).Value;
|
|
|
+ string datanumber = xDoc.Descendants("DataNumber").ElementAt(0).Value;
|
|
|
+ string invoicedate = xDoc.Descendants("InvoiceDate").ElementAt(0).Value;
|
|
|
+ string invoicetime = xDoc.Descendants("InvoiceTime").ElementAt(0).Value;
|
|
|
+ string carriernumber = null;
|
|
|
+ // string carriernumber = xDoc.Descendants("CarrierId1").ElementAt(0).Value;
|
|
|
+
|
|
|
+ InvoiceGenerated?.Invoke(datanumber, invoicenumber, invoicedate, invoicetime, carriernumber);
|
|
|
}
|
|
|
- else
|
|
|
+ else // Failure
|
|
|
{
|
|
|
- // Failure
|
|
|
+ string description = xDoc.Descendants("Description").ElementAt(0).Value;
|
|
|
+ string datanumber = xDoc.Descendants("DataNumber").ElementAt(0).Value;
|
|
|
+
|
|
|
+ InvoiceGenerationFailed?.Invoke(datanumber, description);
|
|
|
}
|
|
|
|
|
|
- InvoiceGenerated?.Invoke(datanumber, invoicenumber, invoicedate, invoicetime, carriernumber);
|
|
|
+
|
|
|
}
|
|
|
#endregion
|
|
|
|