Subversion Repositories SmartDukaan

Rev

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

Rev 6870 Rev 6903
Line -... Line 1...
-
 
1
# -*- coding: utf-8 -*-
-
 
2
 
1
'''
3
'''
2
Created on 29-Mar-2010
4
Created on 29-Mar-2010
3
 
5
 
4
@author: Chandranshu
6
@author: Chandranshu
5
'''
7
'''
Line 23... Line 25...
23
from shop2020.model.v1.order.impl import DataService, RechargeService
25
from shop2020.model.v1.order.impl import DataService, RechargeService
24
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
26
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
25
    Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
27
    Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
26
    OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
28
    OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
27
    CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, \
29
    CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, \
28
    MiscCharges, BlockedIpRange, DeniedIpAddress
30
    MiscCharges, BlockedIpRange, DeniedIpAddress, InsuranceDetailForOrder
29
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
31
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
30
    MobileRechargeOrder
32
    MobileRechargeOrder
31
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
33
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
32
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
34
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
33
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
35
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
Line 153... Line 155...
153
    if t_order.created_timestamp:
155
    if t_order.created_timestamp:
154
        order.created_timestamp = to_py_date(t_order.created_timestamp)
156
        order.created_timestamp = to_py_date(t_order.created_timestamp)
155
    else:
157
    else:
156
        order.created_timestamp = datetime.datetime.now()
158
        order.created_timestamp = datetime.datetime.now()
157
    order.pickupStoreId = t_order.pickupStoreId
159
    order.pickupStoreId = t_order.pickupStoreId
-
 
160
    order.insurer = t_order.insurer
-
 
161
    order.insuranceAmount = t_order.insuranceAmount
-
 
162
    if order.insurer > 0:
-
 
163
        insuranceDetail = InsuranceDetailForOrder()
-
 
164
        insuranceDetail.dob = t_order.dob
-
 
165
        insuranceDetail.guardianName = t_order.guardianName
-
 
166
        insuranceDetail.order = order
158
    return order
167
    return order
159
    
168
    
160
def create_transaction(t_transaction):
169
def create_transaction(t_transaction):
161
    t_orders = t_transaction.orders
170
    t_orders = t_transaction.orders
162
    if not t_orders:
171
    if not t_orders:
Line 1503... Line 1512...
1503
                print e
1512
                print e
1504
        else:
1513
        else:
1505
            order.status = OrderStatus.DELIVERY_SUCCESS
1514
            order.status = OrderStatus.DELIVERY_SUCCESS
1506
            order.statusDescription = "Order delivered"
1515
            order.statusDescription = "Order delivered"
1507
            update_trust_level(order)
1516
            update_trust_level(order)
-
 
1517
            if order.insuranceDetails:
-
 
1518
                order.insuranceDetails[0].startDate = order.delivery_timestamp
-
 
1519
                order.insuranceDetails[0].expiryDate = order.delivery_timestamp + timedelta(days = 365)
1508
            if enqueue_delivery_success_mail(order) :
1520
            if enqueue_delivery_success_mail(order) :
1509
                session.commit()
1521
                session.commit()
1510
            else :
1522
            else :
1511
                session.rollback()
1523
                session.rollback()
1512
            try:
1524
            try:
Line 1533... Line 1545...
1533
            order.first_dlvyatmp_timestamp = deliveryTimestamp
1545
            order.first_dlvyatmp_timestamp = deliveryTimestamp
1534
        order.receiver = receiver
1546
        order.receiver = receiver
1535
    order.status = OrderStatus.DELIVERY_SUCCESS
1547
    order.status = OrderStatus.DELIVERY_SUCCESS
1536
    order.statusDescription = "Order delivered"
1548
    order.statusDescription = "Order delivered"
1537
    update_trust_level(order)
1549
    update_trust_level(order)
-
 
1550
    if order.insuranceDetails:
-
 
1551
        order.insuranceDetails[0].startDate = deliveryTimestamp
-
 
1552
        order.insuranceDetails[0].expiryDate = deliveryTimestamp + timedelta(days = 365)
1538
    session.commit()
1553
    session.commit()
1539
    
1554
    
1540
    if order.pickupStoreId and order.cod:
1555
    if order.pickupStoreId and order.cod:
1541
        __push_collection_to_hotspot(order, "SALE")
1556
        __push_collection_to_hotspot(order, "SALE")
1542
    
1557
    
Line 4131... Line 4146...
4131
    except:
4146
    except:
4132
        return False
4147
        return False
4133
 
4148
 
4134
if __name__ == '__main__':
4149
if __name__ == '__main__':
4135
    print 'Inside main'
4150
    print 'Inside main'
4136
    DataService.initialize()
-
 
4137
    '''a = MobileRechargeOrder()
-
 
4138
    session.commit()
-
 
4139
    a.mobileNumber = 89564785666
-
 
4140
    session.commit()
-
 
4141
    '''
-
 
4142
4151
    #def __generate_return_advice(order, warehouse, provider, filename):
-
 
4152
#    if warehouse.id == 7:
-
 
4153
#        executive = 'Amit Kumar'
-
 
4154
#    else:
-
 
4155
#        executive = 'Dinesh Kumar'
-
 
4156
    from reportlab.lib.styles import ParagraphStyle
-
 
4157
    from reportlab.lib.styles import getSampleStyleSheet
-
 
4158
    from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
-
 
4159
    from reportlab.lib.styles import getSampleStyleSheet
-
 
4160
    from reportlab.rl_config import defaultPageSize
-
 
4161
    from reportlab.lib.units import inch
-
 
4162
    PAGE_HEIGHT=defaultPageSize[1]; PAGE_WIDTH=defaultPageSize[0]
-
 
4163
    styles = getSampleStyleSheet()
-
 
4164
    styles.add(ParagraphStyle(name='left', leftIndent=12,fontSize=11), alias='li')
-
 
4165
    styles.add(ParagraphStyle(name='bullet', bulletIndent=24, leftIndent=24), alias='bull')
-
 
4166
    
-
 
4167
    Title = "MOBILE HAND SET INSURANCE – THEFT & BURGLARY RISKS ONLY"
-
 
4168
    
-
 
4169
    def myFirstPage(canvas, doc):
-
 
4170
        canvas.saveState()
-
 
4171
        canvas.setFont('Times-Bold',14)
-
 
4172
        canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT- inch, Title)
-
 
4173
        canvas.setTitle("Insurance Terms")
-
 
4174
        canvas.restoreState()
-
 
4175
    
-
 
4176
    invoiceNumber = 11111111
-
 
4177
    billing_timestamp = '2012-03-14'
-
 
4178
    
-
 
4179
    doc = SimpleDocTemplate("/home/anupam/Desktop/phello.pdf")
-
 
4180
    Story = [Spacer(1,0.4*inch)]
-
 
4181
    style = styles["Normal"]
-
 
4182
    text = ("""<u><b>Subject Matter Of Insurance</b></u> : <i>New Mobile Handsets</i> alone and <i>Tablets with 'Voice Calls'</i> only. 
-
 
4183
    Sold 'online' by <b>Spice Online Retail Private Limited, New Delhi</b>, to its customers.""") 
-
 
4184
    p = Paragraph(text, style)
-
 
4185
    Story.append(p)
-
 
4186
    Story.append(Spacer(1,0.2*inch))
-
 
4187
    text = ("""Insurer will indemnify the Insured in the event of Theft/Burglary of <i>Mobile Handsets</i> 
-
 
4188
    alone and <i>Tablets with 'Voice Calls'</i> only sold as per Invoice No. %d
-
 
4189
    dated %s and insured with THE NEW INDIA ASSURANCE COMPANY LIMITED, BANGALORE, as per Policy No. 671700/46/12/2400000008,  
-
 
4190
    for a period of 12 months from the date and time of delivery of Mobile Handset to the customer.""" % (invoiceNumber, billing_timestamp)) 
-
 
4191
    p = Paragraph(text, style)
-
 
4192
    Story.append(p)
-
 
4193
    Story.append(Spacer(1,0.2*inch))
-
 
4194
    text = ("""<b>WARRANTY</b> -  Warranted that the Mobile Handset sold during the Policy Period of 25/02/2013 to 24/02/2014
-
 
4195
             are only covered irrespective of date of delivery to the customer""")
-
 
4196
    p = Paragraph(text, style)
-
 
4197
    Story.append(p)
-
 
4198
    Story.append(Spacer(1,0.2*inch))
-
 
4199
    text = ("<b>INSURER</b> - New India Assurance company limited.")
-
 
4200
    p = Paragraph(text, style)
-
 
4201
    Story.append(p)
-
 
4202
    Story.append(Spacer(1,0.2*inch))
-
 
4203
    text = ("<b>INSURED</b> - Purchaser of the Mobile Handset OR his/her spouse or children. If the Purchaser is a ‘Company’, user is the duly authorised person.") 
-
 
4204
    p = Paragraph(text, style)
-
 
4205
    Story.append(p)
-
 
4206
    Story.append(Spacer(1,0.2*inch))
-
 
4207
    text = ("<b>GEOGRAPHICAL LIMIT</b> – World-wide") 
-
 
4208
    p = Paragraph(text, style)
-
 
4209
    Story.append(p)
-
 
4210
    Story.append(Spacer(1,0.2*inch))
-
 
4211
    text = ("<b>RISK COVERAGE</b> – Theft and/or burglary only") 
-
 
4212
    p = Paragraph(text, style)
-
 
4213
    Story.append(p)
-
 
4214
    Story.append(Spacer(1,0.2*inch))
-
 
4215
    text = ("Exclusions:") 
-
 
4216
    p = Paragraph(text, styles["h2"])
-
 
4217
    Story.append(p)
-
 
4218
    Story.append(Spacer(1,0.1*inch))
-
 
4219
    
-
 
4220
    text = ("Insurer is not liable") 
-
 
4221
    p = Paragraph(text, styles["left"])
-
 
4222
    Story.append(p)
-
 
4223
    Story.append(Spacer(1,0.1*inch))
-
 
4224
    
-
 
4225
    text = ("If the handset is not connected to Mobile Service Provider Network")
-
 
4226
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4227
    Story.append(p)
-
 
4228
    Story.append(Spacer(1,0.1*inch))
-
 
4229
    text = ("Caused by incorrect storage, poor care and maintenance, careless use, negligence.")
-
 
4230
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4231
    Story.append(p)
-
 
4232
    Story.append(Spacer(1,0.1*inch))
-
 
4233
    text = ("Due to mysterious disappearance, forgotten or misplaced or Lost or if handset is left unattended at any point of time.")
-
 
4234
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4235
    Story.append(p)
-
 
4236
    Story.append(Spacer(1,0.1*inch))
-
 
4237
    text = ("Caused by war, war like operation, act of foreign enemy, civil war, rebellion, civil commotion, military usurped power, seizure, capture, confiscation, arrests, restrains and detainment by order of any Government or any other Authority.")
-
 
4238
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4239
    Story.append(p)
-
 
4240
    Story.append(Spacer(1,0.1*inch))
-
 
4241
    text = ("Caused whilst engaging in criminal acts.")
-
 
4242
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4243
    Story.append(p)
-
 
4244
    Story.append(Spacer(1,0.1*inch))
-
 
4245
    text = ("Caused by consequential loss or damage of whatsoever nature or any costs incurred in connection with claim under this policy, including postage, transit costs and reconnection cost.")
-
 
4246
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4247
    Story.append(p)
-
 
4248
    Story.append(Spacer(1,0.1*inch))
-
 
4249
    text = ("Loss of mobile handset due to theft from an unattended vehicle unless the vehicle is of  fully enclosed saloon type having at time all the doors/windows and other opening securely locked and properly fastened.")
-
 
4250
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4251
    Story.append(p)
-
 
4252
    Story.append(Spacer(1,0.1*inch))
-
 
4253
    text = ("Loss of mobile handset due to theft from the building unless there is visible forcible entry/exit into/from the building.")
-
 
4254
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4255
    Story.append(p)
-
 
4256
    Story.append(Spacer(1,0.1*inch))
-
 
4257
    text = ("If the documents are found to be tampered; non-disclosure of material fact, fraud/misrepresentation.")
-
 
4258
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4259
    Story.append(p)
-
 
4260
    Story.append(Spacer(1,0.1*inch))
-
 
4261
    text = ("The policy is not transferable.")
-
 
4262
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4263
    Story.append(p)
-
 
4264
    Story.append(Spacer(1,0.2*inch))
-
 
4265
    
-
 
4266
    text = ("Claim Procedure:") 
-
 
4267
    p = Paragraph(text, styles["h2"])
-
 
4268
    Story.append(p)
-
 
4269
    Story.append(Spacer(1,0.1*inch))
-
 
4270
    text = ("""For Theft or Burglary of the handset immediate intimation to be given
-
 
4271
     to the police within 48 hours of occurrence of incident and proper documents to be obtained 
-
 
4272
     and inform the service provider within 48 hours about theft of handset in order to block the SIM services.""")
-
 
4273
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4274
    Story.append(p)
-
 
4275
    Story.append(Spacer(1,0.1*inch))
-
 
4276
    text = ("""To intimate Insurance Company about the loss of Mobile Handset within 48 hours 
-
 
4277
     through Call Centre No.022-49107910 OR through e-mail saholic.claims@universalinsurance.co.in OR through 
-
 
4278
     written communication to <i>Universal Insurance brokers (UIB) No.304, Commerce House, 9/1,Cunningham Road, Bangalore – 560052</i>.""")
-
 
4279
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4280
    Story.append(p)
-
 
4281
    Story.append(Spacer(1,0.1*inch))
-
 
4282
    text = ("""Claim documents can be downloaded through UIB Website ***TO BE DECIDED***
-
 
4283
    To know or track your claim please contact Call Centre No. 022-49107910 of Universal Insurance brokers (UIB). """)
-
 
4284
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4285
    Story.append(p)
-
 
4286
    Story.append(Spacer(1,0.1*inch))
-
 
4287
    text = ("""All the completed claim documents to reach ‘Universal Insurance Brokers (UIB)’ office 
-
 
4288
    at <i>No.304, Commerce House, 9/1, Cunningham Road, Bangalore – 560052</i> <b>within 21 days</b>.""")
-
 
4289
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4290
    Story.append(p)
-
 
4291
    Story.append(Spacer(1,0.2*inch))
-
 
4292
    
-
 
4293
 
-
 
4294
    text = ("Excess(Minimum Deduction):") 
-
 
4295
    p = Paragraph(text, styles["h2"])
-
 
4296
    Story.append(p)
-
 
4297
    Story.append(Spacer(1,0.1*inch))
-
 
4298
    text = ("""The excess will be 5% of the value of each claim subject to a minimum of Rs.500/-""")
-
 
4299
    p = Paragraph(text, styles["left"])
-
 
4300
    Story.append(p)
-
 
4301
    Story.append(Spacer(1,0.2*inch))
-
 
4302
    
-
 
4303
    text = ("Depreciation:") 
-
 
4304
    p = Paragraph(text, styles["h2"])
-
 
4305
    Story.append(p)
-
 
4306
    Story.append(Spacer(1,0.1*inch))
-
 
4307
    
-
 
4308
    text = ("For 0 – 60 days, 15%")
-
 
4309
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4310
    Story.append(p)
-
 
4311
    Story.append(Spacer(1,0.1*inch))
-
 
4312
    
-
 
4313
    text = ("61-150 days, 30%")
-
 
4314
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4315
    Story.append(p)
-
 
4316
    Story.append(Spacer(1,0.1*inch))
-
 
4317
    
-
 
4318
    text = ("151 – 365 days, 45%")
-
 
4319
    p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
-
 
4320
    Story.append(p)
-
 
4321
    Story.append(Spacer(1,0.4*inch))
-
 
4322
    
-
 
4323
    text = ("<i>Insurance is a subject matter of solicitation.</i>")
-
 
4324
    p = Paragraph(text, style)
-
 
4325
    Story.append(p)
-
 
4326
    Story.append(Spacer(1,0.2*inch))
-
 
4327
    
-
 
4328
    doc.build(Story, onFirstPage=myFirstPage)
-
 
4329
4143
4330