-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenelfonks.py
More file actions
199 lines (184 loc) · 5.53 KB
/
Copy pathgenelfonks.py
File metadata and controls
199 lines (184 loc) · 5.53 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
# -*- coding: utf-8 -*-
import sqlite3 as lite
import sys
import datetime
import os
import decimal
import time
import codecs
from logcu import *
import random
import re
import sqlite3 as lite
import sys
import urllib2, urllib
import MultipartPostHandler
from random import randint
import datetime
from mysqlmak import *
from cari import *
from stok import *
from fatura import *
from htmlrapor import *
from stdnum import ean
import ctypes
class Arge:
def coklu_topla(self,miktar):
if '+' in str(miktar):
miktarlar=miktar.split('+')
topmik=0
for mik in miktarlar:
if mik.find(",") > 0 :
mik=mik.replace(',','.')
mik=float(mik)
topmik+=mik
miktar=topmik
miktar=str(miktar)
if '*' in str(miktar):
miktarlar=miktar.split('*')
topmik=1
for mik in miktarlar:
if mik.find(",") > 0 :
mik=mik.replace(',','.')
mik=float(mik)
topmik*=mik
miktar=topmik
miktar=str(miktar)
if '/' in str(miktar):
miktarlar=miktar.split('/')
bolnn=miktarlar[0]
bol=miktarlar[1]
if bolnn.find(",") > 0 :
bolnn=bolnn.replace(',','.')
if bol.find(",") > 0 :
bol=bol.replace(',','.')
miktar=float(bolnn)/float(bol)
else:
return miktar
return str(round(float(miktar),3))
def saat_al(self):
saatstr=""
now = datetime.datetime.now()
saatstr=now.strftime("%H:%M:%S")
return saatstr
def tyazi_cevir(self,tutar):
yaziyla1=""
yaziyla2=""
if(tutar.find(",") != -1):
tumtutar = tutar.split(",")
yaziyla1 = cevir(tumtutar[0]) + "TL"
yaziyla2 = cevir(tumtutar[1]) + "KRStur"
elif(tutar.find(".") != -1):
tumtutar = tutar.split(".")
yaziyla1 = cevir(tumtutar[0]) + "TL."
yaziyla2 = cevir(tumtutar[1]) + "KRStur"
else:
yaziyla1 = cevir(tutar) + "TLdir"
yaziyla2 = ""
return [yaziyla1,yaziyla2]
def barkod_tamamla(self,barkode):
ek=ean.calc_check_digit(str(barkode))
return str(barkode)+ek
def dosyaYdizi(self,dosya):
icerik=codecs.open(dosya, "r","latin5")
stoklar=[]
for satir in icerik:
sat=satir.split("\n")[0]
sat=sat.split("\r")[0]
stoklar.append([sat])
return stoklar
def servisler_al(self,dosya="servisler.ayar"):
icerik=codecs.open(dosya, "r","latin5")
servisler=[]
for satir in icerik:
sat=satir.split("\n")[0]
sat=sat.split("\r")[0]
servisler.append(sat)
return servisler
def z_rapor_analiz(self,dosya):
anahtar="SIGNATURE=GNDZDETAILS.GDF"
zrap=[]
with open(dosya,'r') as f:
for satir in f:
rap=[]
satlar=satir.split()
if satlar[0]==anahtar or anahtar=="tm":
if anahtar=="tm":
fisno=satlar[1]
tarih=satlar[4]
rap.append(tarih)
rap.append(fisno)
for x in range(0,10):
rap.append(satlar[24+x])
gentop=satlar[8]
rap.append(gentop)
anahtar="tm"
if len(rap)>0:
zrap.append(rap)
#print zrap
rapor=statikrapor()
sutunlar=["TARIH","FISNO","KONTOR","TEMEL GIDA","MUHTELIF","UN-EKMEK","TEMIZLIK","GAZETE","SIGARA","MANAV","ET","OZ URETIM","TOPLAM"]
return rapor.diziYhtml(zrap,sutunlar)
open("zrapo.html","w").write(rapor.diziYhtml(zrap,sutunlar))
def termal_yazdir(self,sablon="kasa"):
if sablon == "kasa":
saat=self.saat_al()
if('makbuznot' in request.form and 'makbuznot3' in request.form):
makbuznot=request.form["makbuznot"]
makbuznot2=request.form["makbuznot"]
makbuznot3=request.form["makbuznot3"]
else:
makbuznot="---"
makbuznot2="---"
makbuznot3="-"
fistip=""
tutarf=tutar
if(tutar!=""):
if(tutar[0] != "-" ): ## sayi negatif degilse , yani para girisi oluyorsa
fistip=("TAHSILAT").decode('utf-8')
makbuznot2=makbuznot
makbuznot=makbuznot3
else: ## sayi negatif ise , yani para ciktisi oluyorsa
fistip=("TEDİYE").decode('utf-8')
tutarf=tutar
tutar = tutar[1:]
makbuznot2=makbuznot3
tyazi=self.tyazi_cevir(tutar)
if(guncislem=="CARI" and secim!=""):
fishedef=secim.split('@')[0]
fishedef=fishedef[0:31]
else:
fishedef=secim.split('@')[1]
fishedef=fishedef[0:31]
with codecs.open("kasacikti.prn", "w","latin5") as out:
for line in codecs.open("sablon.prn",'r',"latin5"):
line=line.replace("xnushanot","ikinci".decode('utf-8'))
line=line.replace("xtarih", str(tarih))
line=line.replace("xsaat",str(saat))
line=line.replace("xfistip",fistip)
line=line.replace("xfisno",str(session['ksira']))
line=line.replace("xtutar",tutar.encode('iso8859-9'))
line=line.replace("xyaziyla1",tyazi[0].encode('iso8859-9'))
line=line.replace("xyaziyla2",tyazi[1].encode('iso8859-9'))
line=line.replace("xhedef",fishedef)
line=line.replace("xmakbuzack",kasaack)
line=line.replace("xteslimeden",makbuznot2)
line=line.replace("xteslimalan",makbuznot)
out.write(line)
with codecs.open("kasacikti2.prn", "w","latin5") as out:
for line in codecs.open("sablon.prn",'r',"latin5"):
line=line.replace("xnushanot","birinci".decode('utf-8'))
line=line.replace("xtarih", str(tarih))
line=line.replace("xsaat",str(saat))
line=line.replace("xfistip",fistip)
line=line.replace("xfisno",str(session['ksira']))
line=line.replace("xtutar",tutar.encode('iso8859-9'))
line=line.replace("xyaziyla1",tyazi[0].encode('iso8859-9'))
line=line.replace("xyaziyla2",tyazi[1].encode('iso8859-9'))
line=line.replace("xhedef",fishedef)
line=line.replace("xmakbuzack",kasaack)
line=line.replace("xteslimeden",makbuznot2)
line=line.replace("xteslimalan",makbuznot)
out.write(line)
os.system("yazdir1.bat")
os.system("yazdir2.bat")