Subversion Repositories SmartDukaan

Rev

Rev 13088 | Rev 13094 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13088 Rev 13093
Line 73... Line 73...
73
                          join inventory.warehouse w on w.id = o.fulfilmentWarehouseId join orderstatus os on o.status = os.status 
73
                          join inventory.warehouse w on w.id = o.fulfilmentWarehouseId join orderstatus os on o.status = os.status 
74
                          where o.status in (3,4,5,7) and o.total_amount > 1 order by code, prodname   
74
                          where o.status in (3,4,5,7) and o.total_amount > 1 order by code, prodname   
75
                        """
75
                        """
76
 
76
 
77
STOCK_REPORT_GROUP_SQL= """
77
STOCK_REPORT_GROUP_SQL= """
78
                        select c.name, concat_ws(' ',li.brand, li.model_name, li.model_number, li.color) as product,  count(*) as delivered,
-
 
79
                            sum(if(mar.activationTime is not null, 1, 0)) as sold, sum(if(mar.activationTime is not null, 0, 1)) as instock,  
-
 
80
                            sum(if(mar.activationTime is not null, 0,o.total_amount)) as valueinstock 
-
 
81
                        from transaction.order o join user.privatedealuser pd on o.customer_id=pd.id 
-
 
82
                            left join mobileactivationrecord mar on mar.orderId = o.id  join user.counter c on c.id = pd.counter_id 
-
 
83
                            join transaction.lineitem li on li.order_id=o.id 
-
 
84
                        where o.status=12 and o.total_amount > 0 and li.brand = 'Spice' and li.item_id not in (select itemId from catalog.spiceuntraceable) group by name, product  with rollup
78
                        select c.name, concat_ws(' ',li.brand, li.model_name, li.model_number, li.color) as product,  sum(if(o.status=12, 1,0)) delivered, sum(if(mar.activationTime is not null, 1, 0)) as sold, sum(if(mar.activationTime is null and o.status=12, 1, 0)) as instock, sum(if(mar.activationTime is null and o.status=12, o.total_amount,0)) as valueinstock, sum(if(o.status in (9,10,16,17,40), 1,0)) shipped, sum(if(o.status in (9,10,16,17,40), o.total_amount,0)) shippedAmount, sum(if(o.status in (3,4,5,7), 1,0)) pending, sum(if(o.status in (3,4,5,7), o.total_amount,0)) pendingAmount from transaction.order o join user.privatedealuser pd on o.customer_id=pd.id left join mobileactivationrecord mar on mar.orderId = o.id  join user.counter c on c.id = pd.counter_id join transaction.lineitem li on li.order_id=o.id where o.status in (12,9,10,16,17,40,3,4,5,7) and o.total_amount > 0 and li.brand = 'Spice' and li.item_id not in (select itemId from catalog.spiceuntraceable) group by name, product  with rollup
85
                        """
79
                        """
-
 
80
 
86
STOCK_REPORT_SQL=       """
81
STOCK_REPORT_SQL=       """
87
                        select c.code, c.name, o.id, date(o.created_timestamp) createddate, date(o.delivery_timestamp) delivereddate, os.statusName, 
82
                        select c.code, c.name, o.id, date(o.created_timestamp) createddate, date(o.delivery_timestamp) delivereddate, os.statusName, 
88
                        concat_ws(' ',li.brand, li.model_name, li.model_number, li.color) as product,  li.quantity, o.total_amount, 
83
                        concat_ws(' ',li.brand, li.model_name, li.model_number, li.color) as product,  li.quantity, o.total_amount, 
89
                        datediff(curdate(),date(o.delivery_timestamp)) as ageing  from transaction.order o join user.privatedealuser 
84
                        datediff(curdate(),date(o.delivery_timestamp)) as ageing  from transaction.order o join user.privatedealuser 
90
                        pd on o.customer_id=pd.id left join mobileactivationrecord mar on mar.orderId = o.id  
85
                        pd on o.customer_id=pd.id left join mobileactivationrecord mar on mar.orderId = o.id  
Line 136... Line 131...
136
default_format = xlwt.XFStyle()
131
default_format = xlwt.XFStyle()
137
 
132
 
138
shipped_headers=['Counter', 'Product', 'Quantity', 'Value']
133
shipped_headers=['Counter', 'Product', 'Quantity', 'Value']
139
tertiary_headers=shipped_headers
134
tertiary_headers=shipped_headers
140
pending_headers=shipped_headers
135
pending_headers=shipped_headers
141
ageing_headers=['Counter','Product','QtyDelivered','QtySold','QtyInStock','ValueInStock']
136
ageing_headers=['Counter','Product','QtyDelivered','QtySold','QtyInStock','ValueInStock', 'QtyPending', 'ValuePending', 'QtyShipped','ValueShipped']
142
mis_headers=['Counter','Last Day Qty', 'Last Day Value','MTD Qty', 'MTD Value']
137
mis_headers=['Counter','Last Day Qty', 'Last Day Value','MTD Qty', 'MTD Value']
143
mis_headers_prod=['Product','Last Day Qty', 'Last Day Value','MTD Qty', 'MTD Value']
138
mis_headers_prod=['Product','Last Day Qty', 'Last Day Value','MTD Qty', 'MTD Value']
144
 
139
 
145
report_map['shipped'] = {'title':'Shipped Orders Report', 'query' : SHIPPED_ORDER_GROUP_SQL, 'group':2, 'headers':shipped_headers}
140
report_map['shipped'] = {'title':'Shipped Orders Report', 'query' : SHIPPED_ORDER_GROUP_SQL, 'group':2, 'headers':shipped_headers}
146
report_map['tertiary'] = {'title':'Tertiary Report', 'query' : SOLD_OUT_GROUP_SQL, 'group':2, 'headers':tertiary_headers}
141
report_map['tertiary'] = {'title':'Tertiary Report', 'query' : SOLD_OUT_GROUP_SQL, 'group':2, 'headers':tertiary_headers}
147
report_map['pending'] = {'title':'Pending Orders Report', 'query' : PENDING_ORDER_GROUP_SQL, 'group':2, 'headers':pending_headers}
142
report_map['pending'] = {'title':'Pending Orders Report', 'query' : PENDING_ORDER_GROUP_SQL, 'group':2, 'headers':pending_headers}
148
report_map['ageing'] = {'title':'Spice Stock Ageing Report', 'query' : STOCK_REPORT_GROUP_SQL, 'group':2, 'headers':ageing_headers}
143
report_map['ageing'] = {'title':'Spice Stock Ageing Report', 'query' : STOCK_REPORT_GROUP_SQL, 'group':2, 'headers':ageing_headers, 'grandIndex':5}
149
report_map['mis'] = {'title':'Counter wise Sales Report', 'query' : MIS_REPORT_GROUP_SQL, 'group':1, 'headers':mis_headers}
144
report_map['mis'] = {'title':'Counter wise Sales Report', 'query' : MIS_REPORT_GROUP_SQL, 'group':1, 'headers':mis_headers}
150
report_map['mis_prod'] = {'title':'Product wise Sales Report', 'query' : MIS_REPORT_GROUP_PROD_SQL, 'group':1, 'headers':mis_headers_prod}
145
report_map['mis_prod'] = {'title':'Product wise Sales Report', 'query' : MIS_REPORT_GROUP_PROD_SQL, 'group':1, 'headers':mis_headers_prod}
151
 
146
 
152
#recipients = []
147
#recipients = []
153
recipients = ['rajneesh.arora@saholic.com', 'lakshman.g@smobility.in', 'sandeep.sachdeva@shop2020.in', 'amit.sirohi@shop2020.in', 'khushal.bhatia@saholic.com', 'chaitnaya.vats@saholic.com']
148
recipients = ['rajneesh.arora@saholic.com', 'lakshman.g@smobility.in', 'sandeep.sachdeva@shop2020.in', 'amit.sirohi@shop2020.in', 'khushal.bhatia@saholic.com', 'chaitnaya.vats@saholic.com', 'ritesh.chauhan@shop2020.in']
154
 
149
 
155
 
150
 
156
def getDbConnection():
151
def getDbConnection():
157
    return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
152
    return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
158
  
153
  
Line 426... Line 421...
426
                    nullColumn = grColumn
421
                    nullColumn = grColumn
427
                    break
422
                    break
428
 
423
 
429
            tbody.append("<tr>")
424
            tbody.append("<tr>")
430
            
425
            
-
 
426
            grandIndex =  headerLen - 1
-
 
427
            if reportmap.has_key('grandIndex'):
-
 
428
                grandIndex = reportmap['grandIndex']
431
            for column in range(0, headerLen):      
429
            for column in range(0, headerLen):      
432
                tbody.append(tag)
430
                tbody.append(tag)
433
                if nullColumn==column:
431
                if nullColumn==column:
434
                    if nullColumn==0:
432
                    if nullColumn==0:
435
                        tbody.append('Grand Total')
433
                        tbody.append('Grand Total')
436
                        grandTotal = row[headerLen-1]
434
                        grandTotal = row[grandIndex]
437
                    else:
435
                    else:
438
                        tbody.append('Sub Total')
436
                        tbody.append('Sub Total')
439
                elif row[column] is None:
437
                elif row[column] is None:
440
                        tbody.append('')
438
                        tbody.append('')
441
                else:
439
                else: