-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalLC_GUI.py
More file actions
920 lines (792 loc) ยท 52 KB
/
Copy pathLocalLC_GUI.py
File metadata and controls
920 lines (792 loc) ยท 52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
import streamlit as st
import pandas as pd
import numpy as np
import pickle
import sqlite3
import json
from datetime import datetime
from datetime import timedelta
from typing import TypeVar, Tuple, List, Optional, Dict
from urllib import parse
from bs4 import BeautifulSoup
import ctypes
import shutil
import os
# ํ ๋ชจ๋์์ ์ฌ์ฉ
import subprocess
import time
import psutil
import sys
sys.path.append('C:\\python_source')
import NERP_PI_LC
def run_as_admin():
if ctypes.windll.shell32.IsUserAnAdmin():
return
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
# ๊ธฐ์ค์ ๋ณด
file_path_db = 'C:\\python_source\\LocalLC\\' + 'LocalLC.db'
file_path_json = 'C:\\python_source\\LocalLC\\default_opt.json'
# db๋ณต์ฌ๋ณธ์ ๋ง๋ค๊ณ ์์
file_number = 0
file_path_db_backup = file_path_db.replace('.db',f',{datetime.strftime(datetime.today(),"%Y%m%d")}_{file_number}.db').replace('\\LocalLC\\','\\LocalLC\\db_backup\\')
while True:
if os.path.exists(file_path_db_backup):
file_number = file_number + 1
file_path_db_backup = file_path_db.replace('.db',f',{datetime.strftime(datetime.today(),"%Y%m%d")}_{file_number}.db').replace('\\LocalLC\\','\\LocalLC\\db_backup\\')
else:
shutil.copy(file_path_db, file_path_db_backup)
break
locrct_id = {
'์ ์๋ฌธ์๋ฒํธ':{'main_id':'IssueIdentifier', 'datatype':str},
'์ ์ฉ์ฅ๋ฒํธ':{'main_id':'DocumentReferenceIdentifier', 'datatype':str},
'์ธ๊ธ๊ณ์ฐ์๋ฒํธ':{'main_id':'TaxInvoiceIdentifier', 'datatype':str},
'๋ฐ๊ธ์ผ์':{'main_id':'IssueDate', 'datatype':datetime},
'์ธ์์ผ์':{'main_id':'AcceptanceDate', 'datatype':datetime},
'๊ธ์ก':{'main_id':'AcceptanceAmount','sub_id':['AmountBasisAmount'], 'datatype':float}, # AmountBasisAmount
'ํตํ':{'main_id':'AcceptanceAmount','sub_id':['AmountBasisAmount'], 'class':'currency', 'datatype':str},
'์ฐธ๊ณ ์ฌํญ':{'main_id':'AdditionalConditionsDescriptionText', 'datatype':str}
}
taxinv_id = {
'์ธ๊ธ๊ณ์ฐ์๋ฒํธ':{'main_id':'NTSISSUEID', 'datatype':str},
'๋ฐ๊ธ์ผ์':{'main_id':'TAXDATE', 'datatype':datetime},
'ํตํ':{'main_id':'WAERK_D', 'datatype':str},
'๊ธ์ก':{'main_id':'TOTAMT_D', 'datatype':float},
'๋น๋ง๋ฒํธ':{'main_id':'', 'datatype':str},
'์ ์ฉ์ฅ๋ฒํธ':{'main_id':'', 'datatype':str}
#'๋น๋ง๋ฒํธ':{'main_id':'VBELN', 'datatype':str},
}
locadv_id = {
'์ ์๋ฌธ์๋ฒํธ':{'main_id':'LocalLetterOfCreditApplicationIdentifier', 'datatype':str}, #
'๊ฐ์ค์ํ์ฝ๋':{'main_id':'IssuingBank','sub_id':['Organization','OrganizationIdentifier'], 'datatype':str},
'๊ฐ์ค์ํ':{'main_id':'IssuingBank','sub_id':['Organization','OrganizationName'], 'datatype':str},
'์ ์ฉ์ฅ๋ฒํธ':{'main_id':'LocalLetterOfCreditIdentifier', 'datatype':str}, #
'๊ฐ์ค์๋ขฐ์ธ':{'main_id':'ApplicantParty','sub_id':['Organization','OrganizationName'], 'datatype':str},
'๊ฐ์ค์๋ขฐ์ธ๋ํ๋ช
':{'main_id':'ApplicantParty','sub_id':['Organization','OrganizationCEOName'], 'datatype':str},
'๊ฐ์ค์๋ขฐ์ธ์ฌ์
์๋ฒํธ':{'main_id':'ApplicantParty','sub_id':['Organization','OrganizationIdentifier'], 'datatype':str},
'์์ต์':{'main_id':'BeneficiaryParty','sub_id':['Organization','OrganizationName'], 'datatype':str},
# '์์ต์๋ด๋น์ID':{'main_id':'Contact','sub_id':['ContactEmailAccountText'], 'datatype':str}, # ํน์ ์
์ฒด์์๋ง ์ถ๊ฐ์ ์ผ๋ก ์
๋ ฅํ์ฌ ์ ์ธ
# '์์ต์๋ด๋น์๋๋ฉ์ธ':{'main_id':'Contact','sub_id':['ContactEmailDomainText'], 'datatype':str}, # ํน์ ์
์ฒด์์๋ง ์ถ๊ฐ์ ์ผ๋ก ์
๋ ฅํ์ฌ ์ ์ธ
'๊ฐ์ค์ผ์':{'main_id':'LocalLetterOfCreditIssueDate', 'datatype':datetime}, #
'ํต์ง์ผ์':{'main_id':'NotificationDate', 'datatype':datetime}, #
'๋ฌผํ์ธ๋๊ธฐ์ผ':{'main_id':'DeliveryPromisedDateTime', 'datatype':datetime}, #
'์ ํจ๊ธฐ์ผ':{'main_id':'LocalLetterOfCreditEffectiveDate', 'datatype':datetime}, #
'์๋ฅ์ ์๊ธฐํ':{'main_id':'DocumentPresentationPeriodDate', 'datatype':str}, #
'Partial':{'main_id':'TransportPartialShipmentMethodCode', 'datatype':str}, # 9 ํ์ฉ
'๋ฌผํ๋ช
':{'main_id':'SupplyGoodsDescriptionText', 'datatype':str}, #
'๊ฐ์คํ์ฐจ':{'main_id':'LocalLetterOfCreditOpenDegreeNumber', 'datatype':str}, #
'์ธ์๊ธ์ก':{'main_id':'LocalLetterOfCreditOpenAmount','sub_id':['AmountConvertedAmount'], 'datatype':float}, #
'์ธ์ํตํ':{'main_id':'LocalLetterOfCreditOpenAmount','sub_id':['AmountConvertedAmount'], 'class':'currency', 'datatype':str}, #
'์ ์ถ์๋ฅ':{'main_id':'RequiredDocuments', 'datatype':str, 'show_tag':True}, #
'์ฐธ๊ณ ์ฌํญ':{'main_id':'AdditionalInformationDescriptionText', 'datatype':str} #
}
registeredlc_id = {
'์ ์ฉ์ฅ๋ฒํธ':{'main_id':'wnd[0]/usr/txtZTSDP00130-ZLC_NO', 'sub_id':'text', 'datatype':str},
'ํตํ':{'main_id':'wnd[0]/usr/ctxtZTSDP00130-ZCURR', 'sub_id':'text', 'datatype':str},
'๊ธ์ก':{'main_id':'wnd[0]/usr/txtZTSDP00130-ZOP_AMT', 'sub_id':'text', 'datatype':float},
'์์ก':{'main_id':'wnd[0]/usr/txtZTSDP00130-ZLC_RAMT', 'sub_id':'text', 'datatype':float},
'ApplicantCode':{'main_id':'wnd[0]/usr/ctxtZTSDP00130-ZBUYER', 'sub_id':'text', 'datatype':str},
'PaymentCode':{'main_id':'wnd[0]/usr/ctxtZTSDP00130-ZTERM', 'sub_id':'text', 'datatype':str},
'PaymentText':{'main_id':'wnd[0]/usr/txtZTSDP00130-ZTERM_DESC', 'sub_id':'text', 'datatype':str},
'Incoterms':{'main_id':'wnd[0]/usr/ctxtZTSDP00130-ZINCO', 'sub_id':'text', 'datatype':str},
'๊ฐ์ค์ผ์':{'main_id':'wnd[0]/usr/ctxtZTSDP00130-ZOP_DT', 'sub_id':'text', 'datatype':datetime},
'๋ฌผํ์ธ๋๊ธฐ์ผ':{'main_id':'wnd[0]/usr/ctxtZTSDP00130-ZSP_DT', 'sub_id':'text', 'datatype':datetime},
'์ ํจ๊ธฐ์ผ':{'main_id':'wnd[0]/usr/ctxtZTSDP00130-ZVAL_DT', 'sub_id':'text', 'datatype':datetime},
'Partial':{'main_id':'wnd[0]/usr/chkZTSDP00130-ZPS_TAG', 'sub_id':'selected', 'datatype':str}
}
nego_history_id = {
'๋น๋ง๋ฒํธ':{'main_id':'', 'datatype':str},
'๋ค๊ณ ์ผ์':{'main_id':'', 'datatype':datetime}
}
customer_id = {'์ฌ์
์๋ฒํธ':{'main_id':'', 'datatype':str},
'Name':{'main_id':'', 'datatype':str},
'ApplicantCode':{'main_id':'', 'datatype':str},
'PaymentCode':{'main_id':'', 'datatype':str},
'Incoterms':{'main_id':'','datatype':str},
'์์
๋ด๋น์':{'main_id':'', 'datatype':str},
'์์
๋ด๋น์Knox':{'main_id':'', 'datatype':str} #๋ณ๋ ํฌ๋กค๋งํ๋๊ฒ ์์ด์ ์ฌ๊ธฐ์ ๊ด๋ฆฌ
}
convert_table = {'ReceiptTestimonyCopyNumber':'๋ฌผํ์๋ น์ฆ ์ฌ๋ณธ',
'TaxInvoiceCopyNumber':'์ธ๊ธ๊ณ์ฐ์ ์ฌ๋ณธ',
'LocalLetterOfCreditCopyNumber':'๋ด๊ตญ์ ์ฉ์ฅ ์ฌ๋ณธ',
'OfferSheetCopyNumber':'๋ฌผํ๋งค๋ํ์ฝ์ ์ฌ๋ณธ'
}
def db_open(db_path):
conn_db = sqlite3.connect(db_path)
db_cursor = conn_db.cursor()
return (conn_db, db_cursor)
def db_to_df(conn_db, db_cursor, sql_txt:str)->pd.DataFrame:
query = db_cursor.execute(sql_txt)
cols = [column[0] for column in query.description]
df = pd.DataFrame.from_records(data=query.fetchall(),columns=cols)
conn_db.close()
return df
def write_load_pickle(wr_type, file_path, list_for_pickle=None):
with open(file_path, wr_type) as f:
if 'w' in wr_type:
if list_for_pickle is not None:
pickle.dump(list_for_pickle, f)
else:
raise Exception('Dumpํ list๋ฅผ ํจ์์ ๋ฃ์ด์ฃผ์ธ์')
elif 'r' in wr_type:
return pickle.load(f)
else:
raise Exception('w, wb, r, rb ์ค ํ๋๋ก ์
๋ ฅํ์ธ์')
def write_load_json(wr_type, file_path, list_object=None):
with open(file_path, wr_type, encoding='utf-8') as f:
if 'w' in wr_type:
if list_object is not None:
json.dump(list_object, f, indent=2, ensure_ascii=False)
else:
raise Exception('Dumpํ ๊ฐ์ ํจ์์ ๋ฃ์ด์ฃผ์ธ์')
elif 'r' in wr_type:
return json.load(f, strict=False)
else:
raise Exception('w, wb, r, rb ์ค ํ๋๋ก ์
๋ ฅํ์ธ์')
def exist_lc_ZSDP10200_C(session, lc_no:str)->bool:
session.StartTransaction('ZSDP10200_C')
session.findById("wnd[0]/usr/txtZTSDP00130-ZLC_NO").text = lc_no #"L12G9231000064TEST"
session.findById("wnd[0]").sendVKey (0)
if "cannot be found" in session.findById("wnd[0]/sbar").Text:
session.findById("wnd[0]").sendVKey (3)
return False
else:
session.findById("wnd[0]").sendVKey (3)
return True
def crawl_lc_ZSDP10200_C(session, registeredlc_id, lc_no):
session.StartTransaction('ZSDP10200_C')
session.findById("wnd[0]/usr/txtZTSDP00130-ZLC_NO").text = lc_no #"L12G9231000064TEST"
session.findById("wnd[0]").sendVKey (0)
temp_dict = {}
for column_name in registeredlc_id.keys():
temp_dict[column_name] = session.findById(registeredlc_id[column_name]['main_id'])
if registeredlc_id[column_name]['sub_id'] == 'text':
temp_dict[column_name] = temp_dict[column_name].text
elif registeredlc_id[column_name]['sub_id'] == 'selected':
temp_dict[column_name] = temp_dict[column_name].selected
session.findById("wnd[0]").sendVKey (3)
return temp_dict
def update_nerp_lc(registeredlc_id, input_data)->None:
# ๋ฐ์ดํฐ ์ฝ์
conn_db, db_cursor = db_open(file_path_db)
sql_query = f'''INSERT OR REPLACE INTO ๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ
VALUES (:{', :'.join(registeredlc_id.keys())})
'''
db_cursor.execute(sql_query, (input_data)) # ํํ๋ก ๋ฃ์ด์ผ ์ ์ฅ
conn_db.commit()
conn_db.close()
def check_NegoDueDate(row):
if row['์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ'] is None or row['์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ'] == '์ ์ฉ์ฅ์ ๋ณดX':
lc_expiry = None
else:
lc_expiry = datetime.strptime(row['์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ'],'%Y.%m.%d').date()
if row['์๋ น์ฆ_๋ฐ๊ธ์ผ์'] is None:
receipt_issue_date = None
else:
receipt_issue_date = datetime.strptime(row['์๋ น์ฆ_๋ฐ๊ธ์ผ์'],'%Y-%m-%d').date()
receipt_issue_date_5_workingday = np.busday_offset(np.datetime64(receipt_issue_date, 'D'), 5).astype(datetime)
if lc_expiry is None:
return '์ ์ฉ์ฅ์ ๋ณดX'
elif receipt_issue_date is None: # ์ ์ฉ์ฅ์ ๋ณด๋ ์์ง๋ง ์๋ น์ฆ์ ์์
return lc_expiry
else: # ์ ์ฉ์ฅ์ ๋ณด์ ์๋ น์ฆ์ด ๋ชจ๋ ์์ > ์ ์ฉ์ฅ ์ ํจ
return min(lc_expiry, receipt_issue_date_5_workingday)
def check_progress_localnego(row):
if row['์๋ น์ฆ_๋ฐ๊ธ์ผ์'] is None:
receipt_issue_date = datetime.strptime('1900-01-01','%Y-%m-%d').date()
else:
receipt_issue_date = datetime.strptime(row['์๋ น์ฆ_๋ฐ๊ธ์ผ์'],'%Y-%m-%d').date()
if row['์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ'] == '์ ์ฉ์ฅ์ ๋ณดX':
lc_expiry = datetime.strptime('1900.01.01','%Y.%m.%d').date()
else:
lc_expiry = datetime.strptime(row['์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ'],'%Y.%m.%d').date()
receipt_issue_date_5_workingday = np.busday_offset(np.datetime64(receipt_issue_date, 'D'), 5).astype(datetime)
if row['๋ค๊ณ ์ผ์'] is not None:
return '๋ค๊ณ ์๋ฃ'
if lc_expiry < datetime.today().date(): # 1์์)์ ์ฉ์ฅ ์ ํจ๊ธฐ๊ฐ
return '์ ์ฉ์ฅ ์ ํจ๊ธฐ๊ฐ ๋ง๋ฃ'
elif row['์๋ น์ฆ_๊ณ์ฐ์๋ฒํธ'] is None or row['์๋ น์ฆ_๊ณ์ฐ์๋ฒํธ'] == np.nan: # 2์์)์๋ น์ฆ์ด ์๋ ์ผ์ด์ค
return '์ธ๊ธ๊ณ์ฐ์๊ฐ ๋ฐํ๋์์ผ๋ 10์ผ ์ด๋ด ๋ฌผํ์๋ น์ฆ ๋ฐํ ํ์\n(์ค์๊ธฐ์
์ด ๊ตฌ๋งคํ๋ ๊ฒฝ์ฐ๋ ์์ธ)'
elif receipt_issue_date > datetime.today().date(): # 3์์)์๋ น์ฆ์ด ์๋ ์ผ์ด์ค
return '๋ฌผํ์๋ น์ฆ ๋ ์ง๊ฐ ์ค๋ ์ดํ์ด๋ฏ๋ก ์ฌ๋ฐํ ํ์'
elif receipt_issue_date_5_workingday <= datetime.today().date():
return '๋ฌผํ์๋ น์ฆ ๋ฐ๊ธ์ผ์๋ก๋ถํฐ 5์ผ ๊ฒฝ๊ณผ, ์ฌ๋ฐ๊ธํ์'
else:
return 'Due date์ด๋ด์ ๋ค๊ณ ํ์'
def chk_and_change_df(df_merged_3table:pd.DataFrame)->pd.DataFrame:
for column_name in ['์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ','์ ์ฉ์ฅ_ํตํ']:
df_merged_3table[column_name].fillna(value='์ ์ฉ์ฅ์ ๋ณดX', inplace=True)
df_merged_3table['ํตํChk'] = (df_merged_3table['๊ณ์ฐ์_ํตํ'] == df_merged_3table['์๋ น์ฆ_ํตํ'])
df_merged_3table['๊ธ์กChk'] = (df_merged_3table['๊ณ์ฐ์_๊ธ์ก'] == df_merged_3table['์๋ น์ฆ_๊ธ์ก'])
df_merged_3table['๊ณ์ฐ์Chk'] = df_merged_3table['๊ณ์ฐ์_๊ณ์ฐ์๋ฒํธ'] == df_merged_3table['์๋ น์ฆ_๊ณ์ฐ์๋ฒํธ']
df_merged_3table['์ธ์/๋ฐ๊ธ์ผChk'] = (df_merged_3table['์๋ น์ฆ_์ธ์์ผ์'] == df_merged_3table['๊ณ์ฐ์_๋ฐ๊ธ์ผ์'])
df_merged_3table['NegoDueDate'] = df_merged_3table.apply(check_NegoDueDate, axis=1)
df_merged_3table['์ฐธ๊ณ ์ฌํญ'] = df_merged_3table.apply(check_progress_localnego, axis=1)
df_merged_3table['์๋ น์ฆ๋ฐ๊ธ'] = df_merged_3table['์๋ น์ฆ์ฌ๋ถ'] = np.where(pd.notna(df_merged_3table['์๋ น์ฆ_๊ธ์ก']), True, False)
return df_merged_3table[['์ฐธ๊ณ ์ฌํญ','๋ค๊ณ ์ผ์','NegoDueDate','์๋ น์ฆ๋ฐ๊ธ','๋น๋ง๋ฒํธ','์ ์ฉ์ฅ๋ฒํธ','์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ','์๋ น์ฆ_๋ฐ๊ธ์ผ์', '๊ณ์ฐ์_๋ฐ๊ธ์ผ์', '์๋ น์ฆ_์ธ์์ผ์','์ธ์/๋ฐ๊ธ์ผChk','์ ์ฉ์ฅ_์ ์ ๊ธฐ์ผ','๊ณ์ฐ์_ํตํ','์๋ น์ฆ_ํตํ','ํตํChk','๊ณ์ฐ์_๊ธ์ก','์๋ น์ฆ_๊ธ์ก','๊ธ์กChk','๊ณ์ฐ์_๊ณ์ฐ์๋ฒํธ','์๋ น์ฆ_๊ณ์ฐ์๋ฒํธ','๊ณ์ฐ์Chk','์๋ น์ฆ_์ฐธ๊ณ ์ฌํญ']]
def merge_for_locallc_df(df_locallc:pd.DataFrame, df_joined_taxinv_receipt:pd.DataFrame):
# ์ ์ฉ์ฅ๋ฒํธ ๋ณ ๋ค๊ณ ๊ธ์ก ํฉ๊ณ ๊ตฌํ๊ธฐ
summed_amount = df_joined_taxinv_receipt[df_joined_taxinv_receipt['์ฐธ๊ณ ์ฌํญ']=='๋ค๊ณ ์๋ฃ'].groupby('์ ์ฉ์ฅ๋ฒํธ')['์๋ น์ฆ_๊ธ์ก'].sum()
summed_amount.name = '๋ค๊ณ ์๋ฃ_ํฉ๊ณ'
merged_local_lc = pd.merge(left=df_locallc, right=summed_amount, on='์ ์ฉ์ฅ๋ฒํธ', how='left')
merged_local_lc['๊ฐ์ค๊ธ์ก'] = merged_local_lc['์ธ์๊ธ์ก']
merged_local_lc['๋ค๊ณ ์๋ฃ_ํฉ๊ณ'] = merged_local_lc['๋ค๊ณ ์๋ฃ_ํฉ๊ณ'].replace(np.nan,0)
merged_local_lc['๋ค๊ณ ํ์_ํฉ๊ณ'] = merged_local_lc['๊ฐ์ค๊ธ์ก'].str.replace(',','').astype(float) - merged_local_lc['๋ค๊ณ ์๋ฃ_ํฉ๊ณ']
merged_local_lc['Partial'] = np.where(pd.notna(merged_local_lc['Partial']), False, True)
return merged_local_lc[['๊ฐ์ค๊ธ์ก','๋ค๊ณ ์๋ฃ_ํฉ๊ณ', '๋ค๊ณ ํ์_ํฉ๊ณ','์ ์ฉ์ฅ๋ฒํธ', '์ธ์ํตํ', '์ธ์๊ธ์ก', '์ธ์์์ก', 'ApplicantCode', 'PaymentCode',
'PaymentText', 'Incoterms', '๊ฐ์ค์ผ์', '๋ฌผํ์ธ๋๊ธฐ์ผ', '์ ํจ๊ธฐ์ผ', 'Partial']]
def input_and_search_xml_ZLLEI09020(session, companyid:str, msgid:str, date:list, senderid:str=None)->bool:
'''
sap์์ ๋ฉ๋ด ์กฐ์ํ๊ธฐ์ํด ์ฌ์ฉ
xmltype์ send/receive 2๊ฐ์ง ์
๋ ฅ
๋ ์ง๋ list์์ ์
๋ ฅ ['2023.01.01', '2023.01.31'] or ['2023.01.01']
์กฐํ๊ฒฐ๊ณผ ์์ผ๋ฉด (False, ์๋ฌ๋ฉ์์ง) ๋ฐํ
'''
session.StartTransaction('ZLLEI09020')
session.findById("wnd[0]/usr/radR_ACT_D").select() # Transaction Base
session.findById("wnd[0]/usr/radR_EXW_X").select() # EDI
session.findById("wnd[0]/usr/radP_ACK_LN").select() # Summary
session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").text = companyid # "C100"
session.findById("wnd[0]/usr/ctxtS_MSGID-LOW").text = msgid #"LOCRCT"
# session.findById("wnd[0]/usr/txtS_RID-LOW").text = searchid # RECEIVER ID
if senderid is not None:
session.findById("wnd[0]/usr/txtS_SID-LOW").text = senderid # SENDER ID
# ๋ ์ง์
๋ ฅ
if type(date) == str: date_start, date_end = date, date
elif type(date) == list:
if len(date) == 1: date_start, date_end = date[0], date[0]
elif len(date) == 2: date_start, date_end = date[0], date[1]
else: raise ValueError('๋ ์ง๋ []์์ 1๊ฐ ๋๋ 2๊ฐ ์
๋ ฅํ์')
session.findById("wnd[0]/usr/ctxtSO_AEDAT-LOW").text = date_start
session.findById("wnd[0]/usr/ctxtSO_AEDAT-HIGH").text = date_end
session.findById("wnd[0]").sendVKey(8)
# ์กฐํ๊ฒฐ๊ณผ ์์ผ๋ฉด ์ข
๋ฃ
if 'Message' in session.findById("wnd[0]/sbar").Text: # == 'Message=>Data not found':
return False#, session.findById("wnd[0]/sbar").Text)
elif 'limit is greater' in session.findById("wnd[0]/sbar").Text:
return False#, session.findById("wnd[0]/sbar").Text)
elif 'Invalid date' in session.findById("wnd[0]/sbar").Text:
return False#, session.findById("wnd[0]/sbar").Text)
# ์กฐํ ๊ฒฐ๊ณผ์์ NORMAL๊ฑด ํด๋ฆญํ์ฌ ์ง์
session.findById("wnd[0]/usr/shell/shellcont[1]/shell").currentCellColumn = "NORMAL"
session.findById("wnd[0]/usr/shell/shellcont[1]/shell").selectedRows = "0"
session.findById("wnd[0]/usr/shell/shellcont[1]/shell").doubleClickCurrentCell()
return True
def loop_get_xml_ZLLEI09020(session, id_list:dict, db_table_name:str, convert_table:dict=None)->bool:
'''
์กฐํ๊น์ง ์๋ฃ๋ ์ํ์์ ์คํ, ์ ์ฒด xml์ ์กฐํํ๊ณ dataframe์ผ๋ก ๋ฐํ
'''
for i in range(session.findById("wnd[0]/usr/shell/shellcont[1]/shell").RowCount):
session.findById("wnd[0]/usr/shell/shellcont[1]/shell").selectedRows = i
session.findById("wnd[0]/tbar[1]/btn[5]").press()
# ์กฐํ๊ฒฐ๊ณผ ์์ผ๋ฉด ์ข
๋ฃ
if 'Message' in session.findById("wnd[0]/sbar").Text: # == 'Message=>Data not found
print(f'(์กฐํ๋ถ๊ฐ)', session.findById("wnd[0]/sbar").Text )
return False
# xmlํ์ผ๊ฒฝ๋ก ํ์ธ ๋ฐ ๋ณํ
file_path = session.findById("wnd[0]/usr/cntlGUI_CONTAINER_X/shellcont/shell").BrowserHandle.LocationURL
for (before, after) in (('file:///', ''), ('/', '\\'), ('\\', '\\\\')):
file_path = file_path.replace(before, after)
file_path = parse.unquote(file_path)
# xml ์ฝ๊ณ ํ์ฑ
with open(file_path, 'r', encoding='utf-8') as f:
xml = f.read()
soup = BeautifulSoup(xml, 'xml')
temp_row = {}
for key, tags in id_list.items():
temp_txt = ''
if len(tags) == 2: # main_id๋ง ์์
parsed_txt = soup.findAll(tags['main_id'])
if len(parsed_txt) == 1:
temp_txt = soup.find(tags['main_id']).text
else:
for _ in range(len(parsed_txt)):
temp_txt += parsed_txt[_].text + ' '
elif 'show_tag' in tags.keys():
for _ in soup.find(tags['main_id']).findAll():
temp_txt += f'{_.name}({_.text})' + ' '
elif 'sub_id' in tags.keys() and 'class' not in tags.keys():
element_souped = soup.find(tags['main_id'])
for each_id in tags['sub_id']:
element_souped = element_souped.find(each_id)
temp_txt = element_souped.text
# temp_txt = soup.find(tags['main_id']).find(tags['sub_id']).text
elif 'sub_id' in tags.keys() and 'class' in tags.keys():
temp_txt = soup.find(tags['main_id']).find(tags['sub_id'])[tags['class']]
temp_row[key] = temp_txt
# ํ์ฑ๋ ๋ฐ์ดํฐ ํ์
๋ณํ
for key in temp_row:
if type(temp_row[key]) == id_list[key]['datatype']:
continue
if id_list[key]['datatype'] == str:
temp_row[key] = str(temp_row[key])
elif id_list[key]['datatype'] == float: # ์ง์ ํ๊ณ ์ ํ๋ ํ์
์ด float์ผ๋
temp_row[key] = float(temp_row[key])
elif id_list[key]['datatype'] == datetime:
temp_row[key] = datetime.strptime(temp_row[key],'%y%m%d').date()
# ํ์ฑ๋ ๋ฐ์ดํฐ ๋ด์ฉ๋ณํ
if convert_table is not None:
for name, value in convert_table.items():
for key in temp_row:
if type(temp_row[key]) == str:
temp_row[key] = temp_row[key].replace(name, value)
# ๋ฐ์ดํฐ ์ฝ์
conn_db, db_cursor = db_open(file_path_db)
sql_query = f'''INSERT OR REPLACE INTO {db_table_name}
VALUES (:{', :'.join(id_list.keys())})
'''
db_cursor.execute(sql_query, temp_row)
conn_db.commit()
conn_db.close()
session.findById("wnd[0]").sendVKey(3)
def open_nerp_session():
dict_default_opt = write_load_json('r',file_path_json)
sap_option = dict_default_opt['sap_option']
sap_option[3] = int(sap_option[3])
try:
sessions = NERP_PI_LC.check_and_open_sap(*sap_option)
session = sessions[sap_option[3]-1] # sessions[0]
except:
run_as_admin()
sessions = NERP_PI_LC.check_and_open_sap(*sap_option)
session = sessions[sap_option[3]-1]
return session
def first_and_end_of_month(year, month)->datetime:
base_date = datetime.strptime(str(year)+str(month),'%Y%m').date()
first_day = base_date.replace(day=1)
next_first_day = (first_day + timedelta(32)).replace(day=1)
last_day = next_first_day - timedelta(1)
return (first_day, last_day)
def input_and_search_taxinv_ZRSDM62110(session, payer_list:list, date:str, salesorg:str )->bool:
'''
sap์์ ๋ฉ๋ด ์กฐ์ํ๊ธฐ์ํด ์ฌ์ฉ
payer_list: ๋ฆฌ์คํธํ์ PayerCode๋ฅผ ์
๋ ฅ
date : YYYYMM ํ์ (202311)
์กฐํ๊ฒฐ๊ณผ ์์ผ๋ฉด (False, ์๋ฌ๋ฉ์์ง) ๋ฐํ
'''
session.StartTransaction('ZRSDM62110')
session.findById("wnd[0]/usr/ctxtPA_YYMM").text = date #202308
session.findById("wnd[0]/usr/ctxtPA_VKORG").text = salesorg # R001
session.findById("wnd[0]/usr/btn%_SO_KUNNR_%_APP_%-VALU_PUSH").press()
session.findById("wnd[1]/tbar[0]/btn[16]").press()
pd.DataFrame(data={'9999999':payer_list}).to_clipboard(index=False)
session.findById("wnd[1]/tbar[0]/btn[24]").press()
session.findById("wnd[1]").sendVKey (8)
session.findById("wnd[0]").sendVKey (8)
# ์กฐํ๊ฒฐ๊ณผ ์์ผ๋ฉด ์ข
๋ฃ
if 'No data' in session.findById("wnd[0]/sbar").Text: # No data found. Please check your Input data again
return False#, session.findById("wnd[0]/sbar").Text)
elif ' Fill out' in session.findById("wnd[0]/sbar").Text: # Fill out all required entry fields
return False#, session.findById("wnd[0]/sbar").Text)
else:
return True
def loop_get_taxinv_ZRSDM62110(session, taxinv_id:dict, cursorandcon)->None:
temp_row_taxinv = {}
for result_row in range(session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").RowCount):
# ํ ์ ํ ํ Billing ์ง์
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = str(result_row)
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").currentCellRow = str(result_row)
session.findById("wnd[0]/tbar[1]/btn[14]").press() # Billing list Disp๋ฒํผ
if 'No item has been selected' in session.findById("wnd[0]/sbar").Text: # No item has been selected
continue
elif 'items have been found' in session.findById("wnd[0]/sbar").Text:
#temp_row_taxinv['๋น๋ง๋ฒํธ'] = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").getCellValue(0, taxinv_id['๋น๋ง๋ฒํธ']['main_id']) # Billing No
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").currentCellColumn = "VBELN"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").clickCurrentCell()
session.findById("wnd[0]/tbar[1]/btn[16]").press()
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/tbar[0]/btn[2]").press()
session.findById("wnd[0]/usr/cntlCTRL_CONTAINERBSEG/shellcont/shell").currentCellColumn = "SGTXT"
session.findById("wnd[0]/usr/cntlCTRL_CONTAINERBSEG/shellcont/shell").doubleClickCurrentCell()
temp_row_taxinv['๋น๋ง๋ฒํธ'] = session.findById("wnd[0]/usr/txtBSEG-ZUONR").text
temp_row_taxinv['์ ์ฉ์ฅ๋ฒํธ'] = session.findById("wnd[0]/usr/ctxtBSEG-SGTXT").text
session.findById("wnd[0]").sendVKey(3)
session.findById("wnd[0]").sendVKey(3)
session.findById("wnd[1]").close()
session.findById("wnd[0]").sendVKey(3)
session.findById("wnd[0]").sendVKey (3)
# ์ ์์ง์
์ด ๋ ์ผ์ด์ค๋ผ๋ฉด ๋ฐ์ดํฐ ์์ง(์๋์๋ค๋ฉด Total ๋๋ Sub Total ํ์ผ๋ก Skipํ๋ค)
temp_row_taxinv['์ธ๊ธ๊ณ์ฐ์๋ฒํธ'] = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").getCellValue(result_row, taxinv_id['์ธ๊ธ๊ณ์ฐ์๋ฒํธ']['main_id'])# ์ธ๊ธ๊ณ์ฐ์ ๋ฒํธ
temp_row_taxinv['๋ฐ๊ธ์ผ์'] = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").getCellValue(result_row, taxinv_id['๋ฐ๊ธ์ผ์']['main_id']) # ์ธ๊ธ๊ณ์ฐ์ ๋ฐํ์ผ์
temp_row_taxinv['ํตํ'] = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").getCellValue(result_row,taxinv_id['ํตํ']['main_id']) # ํตํ์ข
๋ฅ
temp_row_taxinv['๊ธ์ก'] = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").getCellValue(result_row,taxinv_id['๊ธ์ก']['main_id']) # ๋ฐํ๊ธ์ก
# ํ์ฑ๋ ๋ฐ์ดํฐ ๋ณํ
for key in temp_row_taxinv:
if type(temp_row_taxinv[key]) == taxinv_id[key]['datatype']:
continue
if taxinv_id[key]['datatype'] == str:
temp_row_taxinv[key] = str(temp_row_taxinv[key])
elif taxinv_id[key]['datatype'] == float:
temp_row_taxinv[key] = float(temp_row_taxinv[key].replace(",",""))
elif taxinv_id[key]['datatype'] == datetime:
temp_row_taxinv[key] = datetime.strptime(temp_row_taxinv[key],'%Y.%m.%d').date()
# ๋ฐ์ดํฐ ์ฝ์
conn_db, db_cursor = cursorandcon
sql_query = f'''INSERT OR REPLACE INTO ์ธ๊ธ๊ณ์ฐ์
VALUES (:{', :'.join(taxinv_id.keys())})
'''
try:
db_cursor.execute(sql_query, temp_row_taxinv)
except:
conn_db, db_cursor = db_open(file_path_db)
db_cursor.execute(sql_query, temp_row_taxinv)
conn_db.commit()
conn_db.close()
def register_localLC(dict_locallc:dict)->None:
#T์ฝ๋์ง์
session.StartTransaction('ZSDP10200_A')
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZLCORG").Text = "1"
session.FindbyId("wnd[0]").sendVKey(0)
session.FindbyId("wnd[0]/usr/radLLCMARK_03").Select()
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZBUYER").Text = dict_locallc['ApplicantCode'] #"1157966"
session.FindbyId("wnd[0]/usr/txtZTSDP00130-ZLC_NO").Text = dict_locallc['์ ์ฉ์ฅ๋ฒํธ']#"L12G9230500089"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-LCOUNTRY").Text = dict_locallc['POL(5์๋ฆฌ)'][:2]#"KR"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-POL").Text = dict_locallc['POL(5์๋ฆฌ)'][2:]#"ICN"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-COUNTRY").Text = dict_locallc['POD(5์๋ฆฌ)'][:2]#"KR"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-FINDEST").Text = dict_locallc['POD(5์๋ฆฌ)'][2:]#"PUS"
session.FindbyId("wnd[0]").sendVKey(0)
session.FindbyId("wnd[0]/usr/txtZTSDP00140-SALESMAN").Text = dict_locallc['์์
๋ด๋น์']#"์ ์๊ฒฝP"
session.FindbyId("wnd[0]/usr/txtZTSDP00140-MAIL_ID").Text = dict_locallc['์์
๋ด๋น์Knox']#"ekdms.jeong"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZCURR").Text = dict_locallc['์ธ์ํตํ']#"USD"
session.FindbyId("wnd[0]/usr/txtZTSDP00130-ZOP_AMT").Text = dict_locallc['์ธ์๊ธ์ก']#"293625"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZTERM").Text = dict_locallc['PaymentCode']#"CD96"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZINCO").Text = dict_locallc['Incoterms']#"FOB"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZOP_DT").Text = dict_locallc['๊ฐ์ค์ผ์'].replace('-','.')#"2023.05.30"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZSP_DT").Text = dict_locallc['๋ฌผํ์ธ๋๊ธฐ์ผ'].replace('-','.')#"2023.06.30"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00130-ZVAL_DT").Text = dict_locallc['์ ํจ๊ธฐ์ผ'].replace('-','.')#"2023.06.30"
session.findById("wnd[0]/usr/chkZTSDP00130-ZPS_TAG").Selected = dict_locallc['Partial']
session.FindbyId("wnd[0]").sendVKey(0)
session.FindbyId("wnd[0]").sendVKey(11)
session.FindbyId("wnd[1]/usr/btnSPOP-OPTION1").press()
session.FindbyId("wnd[1]/tbar[0]/btn[0]").press()#์ฒดํฌ๋ฐ์ค ํด๋ฆญ
session.FindbyId("wnd[1]/usr/btnSPOP-OPTION2").press()#CREATE ITEM NO
applicant_name = session.FindbyId("wnd[0]/usr/txtZTSDP00200-ZBUY_NM1").Text
session.FindbyId("wnd[0]/usr/txtZTSDP00200-ZNOTI1").Text = applicant_name
session.FindbyId("wnd[0]/usr/txtZTSDP00200-ZCONS1").Text = applicant_name
session.FindbyId("wnd[0]").sendVKey (11)
session.FindbyId("wnd[1]/usr/btnSPOP-OPTION1").press() #SAVE YES
#์
๋ ฅํ ํฌํธ ๊ฐฏ์๋ฐ๋ผ ๋ฐ์
if len(dict_locallc['POL2(5์๋ฆฌ)'])!=5 or len(dict_locallc['POD2(5์๋ฆฌ)'])!=5:
session.FindbyId("wnd[1]/usr/btnSPOP-OPTION2").press() #ADDITIONAL PORT NO
else:
session.FindbyId("wnd[1]/usr/btnSPOP-OPTION1").press() #ADDITIONAL PORT YES
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-LCOUNTRY").Text = dict_locallc['POL2(5์๋ฆฌ)'][:2]#"KR"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-POL").Text = dict_locallc['POL2(5์๋ฆฌ)'][2:]#"ICN"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-COUNTRY").Text = dict_locallc['POD2(5์๋ฆฌ)'][:2] #"KR"
session.FindbyId("wnd[0]/usr/ctxtZTSDP00200-FINDEST").Text = dict_locallc['POD2(5์๋ฆฌ)'][2:] #'ICN
session.FindbyId("wnd[0]").sendVKey(11) #SAVE
session.FindbyId("wnd[1]/usr/btnSPOP-OPTION1").press() #SAVE YES
#dict_default_opt = write_load_pickle(wr_type ='w', file_path_db+'default_option.pickle', list_for_pickle=None)
df_receipt = db_to_df(*db_open(file_path_db), 'SELECT * FROM ๋ฌผํ์๋ น์ฆ')
df_taxinv = db_to_df(*db_open(file_path_db), 'SELECT * FROM ์ธ๊ธ๊ณ์ฐ์')
df_locallc = db_to_df(*db_open(file_path_db), 'SELECT * FROM ๋ด๊ตญ์ ์ฉ์ฅ')
df_nerplc = db_to_df(*db_open(file_path_db), 'SELECT * FROM ๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ')
df_customer_info = db_to_df(*db_open(file_path_db), 'SELECT * FROM ๊ฑฐ๋์ ์ ๋ณด')
df_joined_taxinv_receipt = chk_and_change_df(db_to_df(*db_open(file_path_db), '''
SELECT
๋ฌผํ์๋ น์ฆ.์ธ๊ธ๊ณ์ฐ์๋ฒํธ as ์๋ น์ฆ_๊ณ์ฐ์๋ฒํธ,
๋ฌผํ์๋ น์ฆ.๋ฐ๊ธ์ผ์ as ์๋ น์ฆ_๋ฐ๊ธ์ผ์,
๋ฌผํ์๋ น์ฆ.์ธ์์ผ์ as ์๋ น์ฆ_์ธ์์ผ์,
๋ฌผํ์๋ น์ฆ.ํตํ as ์๋ น์ฆ_ํตํ,
๋ฌผํ์๋ น์ฆ.๊ธ์ก as ์๋ น์ฆ_๊ธ์ก,
๋ฌผํ์๋ น์ฆ.์ฐธ๊ณ ์ฌํญ as ์๋ น์ฆ_์ฐธ๊ณ ์ฌํญ,
์ธ๊ธ๊ณ์ฐ์.์ ์ฉ์ฅ๋ฒํธ as ์ ์ฉ์ฅ๋ฒํธ,
์ธ๊ธ๊ณ์ฐ์.์ธ๊ธ๊ณ์ฐ์๋ฒํธ as ๊ณ์ฐ์_๊ณ์ฐ์๋ฒํธ,
์ธ๊ธ๊ณ์ฐ์.๋ฐ๊ธ์ผ์ as ๊ณ์ฐ์_๋ฐ๊ธ์ผ์,
์ธ๊ธ๊ณ์ฐ์.ํตํ as ๊ณ์ฐ์_ํตํ,
์ธ๊ธ๊ณ์ฐ์.๊ธ์ก as ๊ณ์ฐ์_๊ธ์ก,
์ธ๊ธ๊ณ์ฐ์.๋น๋ง๋ฒํธ as ๋น๋ง๋ฒํธ,
๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ.์ธ์ํตํ as ์ ์ฉ์ฅ_ํตํ,
๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ.๋ฌผํ์ธ๋๊ธฐ์ผ as ์ ์ฉ์ฅ_์ ์ ๊ธฐ์ผ,
๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ.์ ํจ๊ธฐ์ผ as ์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ,
๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ.Partial as ์ ์ฉ์ฅ_๋ถํ ์ ์ ,
๋น๋ง๋ฒํธ๋ณ๋ค๊ณ ์ผ์.๋ค๊ณ ์ผ์ as ๋ค๊ณ ์ผ์
FROM
์ธ๊ธ๊ณ์ฐ์ AS ์ธ๊ธ๊ณ์ฐ์
LEFT JOIN (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY ์ธ๊ธ๊ณ์ฐ์๋ฒํธ ORDER BY ์ ์๋ฌธ์๋ฒํธ DESC) AS rn
FROM ๋ฌผํ์๋ น์ฆ
) AS ๋ฌผํ์๋ น์ฆ ON ์ธ๊ธ๊ณ์ฐ์.์ธ๊ธ๊ณ์ฐ์๋ฒํธ = ๋ฌผํ์๋ น์ฆ.์ธ๊ธ๊ณ์ฐ์๋ฒํธ AND ๋ฌผํ์๋ น์ฆ.rn = 1
LEFT JOIN
๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ AS ๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ ON ์ธ๊ธ๊ณ์ฐ์.์ ์ฉ์ฅ๋ฒํธ = ๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ.์ ์ฉ์ฅ๋ฒํธ
LEFT JOIN
๋น๋ง๋ฒํธ๋ณ๋ค๊ณ ์ผ์ AS ๋น๋ง๋ฒํธ๋ณ๋ค๊ณ ์ผ์ ON ์ธ๊ธ๊ณ์ฐ์.๋น๋ง๋ฒํธ = ๋น๋ง๋ฒํธ๋ณ๋ค๊ณ ์ผ์.๋น๋ง๋ฒํธ
'''))
df_joined_local_negoamount = merge_for_locallc_df(df_nerplc, df_joined_taxinv_receipt)
dict_default_opt = write_load_json('r',file_path_json)
st.set_page_config(layout="wide")
tab1, tab2, tab3, tab4, tab5, tab6, tab7 = st.tabs(["L/C๋ฑ๋ก(NERP)", "L/Cํํฉ", '์ธ๊ธ๊ณ์ฐ์/๋ฌผํ์๋ น์ฆ','์ต์
์ค์ ','์ธ๊ธ๊ณ์ฐ์ ๋ด์ญ์ญ์ ','๋ฌผํ์๋ น์ฆ ๋ด์ญ์ญ์ ','์ฐธ๊ณ ์ฌํญ'],)
with tab1:
tab1_col1, tab1_col2, tab1_col3 = st.columns([3, 0.3, 6])
with tab1_col1 : # ํ๋ฉด ์ข์ธก
st.title('Local L/C ๋ฑ๋ก')
locadv_no = st.text_input(label="์ ์๋ฌธ์๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์", value='', max_chars=30, help='30์๋ฆฌ ํ
์คํธ๋ง ์
๋ ฅ๊ฐ๋ฅ')#, autocomplete='on')
df_locallc_for_register = df_locallc[df_locallc['์ ์๋ฌธ์๋ฒํธ'].str.contains(locadv_no)]
tab1_col1_col1, tab1_col1_col2 = st.columns([5,5])
temp_dict_for_register = {}
with tab1_col1_col1:
if locadv_no != '':
column_to_not_show = ['์ ์๋ฌธ์๋ฒํธ','๊ฐ์ค์ํ์ฝ๋','๊ฐ์ค์ํ','๊ฐ์ค์๋ขฐ์ธ๋ํ๋ช
','์์ต์','์์ต์๋ด๋น์๋๋ฉ์ธ','์ฐธ๊ณ ์ฌํญ','','']
for column_name in df_locallc_for_register.columns:
# db์ ์๋ ์ ๋ณด ์ฌ์ฉ
if column_name not in column_to_not_show:
temp_dict_for_register[column_name] = st.text_input(label=column_name, value=df_locallc_for_register[column_name].values[0])
with tab1_col1_col2:
if locadv_no != '':
df_customer = df_customer_info[df_customer_info['์ฌ์
์๋ฒํธ']==temp_dict_for_register['๊ฐ์ค์๋ขฐ์ธ์ฌ์
์๋ฒํธ']]
column_not_in_db = ['ApplicantCode', 'PaymentCode', 'Incoterms', 'POL(5์๋ฆฌ)','POD(5์๋ฆฌ)', 'POL2(5์๋ฆฌ)','POD2(5์๋ฆฌ)','์์
๋ด๋น์','์์
๋ด๋น์Knox']
for column_add in column_not_in_db:
# db์ ์๋ ์ ๋ณด ์ฌ์ฉ1
if column_add in ['ApplicantCode', 'PaymentCode', 'Incoterms','์์
๋ด๋น์','์์
๋ด๋น์Knox']:
value_box = df_customer[column_add].item()
else:
value_box = ''
temp_dict_for_register[column_add] = st.text_input(label=column_add, value=value_box)
# #db์ ์๋ ์ ๋ณด ์ฌ์ฉ2(ํ์ํ ํ์์์ด ๋ถ๋ฌ์ค๊ธฐ๋ง ํ๋ฉด ๋๋ ๊ฐ)
# temp_dict_for_register['์์
๋ด๋น์'] = df_customer['์์
๋ด๋น์'].item()
# temp_dict_for_register['์์
๋ด๋น์Knox'] = df_customer['์์
๋ด๋น์Knox'].item()
# print(temp_dict_for_register['์์
๋ด๋น์'], temp_dict_for_register['์์
๋ด๋น์Knox'])
with tab1_col2:
if st.button('๐๋ฑ๋ก',): # NERP๋ฅผ ์ผ ํ ๋ฑ๋ก์์
์ํ
if locadv_no != '':
# pi_name_and_applicantcode = [temp_dict_for_register['์ ์ฉ์ฅ๋ฒํธ'],temp_dict_for_register['ApplicantCode']]
# pi_dates = [temp_dict_for_register['๊ฐ์ค์ผ์'],temp_dict_for_register['๋ฌผํ์ธ๋๊ธฐ์ผ'],temp_dict_for_register['์ ํจ๊ธฐ์ผ']]
# partial = False if temp_dict_for_register['Partial'] == '9' else True
# pi_cur_value_payment_inco_incotext_part_trans = [temp_dict_for_register['์ธ์ํตํ'],temp_dict_for_register['์ธ์๊ธ์ก'],
# temp_dict_for_register['PaymentCode'],
# temp_dict_for_register['Incoterms'],'',partial, False] # Tranship์์ผ๋ฏ๋ก ํญ์ True\
temp_dict_for_register['Partial'] = False if temp_dict_for_register['Partial'] == '9' else True
pi_port_and_addr = []
proceed_register = True
for i, each_port in enumerate([['POL(5์๋ฆฌ)','POD(5์๋ฆฌ)'], ['POL2(5์๋ฆฌ)','POD2(5์๋ฆฌ)']]):
print()
print(i, temp_dict_for_register[each_port[0]], temp_dict_for_register[each_port[1]])
print()
if len(temp_dict_for_register[each_port[0]])!=5 or len(temp_dict_for_register[each_port[1]]) != 5:
if i == 0:
st.toast('ํฌํธ์ฝ๋๋ฅผ ์
๋ ฅ!\n(์ฒซ๋ฒ์งธ POL/POD ํ์, ๊ฐ 5์๋ฆฌ)')
proceed_register = False
break
else:
break
if proceed_register:
session = open_nerp_session()
register_localLC(temp_dict_for_register)
with tab1_col3:
st.title('Local L/C ์์ ๋ด์ญ')
tab1_col3_col1, tab1_col3_col2, tab1_col3_col3, tab1_col3_col4, tab1_col3_col5 = st.columns([6,1,2,2,1.7])
with tab1_col3_col1:
text_box_searchlc = st.text_input(label="๊ฒ์ํ L/C๋ฒํธ๋ฅผ ์
๋ ฅํ๊ณ Enter", value='', max_chars=30, help='30์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')#, autocomplete='on')
with tab1_col3_col2:
pass
with tab1_col3_col3:
# month_to_update_edi = st.date_input("๊ธฐ์ค์ผ์(ํด๋น์ผ์์ ์ฐ/์๋ก ์
๋ฐ์ดํธ)",format='YYYY-MM-DD', value=datetime.strptime('1900-01-01','%Y-%m-%d').date())
year_to_update_edi = st.text_input(label="์ฐ(YYYY)", value=str(datetime.today().year), max_chars=4, help='4์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')
with tab1_col3_col4:
month_to_update_edi = st.text_input(label="์(MM)", value=str(datetime.today().month), max_chars=2, help='2์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')
with tab1_col3_col5:
if st.button('์
๋ ฅํ ์ฐ/์๋ก โ์
๋ฐ์ดํธ',):
session = open_nerp_session()
first_day, last_day = first_and_end_of_month(year_to_update_edi, month_to_update_edi)
date = [[datetime.strftime(first_day,'%Y.%m.%d'),datetime.strftime(last_day,'%Y.%m.%d')]]
for each_date in date:
if input_and_search_xml_ZLLEI09020(session, companyid='C100', msgid='LOCADV', date=each_date):
loop_get_xml_ZLLEI09020(session, id_list=locadv_id, db_table_name='๋ด๊ตญ์ ์ฉ์ฅ', convert_table=convert_table)
if text_box_searchlc or text_box_searchlc == '':
df_locallc['Partial'] = df_locallc['Partial'].str.replace('9','ํ์ฉ')
df_locallc_viewer = df_locallc[df_locallc['์ ์ฉ์ฅ๋ฒํธ'].str.contains(text_box_searchlc)]
st.dataframe(df_locallc_viewer, width=1500, hide_index=True)
with tab2:
tab2_col1, tab2_col2 = st.columns([8,1.38])
with tab2_col1:
st.title('NERP Local L/C ๋ฑ๋ก๋ด์ญ')
tab2_col1_col1, tab2_col1_col2 = st.columns([2,8])
with tab2_col1_col1:
filter_df_joined_local_negoamount = st.selectbox('์ ์ฒด/์์กO ๋ณด๊ธฐ', ['์ ์ฒด', '์์กO'])
with tab2_col1_col2:
text_box_searchNERPlc = st.text_input(label="๊ฒ์ํ L/C๋ฒํธ๋ฅผ ์
๋ ฅํ๊ณ Enter ", value='', max_chars=30, help='30์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')#, autocomplete='on')
if text_box_searchNERPlc or text_box_searchNERPlc == '':
df_nerplc_viewer = df_joined_local_negoamount[df_joined_local_negoamount['์ ์ฉ์ฅ๋ฒํธ'].str.contains(text_box_searchNERPlc)].sort_values('์ ํจ๊ธฐ์ผ')
if filter_df_joined_local_negoamount == '์์กO':
df_nerplc_viewer = df_nerplc_viewer[df_nerplc_viewer['๋ค๊ณ ํ์_ํฉ๊ณ']>0]
st.dataframe(df_nerplc_viewer, width=1500, hide_index=True)
with tab2_col2:
st.title('์๋Update')
text_box_lc = st.text_input(label="์ถ๊ฐํ L/C๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์", value='', max_chars=30, help='30์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')#, autocomplete='on')
if st.button('์
๋ ฅํ Local L/C ์ถ๊ฐ/์
๋ฐ์ดํธ'):
session = open_nerp_session()
if exist_lc_ZSDP10200_C(session,text_box_lc):
input_data = crawl_lc_ZSDP10200_C(session, registeredlc_id, text_box_lc)
update_nerp_lc(registeredlc_id, input_data)
if st.button('Local L/C EDI ์์ ๋ด์ญ์ผ๋ก \n๋ถ๋ฌ์ค๊ธฐ'):
session = open_nerp_session()
need_chk_all = set(db_to_df(*db_open(file_path_db), 'SELECT * FROM ๋ด๊ตญ์ ์ฉ์ฅ')['์ ์ฉ์ฅ๋ฒํธ'].tolist())
need_not_chk = set(db_to_df(*db_open(file_path_db), 'SELECT * FROM ๋ด๊ตญ์ ์ฉ์ฅ๋ฑ๋ก๋ด์ญ')['์ ์ฉ์ฅ๋ฒํธ'].tolist())
need_chk_final =need_chk_all - need_not_chk
for lc in need_chk_final:
if exist_lc_ZSDP10200_C(session,lc):
input_data = crawl_lc_ZSDP10200_C(session, registeredlc_id, lc)
update_nerp_lc(registeredlc_id, input_data)
if st.button('์๋ก๊ณ ์นจ'):
pass
with tab3:
tab3_col1, tab3_col2 = st.columns([8,1.38])
with tab3_col1:
st.title('์ธ๊ธ๊ณ์ฐ์/๋ฌผํ์๋ น์ฆ')
tab3_col1_col1, tab3_col1_col2, tab3_col1_col3, tab3_col1_col4, tab3_col1_col5, tab3_col1_col6 = st.columns([6,1,2,2,1.5,1.5])
with tab3_col1_col1:
text_box_search_taxinv = st.text_input(label="๊ฒ์ํ ์ธ๊ธ๊ณ์ฐ์๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์", value='', max_chars=30, help='30์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')#, autocomplete='on')
if text_box_search_taxinv or text_box_search_taxinv == '':
df_taxinv_viewer = df_joined_taxinv_receipt[df_taxinv['์ธ๊ธ๊ณ์ฐ์๋ฒํธ'].str.contains(text_box_search_taxinv)]
with tab3_col1_col3:
year_to_update_tax_receipt = st.text_input(label="์ฐ(YYYY) ", value=str(datetime.today().year), max_chars=4, help='4์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')
with tab3_col1_col4:
month_to_update_tax_receipt = st.text_input(label="์(MM) ", value=str(datetime.today().month), max_chars=2, help='2์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')
if len(month_to_update_tax_receipt) == 1:
month_to_update_tax_receipt = '0' + month_to_update_tax_receipt
with tab3_col1_col5:
if st.button('์
๋ ฅํ ์ฐ/์๋ก ์ธ๊ธ๊ณ์ฐ์'):
date = [year_to_update_tax_receipt + month_to_update_tax_receipt]
#payer_list = [info["ApplicantCode"] for info in dict_default_opt["applicant_info"].values()]
payer_list = df_customer_info['ApplicantCode'].tolist()
session = open_nerp_session()
for each_date in date:
if input_and_search_taxinv_ZRSDM62110(session, payer_list=payer_list, date=each_date, salesorg='R001'):
loop_get_taxinv_ZRSDM62110(session, taxinv_id, db_open(file_path_db))
with tab3_col1_col6:
if st.button('์
๋ ฅํ ์ฐ/์๋ก ๋ฌผํ์๋ น์ฆ',):
first_day, last_day = first_and_end_of_month(year_to_update_tax_receipt, month_to_update_tax_receipt)
date = [[datetime.strftime(first_day,'%Y.%m.%d'),datetime.strftime(last_day,'%Y.%m.%d')]]
session = open_nerp_session()
senderid_dict = {'1157966':'PNA9848','6201102':'ICQUS7'}
payer_list = df_customer_info['ApplicantCode'].tolist()
for each_date in date:
for payer_code in payer_list:
if input_and_search_xml_ZLLEI09020(session, companyid='C100', msgid='LOCRCT', date=each_date, senderid=senderid_dict[payer_code]):
loop_get_xml_ZLLEI09020(session, id_list=locrct_id, db_table_name='๋ฌผํ์๋ น์ฆ')
st.dataframe(df_taxinv_viewer, width=1500, hide_index=True)
with tab3_col2:
st.title('๋ค๊ณ ์ผ ๋ฑ๋ก')
date_nego = st.date_input("๋ค๊ณ ์ผ์ ์ ํ",format='YYYY-MM-DD')
text_box_billingno = st.text_input(label="๋น๋ง๋ฒํธ ์
๋ ฅ", value='', max_chars=12, help='12์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')#, autocomplete='on')
if st.button('๐๋ฑ๋ก '):
input_data = {'๋น๋ง๋ฒํธ':text_box_billingno, '๋ค๊ณ ์ผ์':date_nego}
conn_db, db_cursor = db_open(file_path_db)
sql_query = f'''INSERT OR REPLACE INTO ๋น๋ง๋ฒํธ๋ณ๋ค๊ณ ์ผ์
VALUES (:{', :'.join(nego_history_id.keys())})
'''
db_cursor.execute(sql_query, (input_data)) # ํํ๋ก ๋ฃ์ด์ผ ์ ์ฅ
conn_db.commit()
conn_db.close()
if st.button('๐์ญ์ '):
conn_db, db_cursor = db_open(file_path_db)
sql_query = f'''DELETE FROM ๋น๋ง๋ฒํธ๋ณ๋ค๊ณ ์ผ์ WHERE ๋น๋ง๋ฒํธ == {text_box_billingno}'''
db_cursor.execute(sql_query) # ํํ๋ก ๋ฃ์ด์ผ ์ ์ฅ
conn_db.commit()
conn_db.close()
if st.button('์๋ก๊ณ ์นจ '):
pass
if st.button('์๋ น์ฆ ๋ฏธ๋ฐ๊ธ๊ฑด ํด๋ฆฝ๋ณด๋ ๋ณต์ฌ'):
df_taxinv_viewer[df_taxinv_viewer['์๋ น์ฆ๋ฐ๊ธ']==False][['๋น๋ง๋ฒํธ','์ ์ฉ์ฅ๋ฒํธ','์ ์ฉ์ฅ_์ ํจ๊ธฐ์ผ','๊ณ์ฐ์_๋ฐ๊ธ์ผ์','๊ณ์ฐ์_๊ณ์ฐ์๋ฒํธ']].to_clipboard(sep='\t', index=False)
with tab4:
tab4_col1, tab4_col2, tab4_col3 = st.columns([2,4,3])
with tab4_col1:
st.title('๋ก๊ทธ์ธ์ ๋ณด')
idx_txtbox = {0:'SEP/DEP',1:'ID',2:'PW',3:'n๋ฒ์งธ NERP์ฐฝ ์ฌ์ฉ(์ต๋6)'}
data_txtbox = {}
for i, each_data in enumerate(dict_default_opt['sap_option']):
data_txtbox[i] = st.text_input(label=idx_txtbox[i], value=dict_default_opt['sap_option'][i], type=('password' if i == 2 else 'default'))
if st.button('์ ์ฅ'):
dict_default_opt['sap_option'] = [data_txtbox[0], data_txtbox[1], data_txtbox[2], data_txtbox[3]]
write_load_json('w', file_path_json, list_object=dict_default_opt)
with tab4_col2:
st.title('๊ฑฐ๋์ ์ ๋ณด')
st.dataframe(df_customer_info, hide_index=True)
# ๊ฑฐ๋์ ์ ๋ณด๋ฅผ dict๋ก ๊ด๋ฆฌํ ๋๋ง ์ฌ์ฉ
# for each_data in dict_default_opt['applicant_info']:
# st.write(each_data, str(dict_default_opt['applicant_info'][each_data]))
with tab4_col3:
st.title('๊ฑฐ๋์ ์ ๋ณด ์์ ')
tab4_col3_col1, tab4_col3_col2 = st.columns([9,1])
with tab4_col3_col1:
text_box_customer = st.text_input(label=':red[์์ ํ ๊ฑฐ๋์ ์ ์ฌ์
์๋ฒํธ ์
๋ ฅํ์ธ์]', value='', max_chars=30, help='')#, autocomplete='on')
temp_dict_for_customer={}
if text_box_customer == '':
iterater = df_customer_info
for column_name in iterater.columns:
temp_dict_for_customer[column_name] = st.text_input(label=f'{column_name}_Customer', value='')
else:
try:
iterater = df_customer_info[df_customer_info['์ฌ์
์๋ฒํธ'].str.contains(text_box_customer)]
for column_name in iterater.columns:
temp_dict_for_customer[column_name] = st.text_input(label=f'{column_name}_Customer', value=iterater[column_name].iloc[0])
except:
iterater = df_customer_info
for column_name in iterater.columns:
temp_dict_for_customer[column_name] = st.text_input(label=f'{column_name}_Customer', value='')
with tab4_col3_col2:
if st.button('์ถ๊ฐ/์์ '):
conn_db, db_cursor = db_open(file_path_db)
sql_query = f"INSERT OR REPLACE INTO ๊ฑฐ๋์ ์ ๋ณด VALUES (:{', :'.join(customer_id.keys())})"
db_cursor.execute(sql_query, temp_dict_for_customer)
conn_db.commit()
conn_db.close()
if st.button('์ญ์ '):
conn_db, db_cursor = db_open(file_path_db)
db_cursor.execute(f'DELETE FROM ๊ฑฐ๋์ ์ ๋ณด WHERE ์ฌ์
์๋ฒํธ = "{text_box_customer}"')
conn_db.commit()
conn_db.close()
if st.button('์๋ก๊ณ ์นจ '):
pass
with tab5:
tab5_col1, tab5_col2 = st.columns([5, 5])
with tab5_col1:
st.title('์ธ๊ธ๊ณ์ฐ์ ์ญ์ ')
st.dataframe(df_taxinv, width=1500, hide_index=True)
with tab5_col2:
st.title('์ธ๊ธ๊ณ์ฐ์ ์ญ์ ๋ฉ๋ด')
text_box_delete_taxinv = st.text_input(label=':red[์ญ์ ํ ์ธ๊ธ๊ณ์ฐ์๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์]', value='', max_chars=30, help='')#, autocomplete='on')
if st.button('์ธ๊ธ๊ณ์ฐ์ ๋ด์ญ ์ญ์ '):
conn_db, db_cursor = db_open(file_path_db)
db_cursor.execute(f'DELETE FROM ์ธ๊ธ๊ณ์ฐ์ WHERE ์ธ๊ธ๊ณ์ฐ์๋ฒํธ = "{text_box_delete_taxinv}"')
conn_db.commit()
conn_db.close()
if st.button('์๋ก๊ณ ์นจ '):
pass
with tab6:
tab6_col1, tab6_col2 = st.columns([7, 3])
with tab6_col1:
st.title('๋ฌผํ์๋ น์ฆ ์ญ์ ')
tab6_col1_col1, tab6_col1_col2 = st.columns([2,8])
with tab6_col1_col1:
filter_df_receipt_duplicate = st.selectbox('์ ์ฒด/์ค๋ณต๊ฑด ๋ณด๊ธฐ', ['์ ์ฒด', '์ค๋ณต๊ฑด'])
with tab6_col1_col2:
text_box_search_receipt = st.text_input(label="๊ฒ์ํ ์ ์ฉ์ฅ ๋ฒํธ๋ฅผ ์
๋ ฅํ๊ณ Enter ", value='', max_chars=30, help='30์๋ฆฌ ์ซ์๋ง ์
๋ ฅ ๊ฐ๋ฅ')#, autocomplete='on')
# ์ต์
๊ฐ์ ๋ฐ๋ผ ๋ค๋ฅด๊ฒ ํ๊ธฐํ๋๋ก ์ธํ
ํ๋ ์ฝ๋ 1(๊ฒ์์ฐฝ)
if text_box_search_receipt or text_box_search_receipt == '':
df_receipt_viewer = df_receipt[df_receipt['์ ์ฉ์ฅ๋ฒํธ'].str.contains(text_box_search_receipt)].sort_values('์ ์๋ฌธ์๋ฒํธ')
# ์ต์
๊ฐ์ ๋ฐ๋ผ ๋ค๋ฅด๊ฒ ํ๊ธฐํ๋๋ก ์ธํ
ํ๋ ์ฝ๋ 2(ํํฐ)
if filter_df_receipt_duplicate == '์ค๋ณต๊ฑด':
df_receipt_viewer = df_receipt_viewer[df_receipt_viewer.duplicated(subset=['์ธ๊ธ๊ณ์ฐ์๋ฒํธ'], keep=False)]
# ์ต์
๊ฐ์ ๋ฐ๋ฅธ DataFrameํ๊ธฐ
st.dataframe(df_receipt_viewer, width=1500, hide_index=True)
with tab6_col2:
st.title('๋ฌผํ์๋ น์ฆ ์ญ์ ๋ฉ๋ด')
text_box_delete_receipt = st.text_input(label=':red[์ญ์ ํ (๋ฌผํ์๋ น์ฆ์)์ ์๋ฌธ์๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์]', value='', max_chars=30, help='')#, autocomplete='on')
if st.button('๋ฌผํ์๋ น์ฆ ๋ด์ญ ์ญ์ '):
conn_db, db_cursor = db_open(file_path_db)
db_cursor.execute(f'DELETE FROM ๋ฌผํ์๋ น์ฆ WHERE ์ ์๋ฌธ์๋ฒํธ = "{text_box_delete_receipt}"')
conn_db.commit()
conn_db.close()
if st.button('์๋ก๊ณ ์นจ '):
pass
with tab7:
st.title('์ฐธ๊ณ ์ฌ์ดํธ')
tab7_col1, tab7_col2 = st.columns([2,8])
with tab7_col1:
st.link_button('KTNET(๋ก์ปฌLC์ฌ์ดํธ)', 'https://ulocallc.utradehub.or.kr/LocalCredit/index.jsp?sso=ok',)
with tab7_col2:
st.write('์ด์ฉ์๋ด(์ฐ์ธก์๋จ) โ ์
๋ฌด์ ์ฐจ๋ณ ์ด์ฉ์๋ด(์ข์ธก) โ ์์ธ ์
๋ฌด์ ์ฐจ')
# streamlit run LocalLC_GUI.py
# streamlit run .\LocalLC\LocalLC_GUI.py