Subversion Repositories SmartDukaan

Rev

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

Rev 19930 Rev 19950
Line 31... Line 31...
31
from shop2020.clients.UserClient import UserClient
31
from shop2020.clients.UserClient import UserClient
32
from shop2020.clients.WarehouseClient import WarehouseClient
32
from shop2020.clients.WarehouseClient import WarehouseClient
33
from shop2020.config.client.ConfigClient import ConfigClient
33
from shop2020.config.client.ConfigClient import ConfigClient
34
from shop2020.model.v1 import order
34
from shop2020.model.v1 import order
35
from shop2020.model.v1.order.impl import DataService, RechargeService
35
from shop2020.model.v1.order.impl import DataService, RechargeService
36
from shop2020.model.v1.order.impl.Convertors import to_t_emi_scheme, to_t_order
36
from shop2020.model.v1.order.impl.Convertors import to_t_emi_scheme, to_t_order,\
-
 
37
    cutoff_date
37
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
38
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
38
    Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
39
    Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
39
    OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
40
    OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
40
    CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, MiscCharges, \
41
    CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, MiscCharges, \
41
    BlockedIpRange, DeniedIpAddress, InsuranceDetailForOrder, DocumentStore, \
42
    BlockedIpRange, DeniedIpAddress, InsuranceDetailForOrder, DocumentStore, \
Line 94... Line 95...
94
from string import Template
95
from string import Template
95
from suds.client import Client
96
from suds.client import Client
96
from textwrap import dedent
97
from textwrap import dedent
97
from xml.dom.minidom import parseString
98
from xml.dom.minidom import parseString
98
import base64
99
import base64
99
import base64
-
 
100
import datetime
100
import datetime
101
import httplib
101
import httplib
102
import logging
102
import logging
103
import os
103
import os
104
import re
104
import re
Line 266... Line 266...
266
        order.source =  OrderSource.WEBSITE
266
        order.source =  OrderSource.WEBSITE
267
    else:
267
    else:
268
        order.source = t_order.source
268
        order.source = t_order.source
269
    #Change this temporary
269
    #Change this temporary
270
    if t_order.orderType is None or t_order.orderType ==OrderType.B2C:
270
    if t_order.orderType is None or t_order.orderType ==OrderType.B2C:
271
        order.orderType = 0
271
        order.orderType = OrderType.B2C
272
    order.advanceAmount = t_order.advanceAmount
272
    order.advanceAmount = t_order.advanceAmount
273
    order.storeId = t_order.storeId
273
    order.storeId = t_order.storeId
274
    if t_order.productCondition:
274
    if t_order.productCondition:
275
        order.productCondition = t_order.productCondition
275
        order.productCondition = t_order.productCondition
276
    if t_order.dataProtectionInsurer:
276
    if t_order.dataProtectionInsurer:
Line 460... Line 460...
460
                order.statusDescription = "Submitted to warehouse"
460
                order.statusDescription = "Submitted to warehouse"
461
            elif new_status == TransactionStatus.FLAGGED:
461
            elif new_status == TransactionStatus.FLAGGED:
462
                order.status = OrderStatus.PAYMENT_FLAGGED
462
                order.status = OrderStatus.PAYMENT_FLAGGED
463
                order.statusDescription = "Payment flagged by gateway"
463
                order.statusDescription = "Payment flagged by gateway"
464
            order.cod = False
464
            order.cod = False
-
 
465
            #Order type cant be changed during authorization
-
 
466
            #if orderType is not None:
465
            order.orderType = orderType
467
            #    order.orderType = orderType
466
            #After we got payment success, we will set logistics info also 
468
            #After we got payment success, we will set logistics info also 
467
            logistics_client = LogisticsClient().get_client()
469
            logistics_client = LogisticsClient().get_client()
468
            #FIXME line item is only one now. If multiple will come, need to fix.
470
            #FIXME line item is only one now. If multiple will come, need to fix.
469
            item_id = order.lineitems[0].item_id
471
            item_id = order.lineitems[0].item_id
470
            if pickUp == PickUpType.RUNNER or pickUp == PickUpType.SELF or order.source!=OrderSource.WEBSITE:
472
            if pickUp == PickUpType.RUNNER or pickUp == PickUpType.SELF or order.source!=OrderSource.WEBSITE:
Line 675... Line 677...
675
        subOrderAmountsMap = {}
677
        subOrderAmountsMap = {}
676
        for order in transaction.orders:
678
        for order in transaction.orders:
677
            order.status = OrderStatus.COD_VERIFICATION_PENDING
679
            order.status = OrderStatus.COD_VERIFICATION_PENDING
678
            order.statusDescription = "Verification Pending"
680
            order.statusDescription = "Verification Pending"
679
            order.cod = True
681
            order.cod = True
-
 
682
            #OrderType cant be changed
680
            order.orderType = orderType
683
            #order.orderType = orderType
681
            #After we got payment success, we will set logistics info also 
684
            #After we got payment success, we will set logistics info also 
682
            logistics_client = LogisticsClient().get_client()
685
            logistics_client = LogisticsClient().get_client()
683
            #FIXME line item is only one now. If multiple will come, need to fix.
686
            #FIXME line item is only one now. If multiple will come, need to fix.
684
            item_id = order.lineitems[0].item_id
687
            item_id = order.lineitems[0].item_id
685
            if order.pickupStoreId:
688
            if order.pickupStoreId:
Line 2391... Line 2394...
2391
        if singleInvoiceAttr:
2394
        if singleInvoiceAttr:
2392
            if singleInvoiceAttr.value == "true":
2395
            if singleInvoiceAttr.value == "true":
2393
                session.commit()
2396
                session.commit()
2394
                return True
2397
                return True
2395
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
2398
        if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
-
 
2399
            #as of now only company 1 - SORPL, 3-New company is operating and cutoff config will decide the company to be used to bill
-
 
2400
            #until further change - Amit Gupta
-
 
2401
            companyId = 1
-
 
2402
            if cutoff_date <= datetime.datetime.now():
-
 
2403
                companyId = 3
2396
            order.invoice_number = get_next_invoice_counter(order.orderType, whStateId)
2404
            order.invoice_number = get_next_invoice_counter(companyId, order.orderType, whStateId)
2397
        session.commit()
2405
        session.commit()
2398
        return True
2406
        return True
2399
    else:
2407
    else:
2400
        return False
2408
        return False
2401
 
2409
 
Line 3187... Line 3195...
3187
    entity_id = InvoiceIDGenerator.query.filter(InvoiceIDGenerator.orderType == orderType).with_lockmode("update").one()
3195
    entity_id = InvoiceIDGenerator.query.filter(InvoiceIDGenerator.orderType == orderType).with_lockmode("update").one()
3188
    invoice_number = entity_id.id + 1
3196
    invoice_number = entity_id.id + 1
3189
    entity_id.id = invoice_number
3197
    entity_id.id = invoice_number
3190
    return invoice_number
3198
    return invoice_number
3191
 
3199
 
3192
def get_next_invoice_counter(orderType, stateId):
3200
def get_next_invoice_counter(companyId, orderType, stateId):
3193
    if OrderType.B2Cbulk == orderType:
3201
    if OrderType.B2Cbulk == orderType:
3194
        orderType = OrderType.B2C
3202
        orderType = OrderType.B2C
3195
    entity_id = InvoiceCounterGenerator.query.filter(InvoiceCounterGenerator.orderType == orderType).filter(InvoiceCounterGenerator.stateId == stateId).with_lockmode("update").one()
3203
    entity_id = InvoiceCounterGenerator.query.filter(InvoiceCounterGenerator.orderType == orderType).filter(InvoiceCounterGenerator.stateId == stateId).filter(InvoiceCounterGenerator.companyId==companyId).with_lockmode("update").one()
3196
    invoice_number = entity_id.id + 1
3204
    invoice_number = entity_id.id + 1
3197
    entity_id.id = invoice_number 
3205
    entity_id.id = invoice_number 
3198
    ret_invoiceNo = entity_id.prefix + str(invoice_number) 
3206
    ret_invoiceNo = entity_id.prefix + str(invoice_number) 
3199
    return ret_invoiceNo
3207
    return ret_invoiceNo
3200
 
3208
 
Line 9319... Line 9327...
9319
    if warehouseDbConnection.open:
9327
    if warehouseDbConnection.open:
9320
        warehouseDbConnection.close()
9328
        warehouseDbConnection.close()
9321
    session.commit()
9329
    session.commit()
9322
    
9330
    
9323
    if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
9331
    if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
-
 
9332
        #as of now only company 1 - SORPL, 3-New company is operating and cutoff config will decide the company to be used to bill
-
 
9333
        #until further change - Amit Gupta
-
 
9334
        companyId = 1
-
 
9335
        if cutoff_date <= datetime.datetime.now():
-
 
9336
            companyId = 3
-
 
9337
        
9324
        invoiceNumber = get_next_invoice_counter(ordersList[0].orderType, whStateId)
9338
        invoiceNumber = get_next_invoice_counter(companyId, ordersList[0].orderType, whStateId)
-
 
9339
            
-
 
9340
            
9325
    
9341
    
9326
    invoiceTypeVal = 1
9342
    invoiceTypeVal = 1
9327
    if not individualInvoice:
9343
    if not individualInvoice:
9328
        invoiceTypeVal = 2
9344
        invoiceTypeVal = 2
9329
    if lineItemSize > 1:
9345
    if lineItemSize > 1:
Line 10957... Line 10973...
10957
    returnOrder = ReturnOrderInfo.get_by(id=returnOrderId)
10973
    returnOrder = ReturnOrderInfo.get_by(id=returnOrderId)
10958
    if returnOrder is None:
10974
    if returnOrder is None:
10959
        raise TransactionServiceException(101, "No Return Order is there with this Order Id")
10975
        raise TransactionServiceException(101, "No Return Order is there with this Order Id")
10960
    
10976
    
10961
if __name__ == '__main__':
10977
if __name__ == '__main__':
10962
    print get_orders_by_mobile_number("9650889334")
-
 
10963
10978
    print get_orders_by_mobile_number("9650889334")
-
 
10979