Subversion Repositories SmartDukaan

Rev

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

Rev 20848 Rev 20873
Line 85... Line 85...
85
from shop2020.model.v1.order.impl.model.UserWalletHistory import \
85
from shop2020.model.v1.order.impl.model.UserWalletHistory import \
86
    UserWalletHistory
86
    UserWalletHistory
87
from shop2020.model.v1.user.impl.Converters import to_t_address
87
from shop2020.model.v1.user.impl.Converters import to_t_address
88
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
88
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
89
from shop2020.thriftpy.crm.ttypes import *
89
from shop2020.thriftpy.crm.ttypes import *
-
 
90
from shop2020.thriftpy.payments.ttypes import PaymentStatus
90
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
91
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
91
from shop2020.thriftpy.model.v1.catalog.ttypes import ItemType, ItemCondition
92
from shop2020.thriftpy.model.v1.catalog.ttypes import ItemType, ItemCondition
92
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
93
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
93
    InventoryServiceException, WarehouseType, InventoryType, VatType, ItemInventory
94
    InventoryServiceException, WarehouseType, InventoryType, VatType, ItemInventory
94
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
95
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
Line 187... Line 188...
187
 
188
 
188
creditorTicketSizeMap = {}
189
creditorTicketSizeMap = {}
189
creditorDueDateMap = {}
190
creditorDueDateMap = {}
190
 
191
 
191
stateIdMap = {}
192
stateIdMap = {}
-
 
193
 
-
 
194
gvGatewayId = 9
-
 
195
walletGatewayId = 8
-
 
196
 
192
def fetchStateMaster():
197
def fetchStateMaster():
193
    global stateIdMap
198
    global stateIdMap
194
    if stateIdMap:
199
    if stateIdMap:
195
        return stateIdMap
200
        return stateIdMap
196
    else:
201
    else:
Line 11163... Line 11168...
11163
        d_ShipmentLogisticsCostDetail.logisticsTransactionId = shipmentLogisticsCostDetail.logisticsTransactionId
11168
        d_ShipmentLogisticsCostDetail.logisticsTransactionId = shipmentLogisticsCostDetail.logisticsTransactionId
11164
        d_ShipmentLogisticsCostDetail.packageDimensions = shipmentLogisticsCostDetail.packageDimensions
11169
        d_ShipmentLogisticsCostDetail.packageDimensions = shipmentLogisticsCostDetail.packageDimensions
11165
    session.commit()
11170
    session.commit()
11166
 
11171
 
11167
 
11172
 
-
 
11173
def create_payment(userId, txnId, gatewayId):
-
 
11174
    total_payable_amount = calculate_payment_amount(txnId)
-
 
11175
    gv_amount = 0.0
-
 
11176
    wallet_amount = 0.0
-
 
11177
    transaction = Transaction.get_by(id=txnId)
-
 
11178
    for order in transaction.orders:
-
 
11179
        gv_amount = gv_amount + order.gvAmount
-
 
11180
        wallet_amount = wallet_amount + order.wallet_amount
-
 
11181
    payment_client = PaymentClient().get_client()
-
 
11182
    if gv_amount > 0:
-
 
11183
        paymentId = payment_client.createPayment(userId, gv_amount, gvGatewayId, txnId, False);
-
 
11184
        payment_client.updatePaymentDetails(paymentId, "", "", "SUCCESS", "Payment Received", "", "", "", "", PaymentStatus.SUCCESS, "", None);
-
 
11185
    if wallet_amount > 0:
-
 
11186
        paymentId = payment_client.createPayment(userId, wallet_amount, walletGatewayId, txnId, False);
-
 
11187
        payment_client.updatePaymentDetails(paymentId, "", "", "SUCCESS", "Payment Received", "", "", "", "", PaymentStatus.SUCCESS, "", None);
-
 
11188
    if total_payable_amount > 0:
-
 
11189
        paymentId = payment_client.createPayment(userId, total_payable_amount, gatewayId, txnId, False);
-
 
11190
    return paymentId
-
 
11191
    
-
 
11192
 
-
 
11193
def calculate_payment_amount(txnId):
-
 
11194
    transaction = Transaction.get_by(id=txnId)
-
 
11195
    miscCharges = MiscCharges.get_by(transaction_id = transaction.id)
-
 
11196
    total_amount = 0.0
-
 
11197
    for order in transaction.orders:
-
 
11198
        total_amount = total_amount + order.net_payable_amount
-
 
11199
    if miscCharges and miscCharges.get(1) is not None:
-
 
11200
        total_amount = total_amount + miscCharges.get(1)
-
 
11201
    return total_amount
-
 
11202
 
-
 
11203
 
11168
 
11204
 
11169
if __name__ == '__main__':
11205
if __name__ == '__main__':
11170
    pass
11206
    pass
11171
#    ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
11207
#    ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
11172
#                 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,
11208
#                 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,