| Line 846... |
Line 846... |
| 846 |
def get_valid_order_count():
|
846 |
def get_valid_order_count():
|
| 847 |
'''
|
847 |
'''
|
| 848 |
Returns the number of orders which we processed. The reshipped orders are not
|
848 |
Returns the number of orders which we processed. The reshipped orders are not
|
| 849 |
counted since there'll always be a new compensating order present.
|
849 |
counted since there'll always be a new compensating order present.
|
| 850 |
'''
|
850 |
'''
|
| 851 |
return Order.query.filter(Order.status >= OrderStatus.SUBMITTED_FOR_PROCESSING).filter(not_(Order.status.in_((OrderStatus.RTO_RESHIPPED, OrderStatus.DOA_INVALID_RESHIPPED, OrderStatus.DOA_VALID_RESHIPPED, OrderStatus.CANCELED)))).count()
|
851 |
return Order.query.filter(Order.status >= OrderStatus.SUBMITTED_FOR_PROCESSING).filter(not_(Order.status.in_((OrderStatus.RTO_RESHIPPED, OrderStatus.DOA_INVALID_RESHIPPED, OrderStatus.DOA_VALID_RESHIPPED, OrderStatus.COD_VERIFICATION_FAILED)))).count()
|
| 852 |
|
852 |
|
| 853 |
def get_cust_count_with_successful_txn():
|
853 |
def get_cust_count_with_successful_txn():
|
| 854 |
'''
|
854 |
'''
|
| 855 |
Returns the number of distinct customers who have done successful transactions.
|
855 |
Returns the number of distinct customers who have done successful transactions.
|
| 856 |
It uses the sqlalchemy func module to construct an efficient query.
|
856 |
It uses the sqlalchemy func module to construct an efficient query.
|
| Line 1322... |
Line 1322... |
| 1322 |
OrderStatus.DOA_LOST_IN_TRANSIT : OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT,
|
1322 |
OrderStatus.DOA_LOST_IN_TRANSIT : OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT,
|
| 1323 |
OrderStatus.RET_PRODUCT_UNUSABLE : OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED,
|
1323 |
OrderStatus.RET_PRODUCT_UNUSABLE : OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED,
|
| 1324 |
OrderStatus.RET_PRODUCT_USABLE : OrderStatus.RET_PRODUCT_USABLE_REFUNDED,
|
1324 |
OrderStatus.RET_PRODUCT_USABLE : OrderStatus.RET_PRODUCT_USABLE_REFUNDED,
|
| 1325 |
OrderStatus.RET_RECEIVED_DAMAGED : OrderStatus.RET_REFUNDED_RCVD_DAMAGED,
|
1325 |
OrderStatus.RET_RECEIVED_DAMAGED : OrderStatus.RET_REFUNDED_RCVD_DAMAGED,
|
| 1326 |
OrderStatus.RET_LOST_IN_TRANSIT : OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT,
|
1326 |
OrderStatus.RET_LOST_IN_TRANSIT : OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT,
|
| 1327 |
OrderStatus.COD_VERIFICATION_PENDING : OrderStatus.CANCELED,
|
1327 |
OrderStatus.COD_VERIFICATION_PENDING : OrderStatus.COD_VERIFICATION_FAILED,
|
| 1328 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.CANCELED,
|
1328 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1329 |
OrderStatus.INVENTORY_LOW : OrderStatus.CANCELED,
|
1329 |
OrderStatus.INVENTORY_LOW : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1330 |
OrderStatus.LOW_INV_PO_RAISED : OrderStatus.CANCELED,
|
1330 |
OrderStatus.LOW_INV_PO_RAISED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1331 |
OrderStatus.LOW_INV_REVERSAL_IN_PROCESS : OrderStatus.CANCELED,
|
1331 |
OrderStatus.LOW_INV_REVERSAL_IN_PROCESS : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1332 |
OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT : OrderStatus.CANCELED,
|
1332 |
OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1333 |
OrderStatus.ACCEPTED : OrderStatus.CANCELED,
|
1333 |
OrderStatus.ACCEPTED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1334 |
OrderStatus.BILLED : OrderStatus.CANCELED,
|
1334 |
OrderStatus.BILLED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1335 |
OrderStatus.CANCEL_REQUEST_CONFIRMED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST
|
1335 |
OrderStatus.CANCEL_REQUEST_CONFIRMED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST
|
| 1336 |
}
|
1336 |
}
|
| 1337 |
if order.status not in status_transition.keys():
|
1337 |
if order.status not in status_transition.keys():
|
| 1338 |
raise TransactionServiceException(114, "This order can't be refunded")
|
1338 |
raise TransactionServiceException(114, "This order can't be refunded")
|
| 1339 |
|
1339 |
|
| Line 1375... |
Line 1375... |
| 1375 |
OrderStatus.DOA_LOST_IN_TRANSIT : OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT,
|
1375 |
OrderStatus.DOA_LOST_IN_TRANSIT : OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT,
|
| 1376 |
OrderStatus.RET_PRODUCT_UNUSABLE : OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED,
|
1376 |
OrderStatus.RET_PRODUCT_UNUSABLE : OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED,
|
| 1377 |
OrderStatus.RET_PRODUCT_USABLE : OrderStatus.RET_PRODUCT_USABLE_REFUNDED,
|
1377 |
OrderStatus.RET_PRODUCT_USABLE : OrderStatus.RET_PRODUCT_USABLE_REFUNDED,
|
| 1378 |
OrderStatus.RET_RECEIVED_DAMAGED : OrderStatus.RET_REFUNDED_RCVD_DAMAGED,
|
1378 |
OrderStatus.RET_RECEIVED_DAMAGED : OrderStatus.RET_REFUNDED_RCVD_DAMAGED,
|
| 1379 |
OrderStatus.RET_LOST_IN_TRANSIT : OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT,
|
1379 |
OrderStatus.RET_LOST_IN_TRANSIT : OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT,
|
| 1380 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.REFUNDED,
|
1380 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1381 |
OrderStatus.INVENTORY_LOW : OrderStatus.REFUNDED,
|
1381 |
OrderStatus.INVENTORY_LOW : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1382 |
OrderStatus.LOW_INV_PO_RAISED : OrderStatus.REFUNDED,
|
1382 |
OrderStatus.LOW_INV_PO_RAISED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1383 |
OrderStatus.LOW_INV_REVERSAL_IN_PROCESS : OrderStatus.REFUNDED,
|
1383 |
OrderStatus.LOW_INV_REVERSAL_IN_PROCESS : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1384 |
OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT : OrderStatus.REFUNDED,
|
1384 |
OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1385 |
OrderStatus.ACCEPTED : OrderStatus.REFUNDED,
|
1385 |
OrderStatus.ACCEPTED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1386 |
OrderStatus.BILLED : OrderStatus.REFUNDED,
|
1386 |
OrderStatus.BILLED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| 1387 |
OrderStatus.CANCEL_REQUEST_CONFIRMED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST,
|
1387 |
OrderStatus.CANCEL_REQUEST_CONFIRMED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST,
|
| 1388 |
OrderStatus.PAYMENT_FLAGGED : OrderStatus.PAYMENT_FLAGGED_DENIED
|
1388 |
OrderStatus.PAYMENT_FLAGGED : OrderStatus.PAYMENT_FLAGGED_DENIED
|
| 1389 |
}
|
1389 |
}
|
| 1390 |
if order.status not in status_transition.keys():
|
1390 |
if order.status not in status_transition.keys():
|
| 1391 |
raise TransactionServiceException(114, "This order can't be refunded")
|
1391 |
raise TransactionServiceException(114, "This order can't be refunded")
|