diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4704398 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet-test-explorer.testProjectPath": "UblTr.Tests/" +} \ No newline at end of file diff --git a/Ubl-Tr/Common/UnqualifiedDataTypes/TimeType.cs b/Ubl-Tr/Common/UnqualifiedDataTypes/TimeType.cs index 87e885e..b501239 100644 --- a/Ubl-Tr/Common/UnqualifiedDataTypes/TimeType.cs +++ b/Ubl-Tr/Common/UnqualifiedDataTypes/TimeType.cs @@ -41,15 +41,6 @@ namespace UblTr.Common [System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2")] public partial class TimeType { - - private List applicableTimeFormats = new List { - "HH:mm:ss", - "HH:mm", - "HH:mm:ss.fffff", - "HH:mm:ss.fffffff", - "HH:mm:ss.fffffffzzz" - }; - private System.DateTime valueField; /// @@ -75,13 +66,11 @@ public String TimeString bool parsed = false; DateTime parsedValue; - foreach (var format in applicableTimeFormats) + + if(DateTime.TryParse(value,CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedValue)) { - if(DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedValue)) - { - this.valueField = parsedValue; - parsed = true; - } + this.valueField = parsedValue; + parsed = true; } if(!parsed) diff --git a/Ubl-Tr/UblTr.csproj b/Ubl-Tr/UblTr.csproj index fa25cd0..d407354 100644 --- a/Ubl-Tr/UblTr.csproj +++ b/Ubl-Tr/UblTr.csproj @@ -9,10 +9,10 @@ Github ubltr ubl-tr e-invoice ubl ubl-tr-1.2.1 e-fatura fatura efatura e-despatch eirsaliye irsaliye applicationresponse uygulamayaniti creditnote receiptadvice MIT - 1.3.0 + 1.3.1 icon.png - 1.3.0.0 - 1.3.0.0 + 1.3.1.0 + 1.3.1.0 diff --git a/UblTr.Tests/InvoiceTypeTest.cs b/UblTr.Tests/InvoiceTypeTest.cs index dd5e87d..548e21c 100644 --- a/UblTr.Tests/InvoiceTypeTest.cs +++ b/UblTr.Tests/InvoiceTypeTest.cs @@ -43,6 +43,20 @@ public void InvoiceType_BasicInvoice_Deserialize() } [TestMethod] + public void InvoiceType_BasicInvoiceLongTimeWithZone3f_Deserialize() + { + var invoice = DeserializeInvoiceXml( $"{_testFilesPath}/BasicInvoiceLongTimeWithZone3f.xml"); + Assert.AreEqual("23:30:41", TimeZoneInfo.ConvertTimeToUtc(invoice.IssueTime.Value).ToString("HH:mm:ss")); + } + + [TestMethod] + public void InvoiceType_BasicInvoiceLongTime7f_Deserialize() + { + var invoice = DeserializeInvoiceXml( $"{_testFilesPath}/BasicInvoiceLongTime7f.xml"); + Assert.AreEqual("15:21:06", TimeZoneInfo.ConvertTimeToUtc(invoice.IssueTime.Value).ToString("HH:mm:ss")); + } + + [TestMethod] public void InvoiceType_BasicInvoiceLongTime_Deserialize() { var invoice = DeserializeInvoiceXml( $"{_testFilesPath}/BasicInvoiceLongTime.xml"); diff --git a/UblTr.Tests/TestFiles/InvoiceType/BasicInvoiceLongTime7f.xml b/UblTr.Tests/TestFiles/InvoiceType/BasicInvoiceLongTime7f.xml new file mode 100644 index 0000000..a289ec2 --- /dev/null +++ b/UblTr.Tests/TestFiles/InvoiceType/BasicInvoiceLongTime7f.xml @@ -0,0 +1,167 @@ + + + + + + + + + + + 2.1 + TR1.2 + TEMELFATURA + GIB20090000000001 + false + F47AC10B-58CC-4372-A567-0E02B2C3D479 + 2009-01-05 + 15:21:06.0000000Z + SATIS + TRY + 1 + + 2008-12-05 + 2009-01-05 + + + 1288331521 + + + 1288331521 + + + Papatya Caddesi Yasemin Sokak + 21 + Beşiktaş + İstanbul + 34100 + + Türkiye + + + + + + #Signature + + + + + + http://www.aaa.com.tr/ + + 1288331521 + + + AAA Anonim Şirketi + + + 1234567890 + Papatya Caddesi Yasemin Sokak + 21 + Beşiktaş + İstanbul + 34100 + + Türkiye + + + + + Büyük Mükellefler + + + + (212) 925 51515 + (212) 925505015 + aa@aaa.com.tr + + + + + + + + 1234567890 + + + 1234567 + + + 12345678 + + + ATATÜRK MAH. + 1 + 6. Sokak + 1 + Beşiktaş + İstanbul + 34100 + + Türkiye + + + + 1234567890@mydn.com.tr + + + Ali + YILMAZ + + + + + BBB Bank Otomatik Ödeme + 2009-01-20 + + + 2.73 + + 15.15 + 2.73 + + + 0015 + + + + + + 15.15 + 15.15 + 17.88 + 17.88 + + + 1 + 101 + 15.15 + + false + 0.0 + 0 + 15.15 + + + 2.73 + + 15.15 + 2.73 + 18.0 + + + KDV + 0015 + + + + + + Elektrik Tüketim Bedeli + + + 0.15 + + + \ No newline at end of file diff --git a/UblTr.Tests/TestFiles/InvoiceType/BasicInvoiceLongTimeWithZone3f.xml b/UblTr.Tests/TestFiles/InvoiceType/BasicInvoiceLongTimeWithZone3f.xml new file mode 100644 index 0000000..25d5131 --- /dev/null +++ b/UblTr.Tests/TestFiles/InvoiceType/BasicInvoiceLongTimeWithZone3f.xml @@ -0,0 +1,167 @@ + + + + + + + + + + + 2.1 + TR1.2 + TEMELFATURA + GIB20090000000001 + false + F47AC10B-58CC-4372-A567-0E02B2C3D479 + 2009-01-05 + 02:30:41.492+03:00 + SATIS + TRY + 1 + + 2008-12-05 + 2009-01-05 + + + 1288331521 + + + 1288331521 + + + Papatya Caddesi Yasemin Sokak + 21 + Beşiktaş + İstanbul + 34100 + + Türkiye + + + + + + #Signature + + + + + + http://www.aaa.com.tr/ + + 1288331521 + + + AAA Anonim Şirketi + + + 1234567890 + Papatya Caddesi Yasemin Sokak + 21 + Beşiktaş + İstanbul + 34100 + + Türkiye + + + + + Büyük Mükellefler + + + + (212) 925 51515 + (212) 925505015 + aa@aaa.com.tr + + + + + + + + 1234567890 + + + 1234567 + + + 12345678 + + + ATATÜRK MAH. + 1 + 6. Sokak + 1 + Beşiktaş + İstanbul + 34100 + + Türkiye + + + + 1234567890@mydn.com.tr + + + Ali + YILMAZ + + + + + BBB Bank Otomatik Ödeme + 2009-01-20 + + + 2.73 + + 15.15 + 2.73 + + + 0015 + + + + + + 15.15 + 15.15 + 17.88 + 17.88 + + + 1 + 101 + 15.15 + + false + 0.0 + 0 + 15.15 + + + 2.73 + + 15.15 + 2.73 + 18.0 + + + KDV + 0015 + + + + + + Elektrik Tüketim Bedeli + + + 0.15 + + + \ No newline at end of file diff --git a/UblTr.Tests/UblTr.Tests.csproj b/UblTr.Tests/UblTr.Tests.csproj index 3f267b1..f08ba82 100644 --- a/UblTr.Tests/UblTr.Tests.csproj +++ b/UblTr.Tests/UblTr.Tests.csproj @@ -47,6 +47,12 @@ Always + + Always + + + Always +