Pārlūkot izejas kodu

(Fix Bug)當查不到統一編號對應的營業人名稱時,需填入任意的四位數字

Snoopy 3 gadi atpakaļ
vecāks
revīzija
d3a9533a5d

+ 5 - 1
TCCInvoice/InvoiceGenerator.cs

@@ -461,7 +461,7 @@ namespace TCCInvoice
                 {
                     var result = await client.GetFromJsonAsync<BusinessName>(BUSINESS_NAME_API + buyerId);
 
-                    buyerName = GenerateRandom4Digit();
+                    //buyerName = GenerateRandom4Digit();
                     if (result.data != null && result.data.財政部 != null)
                     {
                         buyerName = result.data.財政部.營業人名稱; // 1st try
@@ -474,6 +474,10 @@ namespace TCCInvoice
                             }
                         }
                     }
+                    if (string.IsNullOrEmpty(buyerName))
+                    {
+                        buyerName = GenerateRandom4Digit();
+                    }
                 }
                 catch (Exception)
                 {

+ 2 - 2
TCCInvoice/Program.cs

@@ -17,7 +17,7 @@ namespace TCCInvoice
             myInvoice.InvoiceCompleted += MyInvoice_InvoiceCompleted;
             
             // 填具待開立發票的相關資料(Preinvoice)
-            myInvoice.DataNumber = "202202201145";
+            myInvoice.DataNumber = "202203111145";
             myInvoice.DataDate = DateTime.Today;
             myInvoice.BuyerId = null; // 一般消費者
             myInvoice.TotalAmount = 524;
@@ -29,7 +29,7 @@ namespace TCCInvoice
             myInvoice.AddInvoiceItem(0, "充電服務費", 41.5793, "度", 12, 499, "充電服務費每度12元");
             myInvoice.AddInvoiceItem(1, "占用費", 30, "分鐘", 50, 25, "占用費每小時50元");
             // 開立發票
-            myInvoice.GetInvoiceResponse();
+            //myInvoice.GetInvoiceResponse();
 
 
             Console.WriteLine("Press enter to exit");

+ 4 - 0
TCCInvoice/TCCInvoice.csproj

@@ -93,4 +93,8 @@
     </PropertyGroup>
     <Error Condition="!Exists('..\packages\System.Text.Json.6.0.2-mauipre.1.22054.8\build\System.Text.Json.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Text.Json.6.0.2-mauipre.1.22054.8\build\System.Text.Json.targets'))" />
   </Target>
+  <PropertyGroup>
+    <PreBuildEvent>
+    </PreBuildEvent>
+  </PropertyGroup>
 </Project>