From a9ddcecdcc03158b18eb88a4e741ae12bca2985e Mon Sep 17 00:00:00 2001 From: "Andrey Cunh@" Date: Tue, 23 Jun 2026 16:33:53 -0300 Subject: [PATCH] att --- .../installments_reader.cpython-313.pyc | Bin 45749 -> 45749 bytes recebiveis_report_importer.py | 19 ++++++++++++++---- vendas_watermark.json | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/__pycache__/installments_reader.cpython-313.pyc b/__pycache__/installments_reader.cpython-313.pyc index f2dc77cc0710351d682c816e8be13cda4e0817c6..f31a7e599b954f3b3ae460be38f5cba04f726793 100644 GIT binary patch delta 22 ccmdn`lxgczChpI?yj%=Gu=|$PM($Oc0AWf9LI3~& delta 22 ccmdn`lxgczChpI?yj%=GP bool: +def _is_already_imported(cur, file_name: str, start_date: str = "", end_date: str = "") -> bool: cur.execute( "SELECT 1 FROM dbo.Grgb_vendas_import_log WHERE FileName = ?", file_name ) - return cur.fetchone() is not None + if cur.fetchone() is not None: + return True + # bloqueia se o período já está coberto por outro arquivo + if start_date and end_date: + cur.execute( + "SELECT 1 FROM dbo.Grgb_vendas_import_log " + "WHERE PeriodoInicio <= ? AND PeriodoFim >= ?", + end_date, start_date, + ) + if cur.fetchone() is not None: + return True + return False def _import_csv( @@ -402,8 +413,8 @@ def _import_csv( safe_cols = _ensure_tables(cur, csv_cols) cn.commit() - if _is_already_imported(cur, file_name): - print(f"[skip] {file_name} ja importado anteriormente") + if _is_already_imported(cur, file_name, start_date, end_date): + print(f"[skip] {file_name} periodo {start_date}..{end_date} ja importado anteriormente") cur.close(); cn.close() return 0 diff --git a/vendas_watermark.json b/vendas_watermark.json index 31ff927..78f0186 100644 --- a/vendas_watermark.json +++ b/vendas_watermark.json @@ -1 +1 @@ -{"last_end_date": "2026-05-24"} \ No newline at end of file +{"last_end_date": "2026-06-22"} \ No newline at end of file