Skip to content

Commit ec0eebf

Browse files
committed
Fix: update tin validation
1 parent 03d3fa0 commit ec0eebf

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

DebitExpress.VatRelief/Utils/Extensions.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ public static bool IsTrue(this string? str)
9393
return upper is "YES" or "Y" or "TRUE" or "T" or "1";
9494
}
9595

96-
public static bool IsValidTin(this string? str)
97-
{
98-
if (string.IsNullOrEmpty(str)) return false;
99-
100-
return new Regex("^[0-9]\\d{2}-[0-9]\\d{2}-[0-9]\\d{2}-[0-9]\\d{2,4}$").IsMatch(str);
101-
}
102-
10396
public static string QuarterRangeString(int startingMonth, int year)
10497
{
10598
var startingDate = GetEndOfMonth(year, startingMonth);

DebitExpress.VatRelief/Utils/VatTemplateReader.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private Result<ExcelData> ReadInternal(string path)
4141
var workbook = new XLWorkbook(path);
4242
var info = GetInfo(workbook);
4343
var sales = GetSalesData(workbook);
44-
var purchases = GetPurchaseData(workbook);
44+
var purchases = GetPurchaseData(workbook, info);
4545

4646
return new Result<ExcelData>(new ExcelData(info, sales, purchases));
4747
}
@@ -168,7 +168,7 @@ private static Sales ParseSalesLineItem(IXLRow row, int i)
168168
};
169169
}
170170

171-
private static List<Purchases> GetPurchaseData(IXLWorkbook workbook)
171+
private static List<Purchases> GetPurchaseData(IXLWorkbook workbook, Info info)
172172
{
173173
var purchaseSheet = workbook.Worksheet("PURCHASES");
174174
if (purchaseSheet == null) throw new ArgumentException("PURCHASES sheet not found");
@@ -178,7 +178,12 @@ private static List<Purchases> GetPurchaseData(IXLWorkbook workbook)
178178
for (var i = 2; i <= rowCount; i++)
179179
{
180180
var row = purchaseSheet.Row(i);
181-
purchases.Add(ParsePurchasesLineItem(row, i));
181+
var purchase = ParsePurchasesLineItem(row, i);
182+
183+
if (purchase.Tin.Strip() == info.Tin)
184+
throw new ArgumentException($"TIN in PURCHASES sheet cell B{i} cannot be the same as the TIN of the taxpayer");
185+
186+
purchases.Add(purchase);
182187
}
183188

184189
return purchases;

0 commit comments

Comments
 (0)