Subversion Repositories SmartDukaan

Rev

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

Rev 5488 Rev 5508
Line 17... Line 17...
17
from shop2020.clients.WarehouseClient import WarehouseClient
17
from shop2020.clients.WarehouseClient import WarehouseClient
18
from shop2020.model.v1 import order
18
from shop2020.model.v1 import order
19
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
19
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
20
    Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
20
    Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
21
    OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
21
    OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
22
    CodVerificationAgent
22
    CodVerificationAgent, RechargeVoucherTracker
23
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
23
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
24
from shop2020.thriftpy.generic.ttypes import ExceptionType
24
from shop2020.thriftpy.generic.ttypes import ExceptionType
25
from shop2020.thriftpy.logistics.ttypes import DeliveryType
25
from shop2020.thriftpy.logistics.ttypes import DeliveryType
26
from shop2020.thriftpy.model.v1.catalog.ttypes import BillingType, \
26
from shop2020.thriftpy.model.v1.catalog.ttypes import BillingType, \
27
    InventoryServiceException, WarehouseType, ItemType, InventoryType
27
    InventoryServiceException, WarehouseType, ItemType, InventoryType
Line 42... Line 42...
42
import logging
42
import logging
43
import os
43
import os
44
import sys
44
import sys
45
import time
45
import time
46
import traceback
46
import traceback
-
 
47
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
47
logging.basicConfig(level=logging.DEBUG)
48
logging.basicConfig(level=logging.DEBUG)
48
 
49
 
49
 
50
 
50
PREPAID_SHIPPING_CUTOFF_TIME = 15
51
PREPAID_SHIPPING_CUTOFF_TIME = 15
51
COD_SHIPPING_CUTOFF_TIME = 12
52
COD_SHIPPING_CUTOFF_TIME = 12
Line 231... Line 232...
231
                
232
                
232
            if selfPickup:
233
            if selfPickup:
233
                order.logistics_provider_id = 4
234
                order.logistics_provider_id = 4
234
                order.airwaybill_no = 'Self Pickup'
235
                order.airwaybill_no = 'Self Pickup'
235
                order.tracking_id = order.airwaybill_no
236
                order.tracking_id = order.airwaybill_no
236
                
237
            
-
 
238
            voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
-
 
239
            if voucherAmount:
-
 
240
                __create_recharge_voucher_tracker()
-
 
241
                                
237
    elif new_status == TransactionStatus.COD_IN_PROCESS:
242
    elif new_status == TransactionStatus.COD_IN_PROCESS:
238
        for order in transaction.orders:
243
        for order in transaction.orders:
239
            order.status = OrderStatus.COD_VERIFICATION_PENDING
244
            order.status = OrderStatus.COD_VERIFICATION_PENDING
240
            order.statusDescription = "Verification Pending"
245
            order.statusDescription = "Verification Pending"
241
            order.cod = True
246
            order.cod = True
Line 265... Line 270...
265
            try:
270
            try:
266
                item_pricing = catalog_client.getItemPricing(item_id, -1)
271
                item_pricing = catalog_client.getItemPricing(item_id, -1)
267
                order.lineitems[0].transfer_price = item_pricing.transferPrice        
272
                order.lineitems[0].transfer_price = item_pricing.transferPrice        
268
            except:
273
            except:
269
                print "Not able to get transfer price. Skipping"
274
                print "Not able to get transfer price. Skipping"
-
 
275
            
-
 
276
            voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
-
 
277
            if voucherAmount:
-
 
278
                __create_recharge_voucher_tracker()
270
    session.commit()
279
    session.commit()
271
 
280
 
272
    try:
281
    try:
273
        if new_status == TransactionStatus.COD_IN_PROCESS:
282
        if new_status == TransactionStatus.COD_IN_PROCESS:
274
            transaction_requiring_extra_processing = TransactionRequiringExtraProcessing()
283
            transaction_requiring_extra_processing = TransactionRequiringExtraProcessing()
Line 283... Line 292...
283
    except Exception as e:
292
    except Exception as e:
284
        print "Error inserting transaction Id: " + str(transaction_id) + " due to " + str(e)
293
        print "Error inserting transaction Id: " + str(transaction_id) + " due to " + str(e)
285
 
294
 
286
    return True
295
    return True
287
 
296
 
-
 
297
def __create_recharge_voucher_tracker(amount):
-
 
298
    rvt = RechargeVoucherTracker()
-
 
299
    rvt.order = order
-
 
300
    rvt.amount = amount
-
 
301
    rvt.voucherIssued = False
-
 
302
    rvt.voucherType = VoucherType.SPICEDECK_MOBILE
-
 
303
            
288
def __get_holidays(start_time=0L, to_time=-1L):
304
def __get_holidays(start_time=0L, to_time=-1L):
289
    '''
305
    '''
290
    Get the list of all public holidays since start time including the
306
    Get the list of all public holidays since start time including the
291
    day of start time if it's a holiday
307
    day of start time if it's a holiday
292
    '''
308
    '''