Subversion Repositories SmartDukaan

Rev

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

Rev 7392 Rev 7393
Line 61... Line 61...
61
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
61
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
62
    InventoryServiceException, WarehouseType, InventoryType
62
    InventoryServiceException, WarehouseType, InventoryType
63
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
63
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
64
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
64
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
65
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
65
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
66
    RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod, OrderSource
66
    RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod, OrderSource,\
-
 
67
    StorePaymentStatus
67
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
68
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
68
from shop2020.thriftpy.payments.ttypes import PaymentException
69
from shop2020.thriftpy.payments.ttypes import PaymentException
69
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
70
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
70
    WarehouseServiceException
71
    WarehouseServiceException
71
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
72
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
Line 2591... Line 2592...
2591
                    warehouseClient.scanForOrder(None, ScanType.SALE_RET, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
2592
                    warehouseClient.scanForOrder(None, ScanType.SALE_RET, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
2592
            if warehouse.billingType == BillingType.OURS_EXTERNAL:
2593
            if warehouse.billingType == BillingType.OURS_EXTERNAL:
2593
                warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)            
2594
                warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)            
2594
 
2595
 
2595
    if order.source == 2 and order.status in (OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.ACCEPTED, OrderStatus.INVENTORY_LOW):
2596
    if order.source == 2 and order.status in (OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.ACCEPTED, OrderStatus.INVENTORY_LOW):
-
 
2597
        storeOrderDetail = StoreOrderDetail.query.filter(StoreOrderDetail.orderId == order.id).filter(StoreOrderDetail.storeId == order.storeId).first()
-
 
2598
        if order.created_timestamp.date() == datetime.datetime.now().date():
-
 
2599
            __push_store_collection_to_hotspot(order, "advanceRefund", -(storeOrderDetail.cashRefundAmount + storeOrderDetail.cardRefundAmount))
-
 
2600
            storeOrderDetail.payStatus = StorePaymentStatus.ADV_REFUNDED
-
 
2601
        else:
2596
        __push_store_collection_to_hotspot(order, "advanceRefund", -order.advanceAmount)
2602
            __push_store_collection_to_hotspot(order, "advanceRefund", -(storeOrderDetail.cashRefundAmount))
-
 
2603
            if storeOrderDetail.cardRefundAmount > 0:
-
 
2604
                storeOrderDetail.payStatus = StorePaymentStatus.REFUND_PENDING
2597
        
2605
            else:
-
 
2606
                storeOrderDetail.payStatus = StorePaymentStatus.ADV_REFUNDED
2598
    order.status = status_transition[order.status]
2607
    order.status = status_transition[order.status]
2599
    order.refund_timestamp = datetime.datetime.now()
2608
    order.refund_timestamp = datetime.datetime.now()
2600
    order.refunded_by = refunded_by
2609
    order.refunded_by = refunded_by
2601
    order.refund_reason = reason
2610
    order.refund_reason = reason
2602
    
-
 
2603
    
-
 
2604
    session.commit()
2611
    session.commit()
2605
    return True
2612
    return True
2606
 
2613
 
2607
def __update_inventory_reservation(order):
2614
def __update_inventory_reservation(order):
2608
    '''
2615
    '''
Line 5273... Line 5280...
5273
    customerAdd2 = order.customer_address2
5280
    customerAdd2 = order.customer_address2
5274
    customerCity = order.customer_city
5281
    customerCity = order.customer_city
5275
    customerState = order.customer_state
5282
    customerState = order.customer_state
5276
    customerMobile = order.customer_mobilenumber
5283
    customerMobile = order.customer_mobilenumber
5277
    customerPin = order.customer_pincode
5284
    customerPin = order.customer_pincode
5278
    
-
 
5279
    mode = ""
-
 
5280
    if storeOrderDetail.cashAmount > 0 and storeOrderDetail.cardAmount > 0:
-
 
5281
        mode = "CASH + CARD"
-
 
5282
    elif storeOrderDetail.cashAmount > 0:
5285
    inCash = storeOrderDetail.cashAmount
5283
        mode = "CASH"
-
 
5284
    elif storeOrderDetail.cardAmount > 0:
5286
    byCard = storeOrderDetail.cardAmount
5285
        mode = "CARD"
-
 
5286
        
-
 
5287
    #payMethod = recharge.payMethod
5287
    #payMethod = recharge.payMethod
5288
#    if order.status == 15 or order.status == 34:
5288
#    if order.status == 15 or order.status == 34:
5289
#        return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
5289
#        return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
5290
    return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
5290
    return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
5291
 
5291
 
5292
 
5292
 
5293
def __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin): 
5293
def __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin): 
5294
    PAGE_HEIGHT=defaultPageSize[1];
5294
    PAGE_HEIGHT=defaultPageSize[1];
5295
    styles = getSampleStyleSheet()
5295
    styles = getSampleStyleSheet()
5296
    styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
5296
    styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
5297
    styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
5297
    styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
5298
    styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
5298
    styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
Line 5312... Line 5312...
5312
    
5312
    
5313
    ############### TODO ###############################################################
5313
    ############### TODO ###############################################################
5314
    Story.append(Paragraph("""Spice Retail Limited<br></br>
5314
    Story.append(Paragraph("""Spice Retail Limited<br></br>
5315
        C/O,PIBCO LIMITED,Basement,Punjsons<br></br>
5315
        C/O,PIBCO LIMITED,Basement,Punjsons<br></br>
5316
        2,Kalkaji Industrial Area,New Delhi<br></br>
5316
        2,Kalkaji Industrial Area,New Delhi<br></br>
5317
          .<br></br>
5317
          .<br></br>""", prologueStyle))
5318
        TIN NO. 07430284979<br></br>
-
 
5319
        Service Tax No:AAACM0294PST001<br></br><br></br><br></br>""", prologueStyle))
-
 
5320
    ############### ADDRESS TO BE DYNAMIC ##############################################
5318
    ############### ADDRESS TO BE DYNAMIC ##############################################
5321
    
5319
    
5322
    drawLine(Story, lineStyle)
5320
    drawLine(Story, lineStyle)
-
 
5321
    Story.append(Paragraph("{0:^39s}".format("*** ADVANCE RECEIPT ***").replace(" ", "&nbsp;"), textStyle))
-
 
5322
    drawLine(Story, lineStyle)
5323
    
5323
    
5324
    Story.append(Paragraph("{0:^39s}".format("DELIVERY ADDRESS").replace(" ", "&nbsp;"), textStyle))
5324
    Story.append(Paragraph("{0:^39s}".format("DELIVERY ADDRESS").replace(" ", "&nbsp;"), textStyle))
5325
    drawLine(Story, lineStyle)
5325
    drawLine(Story, lineStyle)
5326
    Story.append(Paragraph(customerAdd1, textStyle))
5326
    Story.append(Paragraph(customerAdd1, textStyle))
5327
    if len(customerAdd2) > 0:
5327
    if len(customerAdd2) > 0:
Line 5331... Line 5331...
5331
    Story.append(Paragraph(customerState + " - " + customerPin, textStyle))
5331
    Story.append(Paragraph(customerState + " - " + customerPin, textStyle))
5332
    drawLine(Story, lineStyle)
5332
    drawLine(Story, lineStyle)
5333
    
5333
    
5334
    Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", "&nbsp;"), textStyle))
5334
    Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", "&nbsp;"), textStyle))
5335
    Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", "&nbsp;"), textStyle))
5335
    Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", "&nbsp;"), textStyle))
5336
    Story.append(Paragraph("{0:<15s}{1:  %d/%m/%Y}".format("EXP DELIVERY:", delivery).replace(" ", "&nbsp;"), textStyle))
5336
    Story.append(Paragraph("{0:<20s}{1:  %d/%m/%Y}".format("EXPECTED DELIVERY:", delivery).replace(" ", "&nbsp;"), textStyle))
5337
    Story.append(Paragraph("{0:<15s}{1:<25s}".format("PAYMENT MODE:", mode).replace(" ", "&nbsp;"), textStyle))
-
 
5338
    
5337
    
5339
    drawLine(Story, lineStyle)
5338
    drawLine(Story, lineStyle)
5340
    Story.append(Paragraph("{0:^39s}".format("PRODUCT NAME").replace(" ", "&nbsp;"), textStyle))
5339
    Story.append(Paragraph("{0:^39s}".format("PRODUCT NAME").replace(" ", "&nbsp;"), textStyle))
5341
    drawLine(Story, lineStyle)
5340
    drawLine(Story, lineStyle)
5342
    Story.append(Paragraph("{0:<39s}".format(product).replace(" ", "&nbsp;"), textStyle))
5341
    Story.append(Paragraph("{0:<39s}".format(product).replace(" ", "&nbsp;"), textStyle))
5343
    drawLine(Story, lineStyle)
5342
    drawLine(Story, lineStyle)
5344
    
5343
    
5345
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("TOTAL PRICE: ", totalAmount).replace(' ', '&nbsp;'),textStyle))
5344
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("TOTAL PRICE: ", totalAmount).replace(' ', '&nbsp;'),textStyle))
5346
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', '&nbsp;'),textStyle))
5345
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', '&nbsp;'),textStyle))
-
 
5346
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("IN CASH: ", inCash).replace(' ', '&nbsp;'),textStyle))
-
 
5347
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BY CARD: ", byCard).replace(' ', '&nbsp;'),textStyle))
5347
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BALANCE TO BE PAID: ", (totalAmount - advanceAmount)).replace(' ', '&nbsp;'),textStyle))
5348
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BALANCE TO BE PAID: ", (totalAmount - advanceAmount)).replace(' ', '&nbsp;'),textStyle))
5348
    
5349
    
5349
    drawLine(Story, lineStyle)
5350
    drawLine(Story, lineStyle)
5350
    Story.append(Paragraph(('{0:<20s}{1:>19s}').format("Customer care : ", "0120-6744700").replace(' ', '&nbsp;'),textStyle))
-
 
5351
    drawLine(Story, lineStyle)
-
 
5352
    drawLine(Story, lineStyle)
-
 
5353
    
-
 
5354
    Story.append(Paragraph("Note:", textStyle))                                        
5351
    Story.append(Paragraph("Note:", textStyle))                                        
5355
    Story.append(Paragraph("* In case of cancellation of order on customer request, 10% of product amount subject to minimum Rs 500/- shall be deducted by Spice Retail Limited as cancellation charges. Customer shall provide original copy of 'Advance Receipt' to get the balance amount as refund",textStyle))                                        
5352
    Story.append(Paragraph("* In case of cancellation of order on customer request, 10% of product amount subject to minimum Rs 500/- shall be deducted by Spice Retail Limited as cancellation charges. Customer shall provide original copy of 'Advance Receipt' to get the balance amount as refund",textStyle))                                        
5356
    Story.append(Paragraph("* In case of cancellation of order other than customer request, original copy of 'Advance Receipt' shall be provided by customer to get the refund",textStyle))                                        
5353
    Story.append(Paragraph("* In case of cancellation of order other than customer request, original copy of 'Advance Receipt' shall be provided by customer to get the refund",textStyle))                                        
5357
    Story.append(Paragraph("* Balance amount as mentioned above to be paid at the time of delivery of product to courier agency. Refusal to accept the product delivered through courier shall be deemed as cancellation of order and cancellation charges shall become applicable.",textStyle))                                         
5354
    Story.append(Paragraph("* Balance amount as mentioned above to be paid at the time of delivery of product to courier agency. Refusal to accept the product delivered through courier shall be deemed as cancellation of order and cancellation charges shall become applicable.",textStyle))                                         
5358
    Story.append(Paragraph("* The product as mentioned above shall be made available to the customer, subject to its availability from the manufacturer",textStyle))                                        
5355
    Story.append(Paragraph("* The product as mentioned above shall be made available to the customer, subject to its availability from the manufacturer",textStyle))                                        
5359
 
-
 
-
 
5356
    drawLine(Story, lineStyle)
-
 
5357
    Story.append(Paragraph(('{0:<20s}{1:>19s}').format("Customer care : ", "0120-6744700").replace(' ', '&nbsp;'),textStyle))
-
 
5358
    drawLine(Story, lineStyle)
5360
    
5359
    
5361
    doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
5360
    doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
5362
 
5361
 
5363
    #start the construction of the pdf
5362
    #start the construction of the pdf
5364
    doc.build(Story)
5363
    doc.build(Story)
Line 5424... Line 5423...
5424
    allBankNames = []
5423
    allBankNames = []
5425
    edcBanks = EdcBank.query.all();
5424
    edcBanks = EdcBank.query.all();
5426
    for bank in edcBanks:
5425
    for bank in edcBanks:
5427
        allBankNames.append(bank.name)
5426
        allBankNames.append(bank.name)
5428
    return allBankNames
5427
    return allBankNames
-
 
5428
 
-
 
5429
def save_refund_amounts_for_store_order(orderId, storeId, cashRefundAmount, cardRefundAmount):
-
 
5430
    storeOrderDetail = StoreOrderDetail.query.filter(StoreOrderDetail.orderId == orderId).filter(StoreOrderDetail.storeId == storeId).first()
-
 
5431
    if storeOrderDetail:
-
 
5432
        storeOrderDetail.cashRefundAmount = cashRefundAmount
-
 
5433
        storeOrderDetail.cardRefundAmount = cardRefundAmount
-
 
5434
        session.commit()
-
 
5435
        return True
-
 
5436
    else:
-
 
5437
        return False
-
 
5438
    
5429
    
5439
    
5430
if __name__ == '__main__':
5440
if __name__ == '__main__':
5431
    print 'helllo'
-
 
5432
5441
    print datetime.datetime.now()
-
 
5442
    print datetime.datetime.now().date()
-
 
5443
    DataService.initialize('transaction', 'localhost')
-
 
5444
    order = Order.get_by(id = 308405)
-
 
5445
    print order.created_timestamp.date()
-
 
5446
    if order.created_timestamp.date() == datetime.datetime.now().date():
-
 
5447
        print "BOOO-YEAH" 
-
 
5448
5433
5449