-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbfSearcher.py
More file actions
executable file
·134 lines (117 loc) · 2.75 KB
/
dbfSearcher.py
File metadata and controls
executable file
·134 lines (117 loc) · 2.75 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
#!/usr/bin/python
from dbfread import DBF
'''
BARCODES
0 - Code Number
1 - Barcode
2 - Qty
3 - Price
4 - P_price
5 - Start Prom
6 - End Prom
7 - Flat Tax
8 - Price B
...
16 - Price J
LIQCODES
0 - Code Number
1 - Barcode
2 - Barcode 2
3 - Brand
4 - Description
5 - Type
6 - Size
7 - Cost
8 - Last Cost
9 - Next Cost
10 - Cost_2
11 - Cost_3
12 - Price
37 - Taxable
53 - Deposit
54 - Deposit Amount
45 - Case Price
46 - Standard Quantity
'''
class Product:
def __init__(self, barcode, barcodes, liqcode):
self.price = None
self.qty = None
self.brand = ''
self.desc = ''
self.barcode = barcode.upper()
self.codeNum = ''
self.singlePrice = None
self.casePrice = None
self.barcodes = DBF(barcodes, encoding='latin-1')
self.liqcode = DBF(liqcode, encoding='latin-1')
self.deposit = None
self.dep = False
self.found = False
def priceFound(self):
return self.price is None
def getCodeNum(self):
for b in self.barcodes:
if b.items()[1][1] == self.barcode:
self.codeNum = b.items()[0][1]
self.qty = b.items()[2][1]
self.price = b.items()[3][1]
self.barcode = b.items()[1][1]
self.found = True
if b.items()[0][1] == self.codeNum and b.items()[1][1].startswith('S'):
self.singlePrice = b.items()[3][1]
if b.items()[0][1] == self.codeNum and b.items()[1][1].startswith('C'):
self.casePrice = b.items()[3][1]
return
def getName(self):
for l in self.liqcode:
if l.items()[0][1] == self.codeNum:
self.found = True
self.brand = l.items()[3][1]
self.desc = l.items()[4][1]
if self.qty is None:
self.qty = l.items()[58][1]
if self.price is None:
self.price = l.items()[12][1]
self.dep = True if l.items()[53][1] == u'Y' else False
if self.dep:
self.deposit = self.qty * 0.05
def getProduct(self):
ScannerGUI.meterPercent = 5
self.getCodeNum()
ScannerGUI.meterPercent = 50
self.getName()
ScannerGui.meterPercent = 100
def __str__(selfi):
if not self.found:
return "Product Not Found :("
s = ''
s+='Brand: '+self.brand+'\n'
s+='Description: '+self.desc+'\n'
if self.price is not None:
s+='Price: %.2f' % self.price+'\n'
else:
s+='Price: N/A\n'
s+='QTY: %i' % self.qty+'\n'
s+='Barcode: '+self.barcode+'\n'
if self.singlePrice is not None:
s+='Single Price: %.2f' % self.singlePrice+'\n'
else:
s+='Single Price: N/A\n'
if self.casePrice is not None:
s+='Case Price: %.2f' % self.casePrice+'\n'
else:
s+='Case Price: N/A\n'
if self.dep:
s+='Deposit: %.2f' % self.deposit+'\n'
else:
s+='Deposit: N/A\n'
return s
def main():
bar = raw_input('enter barcode:\n')
prod = Product(bar, 'BARCODES.dbf', 'LIQCODE.dbf')
prod.getCodeNum()
prod.getName()
print prod
if __name__ == "__main__":
main()