diff --git a/dev-resources/test-cintas/Test.txt b/dev-resources/test-cintas/Test.txt
new file mode 100644
index 00000000..751c15ea
--- /dev/null
+++ b/dev-resources/test-cintas/Test.txt
@@ -0,0 +1,4 @@
+Test
+This is a test file to test the sftp
+Thanks
+OPentext
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/Test.txt b/dev-resources/test-cintas/archive/Test.txt
new file mode 100644
index 00000000..751c15ea
--- /dev/null
+++ b/dev-resources/test-cintas/archive/Test.txt
@@ -0,0 +1,4 @@
+Test
+This is a test file to test the sftp
+Thanks
+OPentext
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230310093903 b/dev-resources/test-cintas/archive/o.zcic.230310093903
new file mode 100644
index 00000000..41fa5b13
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230310093903
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+ 056481716-T
+
+
+
+
+ NTGCORP-T
+
+
+
+
+ 056481716-T
+ NtG$c7S
+
+ Cintas
+
+
+
+
+
+
+
+
+
+
+
+ PO BOX 29059
+ Phoenix
+ AZ
+ 850389059
+ United States
+
+
+
+
+
+ NICK THE GREEK
+
+ 2034 BROADWAY ST
+ REDWOOD CITY
+ CA
+ 940631802
+ United States
+
+
+
+
+
+
+
+
+
+
+
+
+
+ X106
+
+ SERVICE CHARGE
+
+
+ Product Category
+
+
+
+
+ 2.56
+
+ EA
+
+ 2.56
+
+
+
+
+
+ X1919
+
+ 2X3 WELLNESS AF MAT ONYX
+
+
+ Product Category
+
+
+
+
+ 7.168
+
+ EA
+
+ 1.792
+
+
+
+
+
+ X2700
+
+ TERRY TOWEL - WHITE
+
+
+ Product Category
+
+
+
+
+ 10.2
+
+ EA
+
+ 0.102
+
+
+
+
+
+ X2861
+
+ BIB APRON-RED
+
+
+ Product Category
+
+
+
+
+ 19.95
+
+ EA
+
+ 0.266
+
+
+
+
+
+ 39.88
+
+
+ 0.00
+ 0.00
+
+
+ 0.00
+
+ TAX ON ITEMS
+
+
+
+ 39.88
+
+
+ 39.88
+
+
+ 39.88
+
+
+
+
+
diff --git a/dev-resources/test-cintas/archive/o.zcic.230310093903aa b/dev-resources/test-cintas/archive/o.zcic.230310093903aa
new file mode 100644
index 00000000..fb406ff5
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230310093903aa
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK125 BERNAL RDSAN JOSECA951191397United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X18103X5 DURALITE MATProduct Category5.12EA2.56X2278SIGNET SK1 DETERGENTProduct Category2.304EA0.768X2700TERRY TOWEL - WHITEProduct Category15.3EA0.102X2861BIB APRON-REDProduct Category26.6EA0.26651.880.460.460.46TAX ON ITEMS51.8852.3452.34
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230310093903ab b/dev-resources/test-cintas/archive/o.zcic.230310093903ab
new file mode 100644
index 00000000..56cf2e98
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230310093903ab
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+ 056481716-T
+
+
+
+
+ NTGCORP-T
+
+
+
+
+ 056481716-T
+ NtG$c7S
+
+ Cintas
+
+
+
+
+
+
+
+
+
+
+
+ PO BOX 29059
+ Phoenix
+ AZ
+ 850389059
+ United States
+
+
+
+
+
+ NICK THE GREEK
+
+ 125 BERNAL RD
+ SAN JOSE
+ CA
+ 951191397
+ United States
+
+
+
+
+
+
+
+
+
+
+
+
+
+ X106
+
+ SERVICE CHARGE
+
+
+ Product Category
+
+
+
+
+ 2.56
+
+ EA
+
+ 2.56
+
+
+
+
+
+ X1132
+
+ MINIMUM CHARGE
+
+
+ Product Category
+
+
+
+
+ 0.63
+
+ EA
+
+ 0.63
+
+
+
+
+
+ X1919
+
+ 2X3 WELLNESS AF MAT ONYX
+
+
+ Product Category
+
+
+
+
+ 10.752
+
+ EA
+
+ 1.792
+
+
+
+
+
+ X2700
+
+ TERRY TOWEL
+
+
+ Product Category
+
+
+
+
+ 5.1
+
+ EA
+
+ 0.102
+
+
+
+
+
+ X2861
+
+ BIB APRON-RED
+
+
+ Product Category
+
+
+
+
+ 15.96
+
+ EA
+
+ 0.266
+
+
+
+
+
+ 35.00
+
+
+ 0.00
+ 0.00
+
+
+ 0.00
+
+ TAX ON ITEMS
+
+
+
+ 35.00
+
+
+ 35.00
+
+
+ 35.00
+
+
+
+
+
diff --git a/dev-resources/test-cintas/archive/o.zcic.230315102406 b/dev-resources/test-cintas/archive/o.zcic.230315102406
new file mode 100644
index 00000000..805b03b9
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230315102406
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK2034 BROADWAY STREDWOOD CITYCA940631802United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X19192X3 WELLNESS AF MAT ONYXProduct Category7.168EA1.792X2700TERRY TOWEL - WHITEProduct Category10.2EA0.102X2861BIB APRON-REDProduct Category19.95EA0.266-39.880.000.000.00TAX ON ITEMS-39.88-39.88-39.88
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230315102406aa b/dev-resources/test-cintas/archive/o.zcic.230315102406aa
new file mode 100644
index 00000000..c824189e
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230315102406aa
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK125 BERNAL RDSAN JOSECA951191397United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X1132MINIMUM CHARGEProduct Category0.63EA0.63X19192X3 WELLNESS AF MAT ONYXProduct Category10.752EA1.792X2700TERRY TOWELProduct Category5.1EA0.102X2861BIB APRON-REDProduct Category15.96EA0.266-35.000.000.000.00TAX ON ITEMS-35.00-35.00-35.00
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230315102406ab b/dev-resources/test-cintas/archive/o.zcic.230315102406ab
new file mode 100644
index 00000000..69766169
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230315102406ab
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK125 BERNAL RDSAN JOSECA951191397United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X18103X5 DURALITE MATProduct Category5.12EA2.56X2278SIGNET SK1 DETERGENTProduct Category2.304EA0.768X2700TERRY TOWEL - WHITEProduct Category15.3EA0.102X2861BIB APRON-REDProduct Category26.6EA0.266-51.88-0.460.46-0.46TAX ON ITEMS-51.88-52.34-52.34
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230315102406ac b/dev-resources/test-cintas/archive/o.zcic.230315102406ac
new file mode 100644
index 00000000..cb8d7b89
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230315102406ac
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK125 BERNAL RDSAN JOSECA951191397United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X19192X3 WELLNESS AF MAT ONYXProduct Category10.752EA1.792X2861BIB APRON-REDProduct Category15.96EA0.266X102233X5 XTRAC MAT INGOProduct Category16.896EA5.63246.170.000.000.00TAX ON ITEMS46.1746.1746.17
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230327132403 b/dev-resources/test-cintas/archive/o.zcic.230327132403
new file mode 100644
index 00000000..a1a69f21
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230327132403
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK206 E STDAVISCA956164522United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X101974X6 TRAFFIC MATProduct Category15.36EA5.12X2700TERRY TOWEL - WHITEProduct Category10.2EA0.102X2873BIB APRON-BLACKProduct Category10.25EA0.20538.370.000.000.00TAX ON ITEMS38.3738.3738.37
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230327132403aa b/dev-resources/test-cintas/archive/o.zcic.230327132403aa
new file mode 100644
index 00000000..370e8826
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230327132403aa
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK732 LAUREL STSAN CARLOSCA940703114United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X101974X6 TRAFFIC MATProduct Category15.36EA5.12X2700TERRY TOWELProduct Category7.65EA0.102X2873BIB APRON-BLACKProduct Category10.25EA0.205X65175STOCK STOCK-CHEF COAT/PLSTCBTN/WHITE/CW/LSProduct Category4.296EA0.35840.120.000.000.00TAX ON ITEMS40.1240.1240.12
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230403203949 b/dev-resources/test-cintas/archive/o.zcic.230403203949
new file mode 100644
index 00000000..847fbc46
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230403203949
@@ -0,0 +1 @@
+056481716NTGCORP056481716NtG$c7SCintasPO BOX 630921CincinnatiOH452630921United StatesNICK THE GREEK3141 MOWRY AVEFREMONTCA945381505United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X20009SIG AUTOPAPR BLU ALUProduct Category1.024EA0.256X2700TERRY TOWEL - WHITEProduct Category25.75EA0.103X2700TERRY TOWEL - WHITEProduct Category9.74EA0.974X27045SIG AUTOSOAP DSP ALUProduct Category2.304EA0.256X27069SIG SOAP SVCProduct Category10.252EA2.563X2873BIB APRON-BLACKProduct Category10.25EA0.205X8072SIG SANT SVCProduct Category7.689EA2.563X840353X10 BLACK MATProduct Category4.61EA4.61X844354X6 BLACK MATProduct Category7.176EA3.588X9207SANIS BOWL CLIP SVCProduct Category2.05EA1.025X9559SIG HND SANTZR STANDProduct Category4.612EA2.30688.013.123.123.12TAX ON ITEMS88.0191.1391.13
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230403222257 b/dev-resources/test-cintas/archive/o.zcic.230403222257
new file mode 100644
index 00000000..8b4501b0
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230403222257
@@ -0,0 +1 @@
+056481716NTGCORP056481716NtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK101 OYSTER POINT BLVDSOUTH SAN FRANCISCOCA940802034United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X20023SIG HRDWND WHT LRGProduct Category16.4EA8.2X2271FC1 HD FLR CLNR/DGSRProduct Category1.03EA1.03X2275Product Category1.54EA1.54X2276RR1 DISNFCT/ RR CLNRProduct Category1.54EA1.54X2278SIGNET SK1 DETERGENTProduct Category12.304EA0.769X2279SK2 SINK SANITIZERProduct Category0.77EA0.77X2280Z1 HARD SURF SANITZRProduct Category2.05EA2.05X2700TERRY TOWEL - WHITEProduct Category14.61EA0.974X2700TERRY TOWEL - WHITEProduct Category20.6EA0.103X2700TERRY TOWEL - WHITEProduct Category7.792EA0.974X27045SIG AUTOSOAP DSP ALUProduct Category0.768EA0.256X27051SIG AUTOSOAP CVR BLUProduct Category0EA0X27069SIG SOAP SVCProduct Category2.56EA2.56X2873BIB APRON-BLACKProduct Category18.04EA4.51X2873BIB APRON-BLACKProduct Category8.2EA0.205X3030LINEN BAG RACKProduct Category0EA0X3032LINEN BAGProduct Category0EA0X8072SIG SANT SVCProduct Category2.56EA2.56X840353X10 BLACK MATProduct Category9.226EA4.613X843353X5 BLACK MATProduct Category2.56EA2.56X844354X6 BLACK MATProduct Category3.59EA3.59X9559SIG HND SANTZR STANDProduct Category2.31EA2.31131.014.584.584.58TAX ON ITEMS131.01135.59135.59
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230403222257ak b/dev-resources/test-cintas/archive/o.zcic.230403222257ak
new file mode 100644
index 00000000..299799d4
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230403222257ak
@@ -0,0 +1 @@
+056481716NTGCORP056481716NtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK2855 STEVENS CREEK BLVD STE 24SAN JOSECA95128United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X20009SIG AUTOPAPR BLU ALUProduct Category0.768EA0.256X20023SIG HRDWND WHT LRGProduct Category0EA8.2X2271FC1 HD FLR CLNR/DGSRProduct Category16.4EA1.025X2278SIGNET SK1 DETERGENTProduct Category24.608EA0.769X2279SK2 SINK SANITIZERProduct Category10.766EA0.769X2280Z1 HARD SURF SANITZRProduct Category2.05EA2.05X2281DG1 HD FOAM DEGRSRProduct Category1.03EA1.03X2650WET MOP LARGEProduct Category2.562EA1.281X2700TERRY TOWEL - WHITEProduct Category20.6EA0.103X2700TERRY TOWEL - WHITEProduct Category7.792EA0.974X27045SIG AUTOSOAP DSP ALUProduct Category0.768EA0.256X27051SIG AUTOSOAP CVR BLUProduct Category0EA0X27069SIG SOAP SVCProduct Category6.15EA2.05X27070SIG SOAP RFL FOAMProduct Category0EA0X2873BIB APRON-BLACKProduct Category6.15EA0.205X2873BIB APRON-BLACKProduct Category0EA4.51X6922WOOD WET MOP HANDLEProduct Category0EA0X7500CLEANING CHEM DISPProduct Category2.05EA1.025X7550CLEAN CHEM SINK DISPProduct Category1.03EA1.03X8004LAUNDRY LOCK UPProduct Category1.03EA1.03106.326.396.396.39TAX ON ITEMS106.32112.71112.71
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230403222257at b/dev-resources/test-cintas/archive/o.zcic.230403222257at
new file mode 100644
index 00000000..687ab818
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230403222257at
@@ -0,0 +1 @@
+056481716NTGCORP056481716NtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK128 VINTAGE WAY # W-1NOVATOCA949455003United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X101963X5 TRAFFIC MATProduct Category8.2EA4.1X101974X6 TRAFFIC MATProduct Category5.13EA5.13X101983X10 TRAFFIC MATProduct Category13.326EA6.663X19173X5 WELLNESS AF ONYXProduct Category5.126EA2.563X20002SIG DUALTP RFL PREMProduct Category25EA25X20009SIG AUTOPAPR BLU ALUProduct Category1.024EA0.256X20023SIG HRDWND WHT LRGProduct Category24.6EA8.2X2271FC1 HD FLR CLNR/DGSRProduct Category7.175EA1.025X2278SIGNET SK1 DETERGENTProduct Category15.38EA0.769X2279SK2 SINK SANITIZERProduct Category15.38EA0.769X2650WET MOP LARGEProduct Category2.562EA1.281X2700TERRY TOWEL - WHITEProduct Category51.5EA0.103X2700TERRY TOWEL - WHITEProduct Category19.48EA0.974X27013SIG AIR DSP ALUProduct Category0EA0X27019SIG AIR CVR BLUEProduct Category0EA0X27026SIG AIR SVCProduct Category2.05EA2.05X27028SIG AIR RFL MANGOProduct Category0EA0X27045SIG AUTOSOAP DSP ALUProduct Category1.024EA0.256X27051SIG AUTOSOAP CVR BLUProduct Category0EA0X27069SIG SOAP SVCProduct Category5.126EA2.563X27070SIG SOAP RFL FOAMProduct Category0EA0X27071SIG DUALTP DSP ALUProduct Category0EA0X27077SIG DUALTP CVR BLUEProduct Category0EA0X2873BIB APRON-BLACKProduct Category14.35EA0.205X7500CLEANING CHEM DISPProduct Category2.05EA1.025221.058.628.628.62TAX ON ITEMS221.05229.67229.67
\ No newline at end of file
diff --git a/dev-resources/test-cintas/archive/o.zcic.230403225219ao b/dev-resources/test-cintas/archive/o.zcic.230403225219ao
new file mode 100644
index 00000000..df2fac90
--- /dev/null
+++ b/dev-resources/test-cintas/archive/o.zcic.230403225219ao
@@ -0,0 +1 @@
+056481716NTGCORP056481716NtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK1133 PACIFIC AVESANTA CRUZCA950604431United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X20009SIG AUTOPAPR BLU ALUProduct Category0EA0X2271FC1 HD FLR CLNR/DGSRProduct Category15.375EA1.025X2278SIGNET SK1 DETERGENTProduct Category24.608EA0.769X2279SK2 SINK SANITIZERProduct Category15.38EA0.769X2700TERRY TOWEL - WHITEProduct Category30.9EA0.103X2700TERRY TOWEL - WHITEProduct Category23.376EA0.974X27132SIG JMBO TIS DISP LT ALUMProduct Category0EA0X27138SIG JMBO TIS DISP CVR INDProduct Category0EA0X27180DESKTOP HAND SANITIZER STANDProduct Category1.03EA1.03X2873BIB APRON-BLACKProduct Category0EA4.51X2873BIB APRON-BLACKProduct Category8.2EA0.205X7500CLEANING CHEM DISPProduct Category1.03EA1.03X7550CLEAN CHEM SINK DISPProduct Category1.03EA1.03X8072SIG SANT SVCProduct Category5.126EA2.563X840353X10 BLACK MATProduct Category9.226EA4.613X844354X6 BLACK MATProduct Category7.176EA3.588X9148TOILET SEAT COVR RFLProduct Category2.31EA2.31X9559SIG HND SANTZR STANDProduct Category2.31EA2.31149.666.556.556.55TAX ON ITEMS149.66156.21156.21
\ No newline at end of file
diff --git a/dev-resources/test-cintas/o.zcic.230310093903 b/dev-resources/test-cintas/o.zcic.230310093903
new file mode 100644
index 00000000..e5f334ad
--- /dev/null
+++ b/dev-resources/test-cintas/o.zcic.230310093903
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK2034 BROADWAY STREDWOOD CITYCA940631802United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X19192X3 WELLNESS AF MAT ONYXProduct Category7.168EA1.792X2700TERRY TOWEL - WHITEProduct Category10.2EA0.102X2861BIB APRON-REDProduct Category19.95EA0.26639.880.000.000.00TAX ON ITEMS39.8839.8839.88
\ No newline at end of file
diff --git a/dev-resources/test-cintas/o.zcic.230310093903aa b/dev-resources/test-cintas/o.zcic.230310093903aa
new file mode 100644
index 00000000..fb406ff5
--- /dev/null
+++ b/dev-resources/test-cintas/o.zcic.230310093903aa
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK125 BERNAL RDSAN JOSECA951191397United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X18103X5 DURALITE MATProduct Category5.12EA2.56X2278SIGNET SK1 DETERGENTProduct Category2.304EA0.768X2700TERRY TOWEL - WHITEProduct Category15.3EA0.102X2861BIB APRON-REDProduct Category26.6EA0.26651.880.460.460.46TAX ON ITEMS51.8852.3452.34
\ No newline at end of file
diff --git a/dev-resources/test-cintas/o.zcic.230310093903ab b/dev-resources/test-cintas/o.zcic.230310093903ab
new file mode 100644
index 00000000..55b1a1a9
--- /dev/null
+++ b/dev-resources/test-cintas/o.zcic.230310093903ab
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK125 BERNAL RDSAN JOSECA951191397United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X1132MINIMUM CHARGEProduct Category0.63EA0.63X19192X3 WELLNESS AF MAT ONYXProduct Category10.752EA1.792X2700TERRY TOWELProduct Category5.1EA0.102X2861BIB APRON-REDProduct Category15.96EA0.26635.000.000.000.00TAX ON ITEMS35.0035.0035.00
\ No newline at end of file
diff --git a/dev-resources/test-cintas/o.zcic.230327132403 b/dev-resources/test-cintas/o.zcic.230327132403
new file mode 100644
index 00000000..a1a69f21
--- /dev/null
+++ b/dev-resources/test-cintas/o.zcic.230327132403
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK206 E STDAVISCA956164522United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X101974X6 TRAFFIC MATProduct Category15.36EA5.12X2700TERRY TOWEL - WHITEProduct Category10.2EA0.102X2873BIB APRON-BLACKProduct Category10.25EA0.20538.370.000.000.00TAX ON ITEMS38.3738.3738.37
\ No newline at end of file
diff --git a/dev-resources/test-cintas/o.zcic.230327132403aa b/dev-resources/test-cintas/o.zcic.230327132403aa
new file mode 100644
index 00000000..370e8826
--- /dev/null
+++ b/dev-resources/test-cintas/o.zcic.230327132403aa
@@ -0,0 +1 @@
+056481716-TNTGCORP-T056481716-TNtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK732 LAUREL STSAN CARLOSCA940703114United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X101974X6 TRAFFIC MATProduct Category15.36EA5.12X2700TERRY TOWELProduct Category7.65EA0.102X2873BIB APRON-BLACKProduct Category10.25EA0.205X65175STOCK STOCK-CHEF COAT/PLSTCBTN/WHITE/CW/LSProduct Category4.296EA0.35840.120.000.000.00TAX ON ITEMS40.1240.1240.12
\ No newline at end of file
diff --git a/dev-resources/test-cintas/o.zcic.230404101217 b/dev-resources/test-cintas/o.zcic.230404101217
new file mode 100644
index 00000000..dd8c8c7e
--- /dev/null
+++ b/dev-resources/test-cintas/o.zcic.230404101217
@@ -0,0 +1 @@
+056481716NTGCORP056481716NtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK121 HARTZ AVEDANVILLECA945263325United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X2275Product Category1.54EA1.54X2276RR1 DISNFCT/ RR CLNRProduct Category1.54EA1.54X2278SIGNET SK1 DETERGENTProduct Category10.766EA0.769X2279SK2 SINK SANITIZERProduct Category10.766EA0.769X2700TERRY TOWEL - WHITEProduct Category30.9EA0.103X2700TERRY TOWEL - WHITEProduct Category11.688EA0.974X2873BIB APRON-BLACKProduct Category10.25EA0.205X7500CLEANING CHEM DISPProduct Category1.03EA1.03X840353X10 BLACK MATProduct Category4.61EA4.61X843353X5 BLACK MATProduct Category2.56EA2.56X844354X6 BLACK MATProduct Category7.176EA3.58895.402.472.472.47TAX ON ITEMS95.4097.8797.87
\ No newline at end of file
diff --git a/dev-resources/test-cintas/o.zcic.230404101217aa b/dev-resources/test-cintas/o.zcic.230404101217aa
new file mode 100644
index 00000000..55425f6f
--- /dev/null
+++ b/dev-resources/test-cintas/o.zcic.230404101217aa
@@ -0,0 +1 @@
+056481716NTGCORP056481716NtG$c7SCintasPO BOX 29059PhoenixAZ850389059United StatesNICK THE GREEK282 CODDINGTOWN CTRSANTA ROSACA954013506United StatesX106SERVICE CHARGEProduct Category2.56EA2.56X101963X5 TRAFFIC MATProduct Category8.2EA4.1X101983X10 TRAFFIC MATProduct Category13.326EA6.663X19173X5 WELLNESS AF ONYXProduct Category12.815EA2.563X2271FC1 HD FLR CLNR/DGSRProduct Category7.175EA1.025X2278SIGNET SK1 DETERGENTProduct Category3.076EA0.769X2279SK2 SINK SANITIZERProduct Category5.383EA0.769X2650WET MOP LARGEProduct Category2.562EA1.281X2700TERRY TOWEL - WHITEProduct Category30.9EA0.103X2700TERRY TOWEL - WHITEProduct Category11.688EA0.974X27000SIG ZFOLD DSP ALUProduct Category0EA0X27006SIG ZFOLD CVR BLUEProduct Category0EA0X27006SIG ZFOLD CVR BLUEProduct Category0EA0X27045SIG AUTOSOAP DSP ALUProduct Category0.768EA0.256X27048SIG AUTOSOAP CVR WHTProduct Category0EA0X27051SIG AUTOSOAP CVR BLUProduct Category0EA0X27069SIG SOAP SVCProduct Category5.126EA2.563X2873BIB APRON-BLACKProduct Category16.4EA0.205X6923FIBERGLASS WET MOP HANDLEProduct Category0EA0X7500CLEANING CHEM DISPProduct Category1.03EA1.03X8072SIG SANT SVCProduct Category2.56EA2.56X844014X6 LOGO MATProduct Category6.66EA6.66X9559SIG HND SANTZR STANDProduct Category2.31EA2.31X9581DUALCHAMBERMOPBUCKETProduct Category1.79EA1.79134.352.782.782.78TAX ON ITEMS134.35137.13137.13
\ No newline at end of file
diff --git a/project.clj b/project.clj
index 4a3c8668..6e3e932e 100644
--- a/project.clj
+++ b/project.clj
@@ -91,6 +91,7 @@
#_[org.eclipse.jetty.websocket/websocket-servlet "11.0.0"]
[org.clojure/data.json "1.0.0"]
[org.clojure/data.csv "1.0.0"]
+ [lambdaisland/edn-lines "1.0.10"]
[io.rkn/conformity "0.5.4"]
[com.brunobonacci/mulog "0.9.0"]
[com.brunobonacci/mulog-adv-console "0.9.0"]
@@ -103,7 +104,8 @@
;; needed for java 11
[javax.xml.bind/jaxb-api "2.4.0-b180830.0359"]
- [io.forward/clojure-mail "1.0.8"]]
+ [io.forward/clojure-mail "1.0.8"]
+ [lambdaisland/edn-lines "1.0.10"]]
:managed-dependencies [;; explicit dependencies to get to latest versions for above
[com.fasterxml.jackson.core/jackson-core "2.12.0"]
[com.fasterxml.jackson.core/jackson-databind "2.12.0"]
diff --git a/src/clj/auto_ap/backup.clj b/src/clj/auto_ap/backup.clj
new file mode 100644
index 00000000..731bb0fc
--- /dev/null
+++ b/src/clj/auto_ap/backup.clj
@@ -0,0 +1,528 @@
+;; This buffer is for Clojure experiments and evaluation.
+
+;; Press C-j to evaluate the last expression.
+
+;; You can also press C-u C-j to evaluate the expression and pretty-print its result.
+
+(ns auto-ap.backup
+ (:require [datomic.api :as d]
+ [manifold.deferred :as de]
+ [manifold.executor :as ex]
+ [manifold.stream :as s]
+ [manifold.time :as mt]
+ [auto-ap.jobs.core :refer [execute]]
+ [clojure.java.io :as io]
+ [amazonica.aws.s3 :as s3]
+ [config.core :refer [env]]
+ [clojure.core.async :as a]
+ [lambdaisland.edn-lines :as ednl]
+ [clojure.set :as set]
+ [com.brunobonacci.mulog :as mu]))
+
+
+
+
+(def request-pool (ex/fixed-thread-executor 30))
+
+(def buffered (ex/fixed-thread-executor 30))
+
+(defn get-schema [remote-db]
+ (let [everything (->> (d/q '[:find [(pull ?e [:db/ident
+ {:db/valueType [:db/ident]}
+ {:db/cardinality [:db/ident]}
+ :db.attr/preds
+ {:db/unique [:db/ident]}
+ :db/isComponent
+ :db/id
+ :db/noHistory
+ :db/tupleAttrs
+ :db.entity/attrs
+ :db.entity/preds
+ :db/doc]) ...]
+ :where [?e :db/ident]]
+ remote-db))
+ schema-attrs (->> everything
+ (filter :db/ident)
+ (filter (fn [{:db/keys [ident]}]
+ (if (namespace ident)
+ (re-matches #"^(?!cartographer)(?!db)(?!fressian).+" (namespace ident))
+ true
+ ))))
+ meta-schema-schema (filter #(-> % :db/ident not) everything)]
+ schema-attrs))
+
+
+(def entity->best-key
+ {"transaction-rule"
+ [:transaction-rule/description, :transaction-rule/note :transaction-rule/vendor]
+ "square-location"
+ :square-location/square-id,
+ "expected-deposit"
+ :expected-deposit/date,
+ "journal-entry-line"
+ [:journal-entry-line/account, :journal-entry-line/debit :journal-entry-line/credit]
+ "vendor"
+ [:vendor/name, :vendor/default-account, :vendor/hidden]
+ "transaction"
+ :transaction/amount,
+ "yodlee-provider-account"
+ :yodlee-provider-account/id,
+ "journal-entry"
+ :journal-entry/source,
+ "yodlee-merchant" :yodlee-merchant/yodlee-id,
+ "invoice"
+ :invoice/invoice-number,
+ "vendor-terms-override"
+ :vendor-terms-override/client,
+ "integration-status"
+ :integration-status/state,
+ "conformity" :conformity/conformed-norms-index,
+ "user"
+ :user/provider-id,
+ "sales-refund"
+ :sales-refund/total,
+ "plaid-account"
+ :plaid-account/name,
+ "charge"
+ [:charge/total, :charge/external-id]
+ "location-match" :location-match/location,
+ "vendor-schedule-payment-dom"
+ :vendor-schedule-payment-dom/dom,
+ "account-client-override"
+ :account-client-override/client,
+ "plaid-item"
+ :plaid-item/client,
+ "transaction-account"
+ :transaction-account/account,
+ "address"
+ [:address/street1, :address/city :address/state :address/zip]
+ "order-line-item"
+ :order-line-item/total,
+ "ezcater-location" [:ezcater-location/location, :ezcater-location/caterer]
+ "account"
+ [:account/numeric-code, :account/code :account/name :account/type]
+ "intuit-bank-account"
+ :intuit-bank-account/name,
+ "saved-query"
+ :saved-query/guid,
+ "ezcater-caterer"
+ :ezcater-caterer/uuid,
+ "forecasted-transaction"
+ :forecasted-transaction/day-of-month,
+ "audit" :audit/user,
+ "yodlee-account"
+ :yodlee-account/id,
+ "transaction-rule-account"
+ [:transaction-rule-account/account, :transaction-rule-account/location]
+ "ezcater-integration"
+ :ezcater-integration/subscriber-uuid,
+ "report"
+ :report/created,
+ "bank-account"
+ :bank-account/code,
+ "vendor-usage"
+ :vendor-usage/key,
+ "invoice-expense-account"
+ [:invoice-expense-account/expense-account-id, :invoice-expense-account/account :invoice-expense-account/location :invoice-expense-account/amount]
+ "sales-order"
+ :sales-order/date,
+ "client"
+ :client/code,
+ "email-contact" :email-contact/email,
+ "invoice-payment"
+ :invoice-payment/amount,
+ "contact"
+ [:contact/name, :contact/phone :contact/email]
+ "import-batch"
+ :import-batch/date,
+ "payment"
+ [:payment/date, :payment/bank-account]
+ "vendor-account-override"
+ :vendor-account-override/client})
+
+#_(defn references [schema]
+ (filter (comp #{:db.type/ref} :db/ident :db/valueType) schema ))
+
+
+
+
+
+#_(defn reference->entity [remote-db]
+ (->> (d/q '[:find ?a ?v3
+ :in $ $$ [?a ...]
+ :where [$$ _ ?a ?e]
+ [$ ?e ?v _ _]
+ [$ ?v :db/ident ?v2 _ _]
+ [(namespace ?v2) ?v3]
+ [(namespace ?v2) ?v3]]
+ remote-db
+ (d/since remote-db #inst "2022-06-01")
+ (map :db/ident references)
+ )
+ (group-by first)
+ (map (fn [[k v]]
+ [k (disj (set (map second v)) "db")]))
+ (into {})))
+
+#_(def manual-dependencies
+ {:client/location-matches #{"location-match"}
+ :transaction/yodlee-merchant #{"yodlee-merchant"}
+ :vendor-account-override/account #{"account"}
+ :vendor-account-override/client #{"client"}
+ :vendor/secondary-contact #{"contact"}
+ :vendor/account-overrides #{"vendor-account-override"}
+ :client/bank-accounts #{"bank-account"}
+ :transaction-rule/yodlee-merchant #{"yodlee-merchant"}
+ :client/forecasted-transactions #{"forecasted-transaction"}
+ :transaction/forecast-match #{"forecasted-transaction"}
+ :vendor/automatically-paid-when-due #{"client"}
+ :vendor/schedule-payment-dom #{"vendor-schedule-payment-dom"}
+ :vendor/terms-overrides #{"vendor-terms-override"}
+ :vendor-schedule-payment-dom/client #{"client"}})
+
+#_(defn full-dependencies [remote-db]
+ (update (merge-with into (reference->entity remote-db) manual-dependencies)
+ :journal-entry/original-entity
+ #(disj % "journal-entry")))
+
+#_(defn entity-dependencies [schema]
+ (let [base-dependencies
+ (into
+ {}
+ (map (fn [i]
+ [i #{}])
+ (set (map (comp namespace :db/ident)
+ (filter :db/valueType
+ schema))))
+ )
+ ]
+ (into base-dependencies (reduce
+ (fn [acc [ref deps]]
+ (update acc (namespace ref) (fnil #(into % deps) #{})))
+ {}
+ (full-dependencies remote-db)))))
+
+(def full-dependencies
+ {:invoice/client #{"client"},
+ :sales-order/client #{"client"},
+ :transaction-rule/transaction-approval-status #{},
+ :transaction/forecast-match #{"forecasted-transaction"},
+ :user/role #{},
+ :vendor-schedule-payment-dom/client #{"client"},
+ :invoice-payment/payment #{"payment"},
+ :transaction-rule/client #{"client"},
+ :invoice/status #{},
+ :payment/type #{},
+ :expected-deposit/client #{"client"},
+ :transaction/bank-account #{"bank-account"},
+ :transaction-rule-account/account #{"account"},
+ :import-batch/status #{},
+ :user/clients #{"client"},
+ :payment/client #{"client"},
+ :expected-deposit/charges #{"charge"},
+ :vendor/automatically-paid-when-due #{"client"},
+ :payment/invoices #{"invoice"},
+ :client/forecasted-transactions #{"forecasted-transaction"},
+ :transaction/matched-rule #{"transaction-rule"},
+ :invoice/import-status #{},
+ :charge/processor #{},
+ :expected-deposit/vendor #{"vendor"},
+ :client/square-locations #{"square-location"},
+ :payment/status #{},
+ :client/location-matches #{"location-match"},
+ :saved-query/client #{"client"},
+ :transaction/payment #{"payment"},
+ :transaction-rule/vendor #{"vendor"},
+ :plaid-item/client #{"client"},
+ :account/applicability #{},
+ :journal-entry-line/account #{"account" "bank-account"},
+ :client/bank-accounts #{"bank-account"},
+ :yodlee-provider-account/client #{"client"},
+ :account/vendor-allowance #{},
+ :payment/bank-account #{"bank-account"},
+ :account/default-allowance #{},
+ :transaction-rule/yodlee-merchant #{"yodlee-merchant"},
+ :vendor/account-overrides #{"vendor-account-override"},
+ :transaction/client #{"client"},
+ :invoice/vendor #{"vendor"},
+ :sales-order/vendor #{"vendor"},
+ :expected-deposit/status #{},
+ :journal-entry/original-entity #{"transaction" "invoice"},
+ :vendor-usage/client #{"client"},
+ :transaction/expected-deposit #{"expected-deposit"},
+ :client/ezcater-locations #{"ezcater-location"},
+ :journal-entry/client #{"client"},
+ :vendor/secondary-contact #{"contact"},
+ :journal-entry/line-items #{"journal-entry-line"},
+ :vendor/legal-entity-1099-type #{},
+ :transaction-rule/bank-account #{"bank-account"},
+ :transaction-account/account #{"account"},
+ :vendor/terms-overrides #{"vendor-terms-override"},
+ :vendor/default-account #{"account"},
+ :transaction/yodlee-merchant #{"yodlee-merchant"},
+ :sales-refund/client #{"client"},
+ :client/emails #{"email-contact"},
+ :payment/vendor #{"vendor"},
+ :invoice-payment/invoice #{"invoice"},
+ :report/client #{"client"},
+ :transaction-rule/accounts #{"transaction-rule-account"},
+ :charge/client #{"client"},
+ :bank-account/type #{},
+ :invoice-expense-account/account #{"account"},
+ :vendor/legal-entity-tin-type #{},
+ :transaction/approval-status #{},
+ :import-batch/entry #{"transaction"},
+ :bank-account/intuit-bank-account #{"intuit-bank-account"},
+ :account/type #{},
+ :sales-refund/vendor #{"vendor"},
+ :bank-account/yodlee-account #{"yodlee-account"},
+ :vendor/address #{"address"},
+ :integration-status/state #{},
+ :transaction/accounts #{"transaction-account"},
+ :sales-order/charges #{"charge"},
+ :client/address #{"address"},
+ :ezcater-location/caterer #{"ezcater-caterer"},
+ :vendor-account-override/client #{"client"},
+ :bank-account/integration-status #{"integration-status"},
+ :yodlee-provider-account/accounts #{"yodlee-account"},
+ :account/invoice-allowance #{},
+ :journal-entry/vendor #{"vendor"},
+ :plaid-item/accounts #{"plaid-account"},
+ :vendor-usage/vendor #{"vendor"},
+ :sales-order/line-items #{"order-line-item"},
+ :invoice/expense-accounts #{"invoice-expense-account"},
+ :account-client-override/client #{"client"},
+ :vendor/primary-contact #{"contact"},
+ :vendor/schedule-payment-dom #{"vendor-schedule-payment-dom"},
+ :account/client-overrides #{"account-client-override"},
+ :transaction/vendor #{"vendor"},
+ :client/square-integration-status #{"integration-status"},
+ :ezcater-integration/caterers #{"ezcater-caterer"},
+ :ezcater-integration/integration-status #{"integration-status"}
+ :vendor-account-override/account #{"account"},
+ :import-batch/source #{}})
+
+(def entity-dependencies
+ {"transaction-rule"
+ #{"vendor" "yodlee-merchant" "transaction-rule-account" "bank-account"
+ "client"},
+ "square-location" #{},
+ "expected-deposit" #{"vendor" "charge" "client"},
+ "journal-entry-line" #{"account" "bank-account"},
+ "vendor"
+ #{"vendor-schedule-payment-dom" "address" "account" "client" "contact"
+ "vendor-account-override"},
+ "transaction"
+ #{"transaction-rule" "expected-deposit" "vendor" "yodlee-merchant"
+ "transaction-account" "forecasted-transaction" "bank-account" "client"
+ "payment"},
+ "yodlee-provider-account" #{"yodlee-account" "client"},
+ "journal-entry"
+ #{"journal-entry-line" "vendor" "transaction" "invoice" "client"},
+ "yodlee-merchant" #{},
+ "invoice" #{"vendor" "invoice-expense-account" "client"},
+ "vendor-terms-override" #{},
+ "integration-status" #{},
+ "conformity" #{},
+ "user" #{"client"},
+ "sales-refund" #{"vendor" "client"},
+ "plaid-account" #{},
+ "charge" #{"client"},
+ "location-match" #{},
+ "vendor-schedule-payment-dom" #{"client"},
+ "account-client-override" #{"client"},
+ "plaid-item" #{"plaid-account" "client"},
+ "transaction-account" #{"account"},
+ "address" #{},
+ "order-line-item" #{},
+ "ezcater-location" #{"ezcater-caterer"},
+ "account" #{"account-client-override"},
+ "intuit-bank-account" #{},
+ "saved-query" #{"client"},
+ "ezcater-caterer" #{},
+ "forecasted-transaction" #{},
+ "audit" #{},
+ "yodlee-account" #{},
+ "transaction-rule-account" #{"account"},
+ "ezcater-integration" #{"ezcater-caterer" "integration-status"},
+ "report" #{"client"},
+ "bank-account" #{"integration-status" "intuit-bank-account" "yodlee-account"},
+ "vendor-usage" #{"vendor" "client"},
+ "invoice-expense-account" #{"account"},
+ "sales-order" #{"vendor" "charge" "order-line-item" "client"},
+ "client"
+ #{"square-location" "integration-status" "location-match" "address"
+ "ezcater-location" "forecasted-transaction" "bank-account" "email-contact"},
+ "email-contact" #{},
+ "invoice-payment" #{"invoice" "payment"},
+ "contact" #{},
+ "import-batch" #{"transaction"},
+ "payment" #{"vendor" "invoice" "bank-account" "client"},
+ "vendor-account-override" #{"account" "client"}})
+
+(defn order-of-insert [entity-dependencies]
+ (loop [entity-dependencies entity-dependencies
+ order []]
+ (let [next-order (for [[entity deps] entity-dependencies
+ :when (not (seq deps))]
+ entity)
+ next-deps (reduce
+ (fn [entity-dependencies next-entity]
+ (into {}
+ (map
+ (fn [[k v]]
+ [k (disj v next-entity)])
+ entity-dependencies)))
+ (apply dissoc entity-dependencies next-order)
+ next-order)]
+ (if (seq next-deps)
+ (recur next-deps (into order next-order))
+ (into order next-order)))))
+
+
+(def loaded (atom #{}))
+
+
+(def dumped (atom #{}))
+
+(defn write-s3 [data location]
+ (spit (io/file "/tmp/temp-edn")
+ (with-out-str (clojure.pprint/pprint data)))
+ (s3/put-object :bucket-name (:data-bucket env)
+ :key location
+ :input-stream (io/make-input-stream (io/file "/tmp/temp-edn") {})))
+
+(defn dump-schema [schema backup]
+ (write-s3 (map
+ (fn [s]
+ (set/rename-keys s {:db/id :entity/migration-key}))
+ schema)
+ (str backup "/schema.edn"))
+ (write-s3 full-dependencies
+ (str backup "/full-dependencies.edn"))
+ (write-s3 entity-dependencies
+ (str backup "/entity-dependencies.edn")))
+
+(defn pull-batch [remote-db schema entity entities]
+ (de/future-with request-pool
+ (mu/with-context {:entity entity}
+ (try
+ (when (= 0 (rand-int 100))
+ (mu/log ::pulling :count (count entities)))
+ (->> (d/pull-many remote-db
+ (->> schema
+ (filter :db/valueType)
+ (mapv :db/ident)
+ (filter #(= entity (namespace %)))
+ (into [:db/id]))
+ entities)
+ (mapv (fn [m ]
+ (reduce
+ (fn [m [k v]]
+ (cond
+ (= k :db/id)
+ (-> m
+ (assoc :entity/migration-key v)
+ (dissoc :db/id))
+ (full-dependencies k)
+ (if (vector? v)
+ (assoc m k (mapv (fn [r] [:entity/migration-key (:db/id r)]) v))
+ (assoc m k [:entity/migration-key (:db/id v)]))
+ :else
+ (dissoc m :payment/pdf-data
+ :payment/memo
+ :vendor/invoice-reminder-schedule)))
+ m
+ m))))
+ (catch Throwable e
+ (mu/log ::pull-error
+ :exception e)
+
+ (throw e))))))
+
+(def in-flight (atom 0))
+
+(def so-far (atom 0))
+(def total (atom 0))
+
+(defn dump-all
+ ([] (dump-all nil))
+ ([item-list]
+ (let [backup-id (str "/datomic-backup/" (java.util.UUID/randomUUID))
+ _ (mu/log ::starting-backup :backup backup-id)
+ remote-db (d/db (datomic.api/connect "datomic:ddb://us-east-1/integreat/integreat-prod"))
+ _ (mu/log ::fetching-schema)
+ schema (get-schema remote-db)
+ ]
+ (mu/log ::dumping-schema)
+ (dump-schema schema backup-id)
+ (mu/log ::schema-dumped)
+ (doseq [entity (or item-list (filter (complement (conj @loaded "audit")) (order-of-insert entity-dependencies)))
+ :let [_ (swap! dumped conj entity)
+ _ (reset! so-far 0)
+ _ (mu/log ::querying :entity entity)
+ entities (d/q '[:find [?e ...]
+ :in $ [?a ...]
+ :where [?e ?a]]
+ remote-db
+ (cond-> (entity->best-key entity)
+ (not (vector? (entity->best-key entity))) vector))
+
+ _ (reset! total (count entities))
+ _ (mu/log ::entity-total-found :count (count entities) :entity entity)]]
+ (mu/trace ::single-entity
+ [:entity entity]
+ (mu/with-context {:entity entity :total @total}
+ (mu/log ::starting)
+ (mu/log ::deleting)
+ (io/delete-file (io/file "/tmp/tmp-ednl") true)
+ (mu/log ::pulling)
+ (ednl/with-append [append "/tmp/tmp-ednl" ]
+ @(s/consume (fn [batch]
+ (mu/with-context {:entity entity :total @total}
+ (doseq [a batch]
+ (try
+ (append a)
+ (catch Exception e
+ (mu/log ::error
+ :exception e)
+ (throw e)))
+ )
+ (swap! so-far #(+ % (count batch)))
+ (when (= 0 (rand-int 100))
+ (mu/log ::appended :count (count batch)
+ :so-far @so-far))))
+ (->> (partition-all 100 entities)
+ (into [])
+ (s/->source)
+ (s/onto buffered)
+ (s/buffer 20)
+ (s/map (fn [entities]
+ (pull-batch remote-db schema entity entities)))
+ (s/buffer 20)
+ (s/realize-each)))
+ )
+ (try
+ (mu/log ::copying)
+ (let [f (io/file "/tmp/tmp-ednl")]
+ (s3/put-object :bucket-name (:data-bucket env)
+ :key (str backup-id "/" entity ".ednl")
+ :input-stream (io/make-input-stream f {})
+ :metadata {:content-length (.length f)}))
+ (mu/log ::copied)
+ (catch Exception e
+ (mu/log ::upload-error
+ :exception e)
+ (throw e)))))))))
+
+(defn -main [& _]
+ (try
+ (execute "export-backup" #(dump-all))
+ (catch Exception e
+ (println e)
+ (mu/log ::quit-error
+ :exception e
+ :background-job "export-backup"
+ :service "export-backup")
+ (Thread/sleep 5000)
+ (throw e))))
diff --git a/src/clj/auto_ap/jobs/ntg.clj b/src/clj/auto_ap/jobs/ntg.clj
index 2a62db1f..46ef79f3 100644
--- a/src/clj/auto_ap/jobs/ntg.clj
+++ b/src/clj/auto_ap/jobs/ntg.clj
@@ -1,53 +1,38 @@
(ns auto-ap.jobs.ntg
(:require
[amazonica.aws.s3 :as s3]
- [auto-ap.datomic.clients :as d-clients]
+[iol-ion.tx :refer [propose-invoice]]
+ [auto-ap.datomic :refer [conn]]
[auto-ap.jobs.core :refer [execute]]
- [iol-ion.tx :refer [propose-invoice]]
[auto-ap.logging :as log]
[auto-ap.parse :as parse]
[auto-ap.time :as atime]
[clj-time.coerce :as coerce]
+ [clj-time.core :as time]
[clojure.data.csv :as csv]
[clojure.java.io :as io]
- [clojure.string :as str])
+ [clojure.string :as str]
+ [clojure.xml :as xml]
+ [clojure.zip :as zip]
+ [datomic.client.api :as d])
(:import
(java.util UUID)))
(def bucket-name "data.prod.app.integreatconsult.com" #_(:data-bucket env))
-(defn read-csv [k]
- (log/info ::reading-csv :key k)
- (-> (s3/get-object {:bucket-name bucket-name
- :key k})
- :input-stream
+(defn read-csv [stream]
+ (-> stream
io/reader
csv/read-csv))
+(defn read-xml [stream]
+ (-> (slurp stream)
+ (.getBytes)
+ (java.io.ByteArrayInputStream. )
+ xml/parse
+ zip/xml-zip))
+
-(defn extract-invoice-details [csv-rows clients]
- (clojure.pprint/pprint (take 4 csv-rows))
- (->> csv-rows
- (drop 1)
- (filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]]
-
- (= "Y" break-flag)))
- (map (fn [[vendor location-hint invoice-number ship-date invoice-total ]]
-
- (let [[matching-client similarity] (and location-hint
- (parse/best-match clients location-hint 0.0))]
- (clojure.pprint/pprint {:invoice/vendor vendor
- :invoice/location (parse/best-location-match matching-client location-hint location-hint )
- :invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date))
- :invoice/invoice-number invoice-number
- :invoice/total (Double/parseDouble invoice-total)
- :invoice/outstanding-balance (Double/parseDouble invoice-total)
- :invoice/client matching-client
- :invoice/import-status :import-status/completed
- :invoice/status :invoice-status/unpaid
- :invoice/client-identifier location-hint
- }))))
- (filter :invoice/client)))
(defn mark-key [k]
(s3/copy-object {:source-bucket-name bucket-name
@@ -60,46 +45,209 @@
(defn is-csv-file? [x]
(= "csv" (last (str/split x #"[\\.]"))))
+(defn decipher-source [k]
+ (cond
+ (str/includes? k "Cintas")
+ :cintas
+
+ (and (str/includes? k "GeneralProduce")
+ (is-csv-file? k))
+ :general-produce
+
+ :else
+ :unknown))
+
+(defmulti extract-invoice-details (fn [key input-stream clients]
+ (decipher-source key)))
+
+(defmethod extract-invoice-details :general-produce
+ [k input-stream clients]
+ (log/info ::parsing-general-produce :key k)
+ (->> (read-csv input-stream)
+ (drop 1)
+ (filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]]
+ (= "Y" break-flag)))
+ (map (fn [[vendor location-hint invoice-number ship-date invoice-total ]]
+ (let [[matching-client similarity] (and location-hint
+ (parse/best-match clients location-hint 0.0))]
+ {:invoice/vendor vendor
+ :invoice/location (parse/best-location-match matching-client location-hint location-hint )
+ :invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date))
+ :invoice/invoice-number invoice-number
+ :invoice/total (Double/parseDouble invoice-total)
+ :invoice/outstanding-balance (Double/parseDouble invoice-total)
+ :invoice/client matching-client
+ :invoice/import-status :import-status/imported
+ :invoice/status :invoice-status/unpaid
+ :invoice/client-identifier location-hint
+ })))
+ (filter :invoice/client)))
+
+(defmethod extract-invoice-details :unknown
+ [k input-stream clients]
+ (log/warn ::unknown-invoice-format
+ :key k)
+ [])
+
+(defn zip-seq [zipper]
+ (->> (zip/xml-zip (zip/node zipper))
+ (iterate zip/next )
+ (take-while (complement zip/end?))))
+
+(defmethod extract-invoice-details :cintas
+ [k input-stream clients]
+ (log/info ::parsing-cintas :key k)
+ (let [vendor (d/pull (d/db conn) '[:vendor/default-account] :vendor/cintas)
+ top (read-xml input-stream)
+ node-seq (->> top
+ (iterate zip/next)
+ (take-while (complement zip/end?)))
+ location-hint (->> node-seq
+ (filter (fn [z]
+ (= (:tag (zip/node z))
+ :InvoiceDetailShipping)))
+ first
+ zip-seq
+ (map zip/node)
+ (filter (fn [node]
+ (= :Street
+ (:tag node))))
+ first
+ :content
+ first)
+ [matching-client similarity] (and location-hint (parse/best-match clients location-hint 0.0))
+
+ ]
+ (if matching-client
+ (let [invoice-date (->> node-seq
+ (map zip/node)
+ (filter (fn [node]
+ (= (:tag node)
+ :InvoiceDetailRequestHeader)))
+ first
+ (#(-> % :attrs :invoiceDate
+ coerce/to-date-time
+ atime/localize
+ (atime/unparse atime/iso-date)
+ (atime/parse atime/iso-date))))
+ location (parse/best-location-match matching-client location-hint location-hint )
+ due (-> invoice-date
+ (time/plus (time/days 30))
+ (coerce/to-date))
+ total (->> node-seq
+ (filter (fn [zipper]
+ (= (:tag (zip/node zipper))
+ :NetAmount)))
+ first
+ zip-seq
+ (map zip/node)
+ (filter (fn [node]
+ (= :Money
+ (:tag node))))
+ first
+ :content
+ first
+ Double/parseDouble)
+ invoice {:invoice/vendor :vendor/cintas
+ :invoice/import-status :import-status/imported
+ :invoice/status :invoice-status/unpaid
+ :invoice/location location
+ :invoice/client-identifier location-hint
+ :invoice/client (:db/id matching-client)
+ :invoice/total total
+ :invoice/outstanding-balance total
+ :invoice/invoice-number (->> node-seq
+ (map zip/node)
+ (filter (fn [node]
+ (= (:tag node)
+ :InvoiceDetailRequestHeader)))
+ first
+ (#(-> % :attrs :invoiceID)))
+ :invoice/due due
+
+ :invoice/scheduled-payment (when-not ((into #{} (->> matching-client
+ :client/feature-flags))
+ "manually-pay-cintas")
+ due)
+
+ :invoice/date (coerce/to-date invoice-date)
+ :invoice/expense-accounts [{:invoice-expense-account/account
+ (-> vendor :vendor/default-account :db/id)
+ :invoice-expense-account/location location
+ :invoice-expense-account/amount (Math/abs total)
+ }]}]
+ (log/info ::cintas-invoice-importing
+ :invoice invoice)
+ [invoice])
+ (do
+ (log/info ::missing-client
+ :client-hint location-hint)
+ []))))
+
+(defn mark-error [k]
+ (s3/copy-object {:source-bucket-name bucket-name
+ :destination-bucket-name bucket-name
+ :source-key k
+ :destination-key (str "ntg-invoices/error/"
+ (.getName (io/file k)))}))
+
+(defn copy-readable-version [k]
+ (let [invoice-key (str "invoice-files/" (UUID/randomUUID) "." (last (str/split k #"[\\.]")))]
+ (log/info ::assigned-random-key
+ :key k
+ :invoice-key invoice-key)
+ (s3/copy-object {:source-bucket-name bucket-name
+ :destination-bucket-name bucket-name
+ :source-key k
+ :destination-key invoice-key })
+ invoice-key))
+
(defn import-ntg-invoices []
- (let [clients (d-clients/get-all)
- keys (->> (s3/list-objects-v2 {:bucket-name bucket-name
- :prefix "ntg-invoices/pending"})
- :object-summaries
- (map :key))]
+ (let [clients (map first (d/q '[:find (pull ?c [:client/code
+ :db/id
+ :client/feature-flags
+ {:client/location-matches [:location-match/matches :location-match/location]}
+ :client/name
+ :client/matches
+ :client/locations])
+ :where [?c :client/code]]
+ (d/db conn)))
+ keys (->> (s3/list-objects-v2 {:bucket-name bucket-name
+ :prefix "ntg-invoices/pending"})
+ :object-summaries
+ (map :key))]
(log/info ::found-invoice-keys
:keys keys )
(let [transaction (->> keys
- (filter is-csv-file?)
(mapcat (fn [k]
(try
- (log/info ::trying-csv :key k)
- (let [invoice-key (str "invoice-files/" (UUID/randomUUID) ".csv") ;
+ (let [invoice-key (copy-readable-version k)
invoice-url (str "http://" bucket-name ".s3-website-us-east-1.amazonaws.com/" invoice-key)]
- (s3/copy-object {:source-bucket-name bucket-name
- :destination-bucket-name bucket-name
- :source-key k
- :destination-key invoice-key})
- (->> (extract-invoice-details (read-csv k) clients)
- (map (fn [i]
- [`(propose-invoice ~(assoc i :invoice/source-url invoice-url))]))
- ))
- (catch Exception e
+ (with-open [is (-> (s3/get-object {:bucket-name bucket-name
+ :key k})
+ :input-stream)]
+ (->> (extract-invoice-details k
+ is
+ clients)
+ (map (fn [i]
+ (log/info ::importing-invoice
+ :invoice i)
+ i))
+ (mapv (fn [i]
+ `(propose-invoice ~(assoc i :invoice/source-url invoice-url))))))) (catch Exception e
(log/error ::cant-load-file
:key k
:exception e)
- (log/info
- (s3/copy-object {:source-bucket-name bucket-name
- :destination-bucket-name bucket-name
- :source-key k
- :destination-key (str "ntg-invoices/error/"
- (.getName (io/file k)))}))
- [])))))
- #_result #_(transact-with-ledger transaction {:user/name "sysco importer" :user/role "admin"})]
- (clojure.pprint/pprint transaction)
- #_(log/infof "Imported %d invoices" (/ (count (:tempids result)) 2)))
+ (mark-error k)
+ []))))
+ (into []))]
+ (transact-with-ledger transaction {:user/name "sysco importer" :user/role "admin"})
+ (log/info ::success
+ :count (count transaction)
+ :sample (take 3 transaction)))
(doseq [k keys]
(mark-key k))))
diff --git a/src/clj/auto_ap/server.clj b/src/clj/auto_ap/server.clj
index aba46c4f..0558e337 100644
--- a/src/clj/auto_ap/server.clj
+++ b/src/clj/auto_ap/server.clj
@@ -9,6 +9,7 @@
[auto-ap.jobs.ezcater-upsert :as job-ezcater-upsert]
[auto-ap.jobs.import-uploaded-invoices :as job-import-uploaded-invoices]
[auto-ap.jobs.intuit :as job-intuit]
+ #_[auto-ap.backup :as backup]
[auto-ap.jobs.ledger-reconcile :as job-reconcile-ledger]
[auto-ap.jobs.load-historical-sales :as job-load-historical-sales]
[auto-ap.jobs.plaid :as job-plaid]
@@ -141,6 +142,10 @@
(= job "restore-from-backup")
(job-restore-from-backup/-main)
+ (comment
+ (= job "export-backup")
+ (backup/-main))
+
:else
(do
(add-shutdown-hook! shutdown-mount)
diff --git a/src/cljc/auto_ap/ledger/reports.cljc b/src/cljc/auto_ap/ledger/reports.cljc
index 5d82e761..4b07bc50 100644
--- a/src/cljc/auto_ap/ledger/reports.cljc
+++ b/src/cljc/auto_ap/ledger/reports.cljc
@@ -75,6 +75,7 @@
:operating-activities [
;; BEN EDIT STARTING HERE
+ ["20100-20199 Credit Card Balances" 20100 20199 :add]
["21000-24000 Accounts Payable" 21000 23999 :add]
["25000-28000 Accounts Payable" 25000 27999 :add]
["24000-25000 Accrual Liabilities" 24000 24999 :add]
@@ -678,15 +679,17 @@
:financing-activities
(str prefix " Financing Activities")))
+ (conj (cashflow-subtotal-by-column-row (map #(-> %
+ (filter-categories [:operating-activities :investment-activities :financing-activities :sales :cogs :payroll :controllable :fixed-overhead :ownership-controllable])
+ (negate #{:cogs :payroll :controllable :fixed-overhead :ownership-controllable}))
+ pnl-datas)
+ "Change in Cash and Cash Equivalents"))
+
(into (cash-flow-detail-rows pnl-datas
:cash
(str prefix " Bank Accounts / Cash")))
- (conj (cashflow-subtotal-by-column-row (map #(-> %
- (filter-categories [:operating-activities :investment-activities :financing-activities :cash])
- #_(negate #{:cogs :payroll :controllable :fixed-overhead :ownership-controllable}))
- pnl-datas)
- "Change in Cash and Cash Equivalents")))]
+ )]
{:header (cash-flow-headers pnl-datas "Cash Flow")
:rows table}))
diff --git a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs
index b361a52c..15e324d5 100644
--- a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs
+++ b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs
@@ -545,7 +545,8 @@
[com/multi-field-v2 {:allow-change? true
:template [[form-builder/raw-field-v2 {:field :feature-flag}
[com/select-field {:options [[nil nil]
- ["new-square" "New Square+Ezcater"]]
+ ["new-square" "New Square+Ezcater"]
+ ["manually-pay-cintas" "Manually Pay Cintas"]]
:allow-nil? false
:style {:width "18em"}}]]]
:key-fn :id
diff --git a/src/cljs/auto_ap/views/pages/admin/jobs.cljs b/src/cljs/auto_ap/views/pages/admin/jobs.cljs
index dafe6836..cbb5c274 100644
--- a/src/cljs/auto_ap/views/pages/admin/jobs.cljs
+++ b/src/cljs/auto_ap/views/pages/admin/jobs.cljs
@@ -144,7 +144,8 @@
[:square2-import-job "Square2 Import"]
[:register-invoice-import "Register Invoice Import "]
[:ezcater-upsert "Upsert recent ezcater orders"]
- [:load-historical-sales "Load Historical Square Sales"]]
+ [:load-historical-sales "Load Historical Square Sales"]
+ [:export-backup "Export Backup"]]
:allow-nil? true
:keywordize? true}]]
(cond (= :bulk-journal-import (:job data))
diff --git a/src/cljs/auto_ap/views/pages/ledger/cash_flows.cljs b/src/cljs/auto_ap/views/pages/ledger/cash_flows.cljs
index b135dcfc..5102cc1a 100644
--- a/src/cljs/auto_ap/views/pages/ledger/cash_flows.cljs
+++ b/src/cljs/auto_ap/views/pages/ledger/cash_flows.cljs
@@ -416,7 +416,7 @@ NOTE: Please review the transactions we may have question for you here: https://
report (l-reports/summarize-cash-flows pnl-data)
table (rtable/concat-tables (:details report))]
[:div
- [:h1.title "Profit and Loss - " (str/join ", " (map (comp :name :client) (:clients args)))]
+ [:h1.title "Statement of Cash Flows - " (str/join ", " (map (comp :name :client) (:clients args)))]
(when (:warning report)
[:div.notification.is-warning.is-light
(:warning report)])
diff --git a/terraform/.gitx/HEAD b/terraform/.gitx/HEAD
new file mode 100644
index 00000000..cb089cd8
--- /dev/null
+++ b/terraform/.gitx/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/terraform/.gitx/config b/terraform/.gitx/config
new file mode 100644
index 00000000..515f4836
--- /dev/null
+++ b/terraform/.gitx/config
@@ -0,0 +1,5 @@
+[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = false
+ logallrefupdates = true
diff --git a/terraform/.gitx/description b/terraform/.gitx/description
new file mode 100644
index 00000000..498b267a
--- /dev/null
+++ b/terraform/.gitx/description
@@ -0,0 +1 @@
+Unnamed repository; edit this file 'description' to name the repository.
diff --git a/terraform/.gitx/hooks/applypatch-msg.sample b/terraform/.gitx/hooks/applypatch-msg.sample
new file mode 100755
index 00000000..a5d7b84a
--- /dev/null
+++ b/terraform/.gitx/hooks/applypatch-msg.sample
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message taken by
+# applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit. The hook is
+# allowed to edit the commit message file.
+#
+# To enable this hook, rename this file to "applypatch-msg".
+
+. git-sh-setup
+commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
+test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
+:
diff --git a/terraform/.gitx/hooks/commit-msg.sample b/terraform/.gitx/hooks/commit-msg.sample
new file mode 100755
index 00000000..b58d1184
--- /dev/null
+++ b/terraform/.gitx/hooks/commit-msg.sample
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message.
+# Called by "git commit" with one argument, the name of the file
+# that has the commit message. The hook should exit with non-zero
+# status after issuing an appropriate message if it wants to stop the
+# commit. The hook is allowed to edit the commit message file.
+#
+# To enable this hook, rename this file to "commit-msg".
+
+# Uncomment the below to add a Signed-off-by line to the message.
+# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
+# hook is more suited to it.
+#
+# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
+# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
+
+# This example catches duplicate Signed-off-by lines.
+
+test "" = "$(grep '^Signed-off-by: ' "$1" |
+ sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
+ echo >&2 Duplicate Signed-off-by lines.
+ exit 1
+}
diff --git a/terraform/.gitx/hooks/fsmonitor-watchman.sample b/terraform/.gitx/hooks/fsmonitor-watchman.sample
new file mode 100755
index 00000000..23e856f5
--- /dev/null
+++ b/terraform/.gitx/hooks/fsmonitor-watchman.sample
@@ -0,0 +1,174 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use IPC::Open2;
+
+# An example hook script to integrate Watchman
+# (https://facebook.github.io/watchman/) with git to speed up detecting
+# new and modified files.
+#
+# The hook is passed a version (currently 2) and last update token
+# formatted as a string and outputs to stdout a new update token and
+# all files that have been modified since the update token. Paths must
+# be relative to the root of the working tree and separated by a single NUL.
+#
+# To enable this hook, rename this file to "query-watchman" and set
+# 'git config core.fsmonitor .git/hooks/query-watchman'
+#
+my ($version, $last_update_token) = @ARGV;
+
+# Uncomment for debugging
+# print STDERR "$0 $version $last_update_token\n";
+
+# Check the hook interface version
+if ($version ne 2) {
+ die "Unsupported query-fsmonitor hook version '$version'.\n" .
+ "Falling back to scanning...\n";
+}
+
+my $git_work_tree = get_working_dir();
+
+my $retry = 1;
+
+my $json_pkg;
+eval {
+ require JSON::XS;
+ $json_pkg = "JSON::XS";
+ 1;
+} or do {
+ require JSON::PP;
+ $json_pkg = "JSON::PP";
+};
+
+launch_watchman();
+
+sub launch_watchman {
+ my $o = watchman_query();
+ if (is_work_tree_watched($o)) {
+ output_result($o->{clock}, @{$o->{files}});
+ }
+}
+
+sub output_result {
+ my ($clockid, @files) = @_;
+
+ # Uncomment for debugging watchman output
+ # open (my $fh, ">", ".git/watchman-output.out");
+ # binmode $fh, ":utf8";
+ # print $fh "$clockid\n@files\n";
+ # close $fh;
+
+ binmode STDOUT, ":utf8";
+ print $clockid;
+ print "\0";
+ local $, = "\0";
+ print @files;
+}
+
+sub watchman_clock {
+ my $response = qx/watchman clock "$git_work_tree"/;
+ die "Failed to get clock id on '$git_work_tree'.\n" .
+ "Falling back to scanning...\n" if $? != 0;
+
+ return $json_pkg->new->utf8->decode($response);
+}
+
+sub watchman_query {
+ my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
+ or die "open2() failed: $!\n" .
+ "Falling back to scanning...\n";
+
+ # In the query expression below we're asking for names of files that
+ # changed since $last_update_token but not from the .git folder.
+ #
+ # To accomplish this, we're using the "since" generator to use the
+ # recency index to select candidate nodes and "fields" to limit the
+ # output to file names only. Then we're using the "expression" term to
+ # further constrain the results.
+ my $last_update_line = "";
+ if (substr($last_update_token, 0, 1) eq "c") {
+ $last_update_token = "\"$last_update_token\"";
+ $last_update_line = qq[\n"since": $last_update_token,];
+ }
+ my $query = <<" END";
+ ["query", "$git_work_tree", {$last_update_line
+ "fields": ["name"],
+ "expression": ["not", ["dirname", ".git"]]
+ }]
+ END
+
+ # Uncomment for debugging the watchman query
+ # open (my $fh, ">", ".git/watchman-query.json");
+ # print $fh $query;
+ # close $fh;
+
+ print CHLD_IN $query;
+ close CHLD_IN;
+ my $response = do {local $/; };
+
+ # Uncomment for debugging the watch response
+ # open ($fh, ">", ".git/watchman-response.json");
+ # print $fh $response;
+ # close $fh;
+
+ die "Watchman: command returned no output.\n" .
+ "Falling back to scanning...\n" if $response eq "";
+ die "Watchman: command returned invalid output: $response\n" .
+ "Falling back to scanning...\n" unless $response =~ /^\{/;
+
+ return $json_pkg->new->utf8->decode($response);
+}
+
+sub is_work_tree_watched {
+ my ($output) = @_;
+ my $error = $output->{error};
+ if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
+ $retry--;
+ my $response = qx/watchman watch "$git_work_tree"/;
+ die "Failed to make watchman watch '$git_work_tree'.\n" .
+ "Falling back to scanning...\n" if $? != 0;
+ $output = $json_pkg->new->utf8->decode($response);
+ $error = $output->{error};
+ die "Watchman: $error.\n" .
+ "Falling back to scanning...\n" if $error;
+
+ # Uncomment for debugging watchman output
+ # open (my $fh, ">", ".git/watchman-output.out");
+ # close $fh;
+
+ # Watchman will always return all files on the first query so
+ # return the fast "everything is dirty" flag to git and do the
+ # Watchman query just to get it over with now so we won't pay
+ # the cost in git to look up each individual file.
+ my $o = watchman_clock();
+ $error = $output->{error};
+
+ die "Watchman: $error.\n" .
+ "Falling back to scanning...\n" if $error;
+
+ output_result($o->{clock}, ("/"));
+ $last_update_token = $o->{clock};
+
+ eval { launch_watchman() };
+ return 0;
+ }
+
+ die "Watchman: $error.\n" .
+ "Falling back to scanning...\n" if $error;
+
+ return 1;
+}
+
+sub get_working_dir {
+ my $working_dir;
+ if ($^O =~ 'msys' || $^O =~ 'cygwin') {
+ $working_dir = Win32::GetCwd();
+ $working_dir =~ tr/\\/\//;
+ } else {
+ require Cwd;
+ $working_dir = Cwd::cwd();
+ }
+
+ return $working_dir;
+}
diff --git a/terraform/.gitx/hooks/post-update.sample b/terraform/.gitx/hooks/post-update.sample
new file mode 100755
index 00000000..ec17ec19
--- /dev/null
+++ b/terraform/.gitx/hooks/post-update.sample
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# An example hook script to prepare a packed repository for use over
+# dumb transports.
+#
+# To enable this hook, rename this file to "post-update".
+
+exec git update-server-info
diff --git a/terraform/.gitx/hooks/pre-applypatch.sample b/terraform/.gitx/hooks/pre-applypatch.sample
new file mode 100755
index 00000000..4142082b
--- /dev/null
+++ b/terraform/.gitx/hooks/pre-applypatch.sample
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed
+# by applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit.
+#
+# To enable this hook, rename this file to "pre-applypatch".
+
+. git-sh-setup
+precommit="$(git rev-parse --git-path hooks/pre-commit)"
+test -x "$precommit" && exec "$precommit" ${1+"$@"}
+:
diff --git a/terraform/.gitx/hooks/pre-commit.sample b/terraform/.gitx/hooks/pre-commit.sample
new file mode 100755
index 00000000..e144712c
--- /dev/null
+++ b/terraform/.gitx/hooks/pre-commit.sample
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed.
+# Called by "git commit" with no arguments. The hook should
+# exit with non-zero status after issuing an appropriate message if
+# it wants to stop the commit.
+#
+# To enable this hook, rename this file to "pre-commit".
+
+if git rev-parse --verify HEAD >/dev/null 2>&1
+then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=$(git hash-object -t tree /dev/null)
+fi
+
+# If you want to allow non-ASCII filenames set this variable to true.
+allownonascii=$(git config --type=bool hooks.allownonascii)
+
+# Redirect output to stderr.
+exec 1>&2
+
+# Cross platform projects tend to avoid non-ASCII filenames; prevent
+# them from being added to the repository. We exploit the fact that the
+# printable range starts at the space character and ends with tilde.
+if [ "$allownonascii" != "true" ] &&
+ # Note that the use of brackets around a tr range is ok here, (it's
+ # even required, for portability to Solaris 10's /usr/bin/tr), since
+ # the square bracket bytes happen to fall in the designated range.
+ test $(git diff --cached --name-only --diff-filter=A -z $against |
+ LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
+then
+ cat <<\EOF
+Error: Attempt to add a non-ASCII file name.
+
+This can cause problems if you want to work with people on other platforms.
+
+To be portable it is advisable to rename the file.
+
+If you know what you are doing you can disable this check using:
+
+ git config hooks.allownonascii true
+EOF
+ exit 1
+fi
+
+# If there are whitespace errors, print the offending file names and fail.
+exec git diff-index --check --cached $against --
diff --git a/terraform/.gitx/hooks/pre-merge-commit.sample b/terraform/.gitx/hooks/pre-merge-commit.sample
new file mode 100755
index 00000000..399eab19
--- /dev/null
+++ b/terraform/.gitx/hooks/pre-merge-commit.sample
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed.
+# Called by "git merge" with no arguments. The hook should
+# exit with non-zero status after issuing an appropriate message to
+# stderr if it wants to stop the merge commit.
+#
+# To enable this hook, rename this file to "pre-merge-commit".
+
+. git-sh-setup
+test -x "$GIT_DIR/hooks/pre-commit" &&
+ exec "$GIT_DIR/hooks/pre-commit"
+:
diff --git a/terraform/.gitx/hooks/pre-push.sample b/terraform/.gitx/hooks/pre-push.sample
new file mode 100755
index 00000000..4ce688d3
--- /dev/null
+++ b/terraform/.gitx/hooks/pre-push.sample
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# An example hook script to verify what is about to be pushed. Called by "git
+# push" after it has checked the remote status, but before anything has been
+# pushed. If this script exits with a non-zero status nothing will be pushed.
+#
+# This hook is called with the following parameters:
+#
+# $1 -- Name of the remote to which the push is being done
+# $2 -- URL to which the push is being done
+#
+# If pushing without using a named remote those arguments will be equal.
+#
+# Information about the commits which are being pushed is supplied as lines to
+# the standard input in the form:
+#
+#
+#
+# This sample shows how to prevent push of commits where the log message starts
+# with "WIP" (work in progress).
+
+remote="$1"
+url="$2"
+
+zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing"
+ exit 1
+ fi
+ fi
+done
+
+exit 0
diff --git a/terraform/.gitx/hooks/pre-rebase.sample b/terraform/.gitx/hooks/pre-rebase.sample
new file mode 100755
index 00000000..6cbef5c3
--- /dev/null
+++ b/terraform/.gitx/hooks/pre-rebase.sample
@@ -0,0 +1,169 @@
+#!/bin/sh
+#
+# Copyright (c) 2006, 2008 Junio C Hamano
+#
+# The "pre-rebase" hook is run just before "git rebase" starts doing
+# its job, and can prevent the command from running by exiting with
+# non-zero status.
+#
+# The hook is called with the following parameters:
+#
+# $1 -- the upstream the series was forked from.
+# $2 -- the branch being rebased (or empty when rebasing the current branch).
+#
+# This sample shows how to prevent topic branches that are already
+# merged to 'next' branch from getting rebased, because allowing it
+# would result in rebasing already published history.
+
+publish=next
+basebranch="$1"
+if test "$#" = 2
+then
+ topic="refs/heads/$2"
+else
+ topic=`git symbolic-ref HEAD` ||
+ exit 0 ;# we do not interrupt rebasing detached HEAD
+fi
+
+case "$topic" in
+refs/heads/??/*)
+ ;;
+*)
+ exit 0 ;# we do not interrupt others.
+ ;;
+esac
+
+# Now we are dealing with a topic branch being rebased
+# on top of master. Is it OK to rebase it?
+
+# Does the topic really exist?
+git show-ref -q "$topic" || {
+ echo >&2 "No such branch $topic"
+ exit 1
+}
+
+# Is topic fully merged to master?
+not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
+if test -z "$not_in_master"
+then
+ echo >&2 "$topic is fully merged to master; better remove it."
+ exit 1 ;# we could allow it, but there is no point.
+fi
+
+# Is topic ever merged to next? If so you should not be rebasing it.
+only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
+only_next_2=`git rev-list ^master ${publish} | sort`
+if test "$only_next_1" = "$only_next_2"
+then
+ not_in_topic=`git rev-list "^$topic" master`
+ if test -z "$not_in_topic"
+ then
+ echo >&2 "$topic is already up to date with master"
+ exit 1 ;# we could allow it, but there is no point.
+ else
+ exit 0
+ fi
+else
+ not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
+ /usr/bin/perl -e '
+ my $topic = $ARGV[0];
+ my $msg = "* $topic has commits already merged to public branch:\n";
+ my (%not_in_next) = map {
+ /^([0-9a-f]+) /;
+ ($1 => 1);
+ } split(/\n/, $ARGV[1]);
+ for my $elem (map {
+ /^([0-9a-f]+) (.*)$/;
+ [$1 => $2];
+ } split(/\n/, $ARGV[2])) {
+ if (!exists $not_in_next{$elem->[0]}) {
+ if ($msg) {
+ print STDERR $msg;
+ undef $msg;
+ }
+ print STDERR " $elem->[1]\n";
+ }
+ }
+ ' "$topic" "$not_in_next" "$not_in_master"
+ exit 1
+fi
+
+<<\DOC_END
+
+This sample hook safeguards topic branches that have been
+published from being rewound.
+
+The workflow assumed here is:
+
+ * Once a topic branch forks from "master", "master" is never
+ merged into it again (either directly or indirectly).
+
+ * Once a topic branch is fully cooked and merged into "master",
+ it is deleted. If you need to build on top of it to correct
+ earlier mistakes, a new topic branch is created by forking at
+ the tip of the "master". This is not strictly necessary, but
+ it makes it easier to keep your history simple.
+
+ * Whenever you need to test or publish your changes to topic
+ branches, merge them into "next" branch.
+
+The script, being an example, hardcodes the publish branch name
+to be "next", but it is trivial to make it configurable via
+$GIT_DIR/config mechanism.
+
+With this workflow, you would want to know:
+
+(1) ... if a topic branch has ever been merged to "next". Young
+ topic branches can have stupid mistakes you would rather
+ clean up before publishing, and things that have not been
+ merged into other branches can be easily rebased without
+ affecting other people. But once it is published, you would
+ not want to rewind it.
+
+(2) ... if a topic branch has been fully merged to "master".
+ Then you can delete it. More importantly, you should not
+ build on top of it -- other people may already want to
+ change things related to the topic as patches against your
+ "master", so if you need further changes, it is better to
+ fork the topic (perhaps with the same name) afresh from the
+ tip of "master".
+
+Let's look at this example:
+
+ o---o---o---o---o---o---o---o---o---o "next"
+ / / / /
+ / a---a---b A / /
+ / / / /
+ / / c---c---c---c B /
+ / / / \ /
+ / / / b---b C \ /
+ / / / / \ /
+ ---o---o---o---o---o---o---o---o---o---o---o "master"
+
+
+A, B and C are topic branches.
+
+ * A has one fix since it was merged up to "next".
+
+ * B has finished. It has been fully merged up to "master" and "next",
+ and is ready to be deleted.
+
+ * C has not merged to "next" at all.
+
+We would want to allow C to be rebased, refuse A, and encourage
+B to be deleted.
+
+To compute (1):
+
+ git rev-list ^master ^topic next
+ git rev-list ^master next
+
+ if these match, topic has not merged in next at all.
+
+To compute (2):
+
+ git rev-list master..topic
+
+ if this is empty, it is fully merged to "master".
+
+DOC_END
diff --git a/terraform/.gitx/hooks/pre-receive.sample b/terraform/.gitx/hooks/pre-receive.sample
new file mode 100755
index 00000000..a1fd29ec
--- /dev/null
+++ b/terraform/.gitx/hooks/pre-receive.sample
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# An example hook script to make use of push options.
+# The example simply echoes all push options that start with 'echoback='
+# and rejects all pushes when the "reject" push option is used.
+#
+# To enable this hook, rename this file to "pre-receive".
+
+if test -n "$GIT_PUSH_OPTION_COUNT"
+then
+ i=0
+ while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
+ do
+ eval "value=\$GIT_PUSH_OPTION_$i"
+ case "$value" in
+ echoback=*)
+ echo "echo from the pre-receive-hook: ${value#*=}" >&2
+ ;;
+ reject)
+ exit 1
+ esac
+ i=$((i + 1))
+ done
+fi
diff --git a/terraform/.gitx/hooks/prepare-commit-msg.sample b/terraform/.gitx/hooks/prepare-commit-msg.sample
new file mode 100755
index 00000000..10fa14c5
--- /dev/null
+++ b/terraform/.gitx/hooks/prepare-commit-msg.sample
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# An example hook script to prepare the commit log message.
+# Called by "git commit" with the name of the file that has the
+# commit message, followed by the description of the commit
+# message's source. The hook's purpose is to edit the commit
+# message file. If the hook fails with a non-zero status,
+# the commit is aborted.
+#
+# To enable this hook, rename this file to "prepare-commit-msg".
+
+# This hook includes three examples. The first one removes the
+# "# Please enter the commit message..." help message.
+#
+# The second includes the output of "git diff --name-status -r"
+# into the message, just before the "git status" output. It is
+# commented because it doesn't cope with --amend or with squashed
+# commits.
+#
+# The third example adds a Signed-off-by line to the message, that can
+# still be edited. This is rarely a good idea.
+
+COMMIT_MSG_FILE=$1
+COMMIT_SOURCE=$2
+SHA1=$3
+
+/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
+
+# case "$COMMIT_SOURCE,$SHA1" in
+# ,|template,)
+# /usr/bin/perl -i.bak -pe '
+# print "\n" . `git diff --cached --name-status -r`
+# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
+# *) ;;
+# esac
+
+# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
+# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
+# if test -z "$COMMIT_SOURCE"
+# then
+# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
+# fi
diff --git a/terraform/.gitx/hooks/push-to-checkout.sample b/terraform/.gitx/hooks/push-to-checkout.sample
new file mode 100755
index 00000000..af5a0c00
--- /dev/null
+++ b/terraform/.gitx/hooks/push-to-checkout.sample
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# An example hook script to update a checked-out tree on a git push.
+#
+# This hook is invoked by git-receive-pack(1) when it reacts to git
+# push and updates reference(s) in its repository, and when the push
+# tries to update the branch that is currently checked out and the
+# receive.denyCurrentBranch configuration variable is set to
+# updateInstead.
+#
+# By default, such a push is refused if the working tree and the index
+# of the remote repository has any difference from the currently
+# checked out commit; when both the working tree and the index match
+# the current commit, they are updated to match the newly pushed tip
+# of the branch. This hook is to be used to override the default
+# behaviour; however the code below reimplements the default behaviour
+# as a starting point for convenient modification.
+#
+# The hook receives the commit with which the tip of the current
+# branch is going to be updated:
+commit=$1
+
+# It can exit with a non-zero status to refuse the push (when it does
+# so, it must not modify the index or the working tree).
+die () {
+ echo >&2 "$*"
+ exit 1
+}
+
+# Or it can make any necessary changes to the working tree and to the
+# index to bring them to the desired state when the tip of the current
+# branch is updated to the new commit, and exit with a zero status.
+#
+# For example, the hook can simply run git read-tree -u -m HEAD "$1"
+# in order to emulate git fetch that is run in the reverse direction
+# with git push, as the two-tree form of git read-tree -u -m is
+# essentially the same as git switch or git checkout that switches
+# branches while keeping the local changes in the working tree that do
+# not interfere with the difference between the branches.
+
+# The below is a more-or-less exact translation to shell of the C code
+# for the default behaviour for git's push-to-checkout hook defined in
+# the push_to_deploy() function in builtin/receive-pack.c.
+#
+# Note that the hook will be executed from the repository directory,
+# not from the working tree, so if you want to perform operations on
+# the working tree, you will have to adapt your code accordingly, e.g.
+# by adding "cd .." or using relative paths.
+
+if ! git update-index -q --ignore-submodules --refresh
+then
+ die "Up-to-date check failed"
+fi
+
+if ! git diff-files --quiet --ignore-submodules --
+then
+ die "Working directory has unstaged changes"
+fi
+
+# This is a rough translation of:
+#
+# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
+if git cat-file -e HEAD 2>/dev/null
+then
+ head=HEAD
+else
+ head=$(git hash-object -t tree --stdin &2
+ echo " (if you want, you could supply GIT_DIR then run" >&2
+ echo " $0 [ )" >&2
+ exit 1
+fi
+
+if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
+ echo "usage: $0 ][ " >&2
+ exit 1
+fi
+
+# --- Config
+allowunannotated=$(git config --type=bool hooks.allowunannotated)
+allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
+denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
+allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
+allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
+
+# check for no description
+projectdesc=$(sed -e '1q' "$GIT_DIR/description")
+case "$projectdesc" in
+"Unnamed repository"* | "")
+ echo "*** Project description file hasn't been set" >&2
+ exit 1
+ ;;
+esac
+
+# --- Check types
+# if $newrev is 0000...0000, it's a commit to delete a ref.
+zero=$(git hash-object --stdin &2
+ echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
+ exit 1
+ fi
+ ;;
+ refs/tags/*,delete)
+ # delete tag
+ if [ "$allowdeletetag" != "true" ]; then
+ echo "*** Deleting a tag is not allowed in this repository" >&2
+ exit 1
+ fi
+ ;;
+ refs/tags/*,tag)
+ # annotated tag
+ if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
+ then
+ echo "*** Tag '$refname' already exists." >&2
+ echo "*** Modifying a tag is not allowed in this repository." >&2
+ exit 1
+ fi
+ ;;
+ refs/heads/*,commit)
+ # branch
+ if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
+ echo "*** Creating a branch is not allowed in this repository" >&2
+ exit 1
+ fi
+ ;;
+ refs/heads/*,delete)
+ # delete branch
+ if [ "$allowdeletebranch" != "true" ]; then
+ echo "*** Deleting a branch is not allowed in this repository" >&2
+ exit 1
+ fi
+ ;;
+ refs/remotes/*,commit)
+ # tracking branch
+ ;;
+ refs/remotes/*,delete)
+ # delete tracking branch
+ if [ "$allowdeletebranch" != "true" ]; then
+ echo "*** Deleting a tracking branch is not allowed in this repository" >&2
+ exit 1
+ fi
+ ;;
+ *)
+ # Anything else (is there anything else?)
+ echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
+ exit 1
+ ;;
+esac
+
+# --- Finished
+exit 0
diff --git a/terraform/.gitx/info/exclude b/terraform/.gitx/info/exclude
new file mode 100644
index 00000000..a5196d1b
--- /dev/null
+++ b/terraform/.gitx/info/exclude
@@ -0,0 +1,6 @@
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
diff --git a/terraform/main.tf b/terraform/main.tf
index 91e8b3a3..f7fdd532 100644
--- a/terraform/main.tf
+++ b/terraform/main.tf
@@ -82,7 +82,16 @@ resource "aws_s3_bucket" "data" {
},
"Resource": "arn:aws:s3:::data.${var.stage}.app.integreatconsult.com",
"Sid": "AllowReadForProd"
- }
+ },
+ {
+ "Action": "s3:*",
+ "Effect": "Allow",
+ "Principal": {
+ "AWS": "arn:aws:iam::679918342773:role/http-proxy"
+ },
+ "Resource": "arn:aws:s3:::data.${var.stage}.app.integreatconsult.com",
+ "Sid": "AllowReadForProdProxy"
+ }
]
}
POLICY
diff --git a/terraform/terraform.tfstate.d/prod/terraform.tfstate b/terraform/terraform.tfstate.d/prod/terraform.tfstate
index 7704fb84..7886b6d8 100644
--- a/terraform/terraform.tfstate.d/prod/terraform.tfstate
+++ b/terraform/terraform.tfstate.d/prod/terraform.tfstate
@@ -1,7 +1,7 @@
{
"version": 4,
- "terraform_version": "1.3.2",
- "serial": 406,
+ "terraform_version": "1.3.8",
+ "serial": 411,
"lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51",
"outputs": {
"aws_access_key_id": {
@@ -164,7 +164,7 @@
],
"tags": {},
"tags_all": {},
- "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:415",
+ "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:520",
"timeouts": {
"delete": null
},
@@ -669,11 +669,25 @@
"lifecycle_rule": [],
"logging": [],
"object_lock_configuration": [],
- "policy": "{\"Id\":\"Policy1526084187222\",\"Statement\":[{\"Action\":\"s3:GetObject\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:s3:::data.prod.app.integreatconsult.com/*\",\"Sid\":\"Stmt1526084185514\"},{\"Action\":\"s3:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::679918342773:role/datomic-ddb\"},\"Resource\":\"arn:aws:s3:::data.prod.app.integreatconsult.com\",\"Sid\":\"AllowReadForProd\"}],\"Version\":\"2012-10-17\"}",
+ "policy": "{\"Id\":\"Policy1526084187222\",\"Statement\":[{\"Action\":\"s3:GetObject\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:s3:::data.prod.app.integreatconsult.com/*\",\"Sid\":\"Stmt1526084185514\"},{\"Action\":\"s3:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::679918342773:role/datomic-ddb\"},\"Resource\":\"arn:aws:s3:::data.prod.app.integreatconsult.com\",\"Sid\":\"AllowReadForProd\"},{\"Action\":\"s3:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::679918342773:role/http-proxy\"},\"Resource\":\"arn:aws:s3:::data.prod.app.integreatconsult.com\",\"Sid\":\"AllowReadForProdProxy\"}],\"Version\":\"2012-10-17\"}",
"region": "us-east-1",
"replication_configuration": [],
"request_payer": "BucketOwner",
- "server_side_encryption_configuration": [],
+ "server_side_encryption_configuration": [
+ {
+ "rule": [
+ {
+ "apply_server_side_encryption_by_default": [
+ {
+ "kms_master_key_id": "",
+ "sse_algorithm": "AES256"
+ }
+ ],
+ "bucket_key_enabled": false
+ }
+ ]
+ }
+ ],
"tags": {},
"tags_all": {},
"versioning": [
@@ -693,7 +707,8 @@
"website_domain": "s3-website-us-east-1.amazonaws.com",
"website_endpoint": "data.prod.app.integreatconsult.com.s3-website-us-east-1.amazonaws.com"
},
- "sensitive_attributes": []
+ "sensitive_attributes": [],
+ "private": "bnVsbA=="
}
]
},
@@ -725,7 +740,21 @@
"region": "us-east-1",
"replication_configuration": [],
"request_payer": "BucketOwner",
- "server_side_encryption_configuration": [],
+ "server_side_encryption_configuration": [
+ {
+ "rule": [
+ {
+ "apply_server_side_encryption_by_default": [
+ {
+ "kms_master_key_id": "",
+ "sse_algorithm": "AES256"
+ }
+ ],
+ "bucket_key_enabled": false
+ }
+ ]
+ }
+ ],
"tags": {},
"tags_all": {},
"versioning": [
@@ -739,6 +768,7 @@
"website_endpoint": null
},
"sensitive_attributes": [],
+ "private": "bnVsbA==",
"dependencies": [
"data.aws_caller_identity.current"
]
@@ -790,7 +820,21 @@
"region": "us-east-1",
"replication_configuration": [],
"request_payer": "BucketOwner",
- "server_side_encryption_configuration": [],
+ "server_side_encryption_configuration": [
+ {
+ "rule": [
+ {
+ "apply_server_side_encryption_by_default": [
+ {
+ "kms_master_key_id": "",
+ "sse_algorithm": "AES256"
+ }
+ ],
+ "bucket_key_enabled": false
+ }
+ ]
+ }
+ ],
"tags": {},
"tags_all": {},
"versioning": [
@@ -1370,6 +1414,45 @@
}
]
},
+ {
+ "module": "module.export_backup_job",
+ "mode": "managed",
+ "type": "aws_ecs_task_definition",
+ "name": "background_taskdef",
+ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
+ "instances": [
+ {
+ "schema_version": 1,
+ "attributes": {
+ "arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/export_backup_prod:1",
+ "container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod\",\"com.datadoghq.tags.service\":\"export-backup\"},\"environment\":[{\"name\":\"DD_CONTAINER_ENV_AS_TAGS\",\"value\":\"{\\\"INTEGREAT_JOB\\\":\\\"background_job\\\"}\"},{\"name\":\"DD_ENV\",\"value\":\"prod\"},{\"name\":\"DD_SERVICE\",\"value\":\"export-backup\"},{\"name\":\"INTEGREAT_JOB\",\"value\":\"export-backup\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-background-worker.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat:prod\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-background-worker-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]",
+ "cpu": "4096",
+ "ephemeral_storage": [],
+ "execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole",
+ "family": "export_backup_prod",
+ "id": "export_backup_prod",
+ "inference_accelerator": [],
+ "ipc_mode": "",
+ "memory": "8192",
+ "network_mode": "awsvpc",
+ "pid_mode": "",
+ "placement_constraints": [],
+ "proxy_configuration": [],
+ "requires_compatibilities": [
+ "FARGATE"
+ ],
+ "revision": 1,
+ "runtime_platform": [],
+ "tags": null,
+ "tags_all": {},
+ "task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
+ "volume": []
+ },
+ "sensitive_attributes": [],
+ "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ=="
+ }
+ ]
+ },
{
"module": "module.ezcater_upsert_job",
"mode": "managed",
@@ -1801,7 +1884,7 @@
],
"revision": 1,
"runtime_platform": [],
- "tags": null,
+ "tags": {},
"tags_all": {},
"task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
"volume": []
@@ -2828,5 +2911,5 @@
]
}
],
- "check_results": []
+ "check_results": null
}
diff --git a/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup b/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup
index 68a9dcad..13e8f90c 100644
--- a/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup
+++ b/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup
@@ -1,7 +1,7 @@
{
"version": 4,
- "terraform_version": "1.3.2",
- "serial": 343,
+ "terraform_version": "1.3.8",
+ "serial": 406,
"lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51",
"outputs": {
"aws_access_key_id": {
@@ -164,7 +164,7 @@
],
"tags": {},
"tags_all": {},
- "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:413",
+ "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:415",
"timeouts": {
"delete": null
},
@@ -1772,6 +1772,45 @@
}
]
},
+ {
+ "module": "module.load_historical_sales_job",
+ "mode": "managed",
+ "type": "aws_ecs_task_definition",
+ "name": "background_taskdef",
+ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
+ "instances": [
+ {
+ "schema_version": 1,
+ "attributes": {
+ "arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/load_historical_sales_prod:1",
+ "container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod\",\"com.datadoghq.tags.service\":\"load-historical-sales\"},\"environment\":[{\"name\":\"DD_CONTAINER_ENV_AS_TAGS\",\"value\":\"{\\\"INTEGREAT_JOB\\\":\\\"background_job\\\"}\"},{\"name\":\"DD_ENV\",\"value\":\"prod\"},{\"name\":\"DD_SERVICE\",\"value\":\"load-historical-sales\"},{\"name\":\"INTEGREAT_JOB\",\"value\":\"load-historical-sales\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-background-worker.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat:prod\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-background-worker-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]",
+ "cpu": "1024",
+ "ephemeral_storage": [],
+ "execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole",
+ "family": "load_historical_sales_prod",
+ "id": "load_historical_sales_prod",
+ "inference_accelerator": [],
+ "ipc_mode": "",
+ "memory": "4096",
+ "network_mode": "awsvpc",
+ "pid_mode": "",
+ "placement_constraints": [],
+ "proxy_configuration": [],
+ "requires_compatibilities": [
+ "FARGATE"
+ ],
+ "revision": 1,
+ "runtime_platform": [],
+ "tags": null,
+ "tags_all": {},
+ "task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
+ "volume": []
+ },
+ "sensitive_attributes": [],
+ "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ=="
+ }
+ ]
+ },
{
"module": "module.plaid_job",
"mode": "managed",
@@ -2069,7 +2108,7 @@
],
"revision": 1,
"runtime_platform": [],
- "tags": null,
+ "tags": {},
"tags_all": {},
"task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
"volume": []
@@ -2789,5 +2828,5 @@
]
}
],
- "check_results": []
+ "check_results": null
}
diff --git a/test/clj/auto_ap/integration/jobs/ntg.clj b/test/clj/auto_ap/integration/jobs/ntg.clj
new file mode 100644
index 00000000..e98a4288
--- /dev/null
+++ b/test/clj/auto_ap/integration/jobs/ntg.clj
@@ -0,0 +1,58 @@
+(ns auto-ap.integration.jobs.ntg
+ (:require [auto-ap.jobs.ntg :as sut]
+ [auto-ap.integration.util :refer [wrap-setup admin-token setup-test-data test-vendor test-account dissoc-id]]
+ [clojure.test :as t :refer [deftest is testing use-fixtures]]
+ [datomic.api :as d]
+ [clojure.java.io :as io]))
+
+
+(use-fixtures :each wrap-setup)
+
+(deftest extract-invoice-details-cintas
+ (testing "Should parse a single cintas invoice"
+ (let [client {:db/id 1
+ :client/name "NICK THE GREEK"
+ :client/locations ["OP"]
+ :client/matches ["2034 BROADWAY ST"]}]
+ (is (=
+ [{:invoice/invoice-number "1500000592"
+ :invoice/date #inst "2023-03-09T08:00:00-00:00"
+ :invoice/due #inst "2023-04-08T07:00:00-00:00"
+ :invoice/import-status :import-status/imported
+ :invoice/client-identifier "2034 BROADWAY ST"
+ :invoice/location "OP"
+ :invoice/status :invoice-status/unpaid
+ :invoice/vendor :vendor/cintas
+ :invoice/scheduled-payment #inst "2023-04-08T07:00:00-00:00"
+ :invoice/client 1
+ :invoice/total 39.88
+ :invoice/outstanding-balance 39.88
+ }]
+ (map #(dissoc % :invoice/expense-accounts)
+ (sut/extract-invoice-details "ntg-invoices/Cintas/123"
+ (io/input-stream (io/resource "test-cintas/o.zcic.230310093903"))
+ [client]))))))
+
+ (testing "Should disable automatic payment based on feature flag"
+ (let [client {:db/id 1
+ :client/name "NICK THE GREEK"
+ :client/locations ["OP"]
+ :client/matches ["2034 BROADWAY ST"]
+ :client/feature-flags ["manually-pay-cintas"]}]
+ (is (nil? (->> (sut/extract-invoice-details "ntg-invoices/Cintas/123"
+ (io/input-stream (io/resource "test-cintas/o.zcic.230310093903"))
+ [client])
+ first
+ :invoice/scheduled-payment)))))
+
+ (testing "Should not import anything when there isn't an exact match"
+ (let [client {:db/id 1
+ :client/name "NICK THE GREEK"
+ :client/locations ["OP"]
+ :client/matches ["123 time square"]}]
+ (is (=
+ []
+ (sut/extract-invoice-details "ntg-invoices/Cintas/123"
+ (io/input-stream (io/resource "test-cintas/o.zcic.230310093903"))
+ [client]))))))
+
]