| Line 5... |
Line 5... |
| 5 |
|
5 |
|
| 6 |
@author: Chandranshu
|
6 |
@author: Chandranshu
|
| 7 |
'''
|
7 |
'''
|
| 8 |
|
8 |
|
| 9 |
from datetime import date, timedelta
|
9 |
from datetime import date, timedelta
|
| 10 |
from math import ceil
|
10 |
from decimal import Decimal
|
| 11 |
from elixir import *
|
11 |
from elixir import *
|
| - |
|
12 |
from math import ceil
|
| 12 |
from random import randrange
|
13 |
from random import randrange
|
| - |
|
14 |
from reportlab.lib.enums import TA_CENTER, TA_JUSTIFY
|
| - |
|
15 |
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
|
| 13 |
from reportlab.lib.units import inch
|
16 |
from reportlab.lib.units import inch
|
| 14 |
from reportlab.pdfgen.canvas import Canvas
|
17 |
from reportlab.pdfgen.canvas import Canvas
|
| 15 |
from reportlab.rl_config import defaultPageSize
|
- |
|
| 16 |
from reportlab.lib.enums import TA_CENTER,TA_JUSTIFY
|
- |
|
| 17 |
from reportlab.lib.styles import ParagraphStyle
|
- |
|
| 18 |
from reportlab.lib.styles import getSampleStyleSheet
|
- |
|
| 19 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image, \
|
18 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image, \
|
| 20 |
BaseDocTemplate, Frame, PageTemplate
|
19 |
BaseDocTemplate, Frame, PageTemplate
|
| - |
|
20 |
from reportlab.rl_config import defaultPageSize
|
| 21 |
from shop2020.clients.AlertClient import AlertClient
|
21 |
from shop2020.clients.AlertClient import AlertClient
|
| 22 |
from shop2020.clients.CatalogClient import CatalogClient
|
22 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 23 |
from shop2020.clients.HelperClient import HelperClient
|
23 |
from shop2020.clients.HelperClient import HelperClient
|
| 24 |
from shop2020.clients.InventoryClient import InventoryClient
|
24 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 25 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
25 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 26 |
from shop2020.clients.PaymentClient import PaymentClient
|
26 |
from shop2020.clients.PaymentClient import PaymentClient
|
| - |
|
27 |
from shop2020.clients.PromotionClient import PromotionClient
|
| 27 |
from shop2020.clients.UserClient import UserClient
|
28 |
from shop2020.clients.UserClient import UserClient
|
| 28 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
29 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
| - |
|
30 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 29 |
from shop2020.model.v1 import order
|
31 |
from shop2020.model.v1 import order
|
| 30 |
from shop2020.model.v1.order.impl import DataService, RechargeService
|
32 |
from shop2020.model.v1.order.impl import DataService, RechargeService
|
| - |
|
33 |
from shop2020.model.v1.order.impl.Convertors import to_t_emi_scheme
|
| 31 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
34 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
| 32 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
35 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
| 33 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
36 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
| 34 |
CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, \
|
37 |
CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, MiscCharges, \
|
| 35 |
MiscCharges, BlockedIpRange, DeniedIpAddress, InsuranceDetailForOrder,\
|
38 |
BlockedIpRange, DeniedIpAddress, InsuranceDetailForOrder, DocumentStore, \
|
| 36 |
DocumentStore, RechargeTransaction, HotspotStore, WalletForCompany,\
|
39 |
RechargeTransaction, HotspotStore, WalletForCompany, WalletHistoryForCompany, \
|
| 37 |
WalletHistoryForCompany, FRC, OperatorSeries
|
40 |
FRC, OperatorSeries
|
| - |
|
41 |
from shop2020.model.v1.order.impl.model.BaseOrder import BaseOrder
|
| - |
|
42 |
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
|
| 38 |
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
|
43 |
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
|
| 39 |
MobileRechargeOrder
|
44 |
MobileRechargeOrder
|
| - |
|
45 |
from shop2020.model.v1.order.impl.model.RechargeDenomination import \
|
| - |
|
46 |
RechargeDenomination
|
| - |
|
47 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
| - |
|
48 |
from shop2020.model.v1.order.impl.model.RechargePlan import RechargePlan
|
| 40 |
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
|
49 |
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
|
| - |
|
50 |
from shop2020.model.v1.order.impl.model.ServiceAvailability import \
|
| - |
|
51 |
ServiceAvailability
|
| - |
|
52 |
from shop2020.model.v1.order.impl.model.ServiceProvider import ServiceProvider
|
| - |
|
53 |
from shop2020.model.v1.order.impl.model.TelecomCircle import TelecomCircle
|
| - |
|
54 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
| - |
|
55 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import \
|
| - |
|
56 |
UserWalletHistory
|
| 41 |
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
|
57 |
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
|
| 42 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
|
58 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
|
| 43 |
from shop2020.thriftpy.model.v1.catalog.ttypes import ItemType
|
59 |
from shop2020.thriftpy.model.v1.catalog.ttypes import ItemType
|
| 44 |
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
|
60 |
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
|
| 45 |
InventoryServiceException, WarehouseType, InventoryType
|
61 |
InventoryServiceException, WarehouseType, InventoryType
|
| 46 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
62 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
| 47 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
63 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
| 48 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType,\
|
64 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
|
| 49 |
RechargeOrderStatus, RechargeType, RechargeStatistics, DeviceNumberInfo,\
|
65 |
RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod
|
| 50 |
EmiChargeType
|
- |
|
| 51 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
|
66 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
|
| 52 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
67 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
| 53 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
68 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
| 54 |
WarehouseServiceException
|
69 |
WarehouseServiceException
|
| 55 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
70 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
| 56 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
71 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
| 57 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
72 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
| 58 |
from sqlalchemy.sql import func
|
73 |
from sqlalchemy.sql import func
|
| 59 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct
|
74 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct, cast, \
|
| - |
|
75 |
between
|
| 60 |
from string import Template
|
76 |
from string import Template
|
| 61 |
from textwrap import dedent
|
77 |
from textwrap import dedent
|
| 62 |
import datetime
|
78 |
import datetime
|
| 63 |
import httplib
|
79 |
import httplib
|
| 64 |
import logging
|
80 |
import logging
|
| Line 66... |
Line 82... |
| 66 |
import sys
|
82 |
import sys
|
| 67 |
import time
|
83 |
import time
|
| 68 |
import traceback
|
84 |
import traceback
|
| 69 |
import urllib
|
85 |
import urllib
|
| 70 |
|
86 |
|
| 71 |
from shop2020.config.client.ConfigClient import ConfigClient
|
- |
|
| 72 |
from shop2020.model.v1.order.impl.model.RechargePlan import RechargePlan
|
- |
|
| 73 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
- |
|
| 74 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
- |
|
| 75 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import UserWalletHistory
|
- |
|
| 76 |
from shop2020.model.v1.order.impl.model.ServiceProvider import ServiceProvider
|
- |
|
| 77 |
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
|
- |
|
| 78 |
from shop2020.model.v1.order.impl.model.TelecomCircle import TelecomCircle
|
- |
|
| 79 |
from shop2020.model.v1.order.impl.model.ServiceAvailability import ServiceAvailability
|
- |
|
| 80 |
from shop2020.model.v1.order.impl.model.RechargeDenomination import RechargeDenomination
|
- |
|
| 81 |
from shop2020.clients.PromotionClient import PromotionClient
|
- |
|
| 82 |
from decimal import Decimal
|
- |
|
| 83 |
from shop2020.model.v1.order.impl.Convertors import to_t_emi_scheme
|
- |
|
| 84 |
from shop2020.model.v1.order.impl.model.BaseOrder import BaseOrder
|
- |
|
| 85 |
|
87 |
|
| 86 |
logging.basicConfig(level=logging.DEBUG)
|
88 |
logging.basicConfig(level=logging.DEBUG)
|
| 87 |
|
89 |
|
| 88 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
90 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
| 89 |
mail_user = 'cnc.center@shop2020.in'
|
91 |
mail_user = 'cnc.center@shop2020.in'
|
| Line 921... |
Line 923... |
| 921 |
order = get_order(order_id)
|
923 |
order = get_order(order_id)
|
| 922 |
if order == None or order.status not in [OrderStatus.SHIPPED_FROM_WH, OrderStatus.DELIVERED_AT_STORE, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.REACHED_DESTINATION_CITY, OrderStatus.FIRST_DELIVERY_ATTEMPT_MADE, OrderStatus.DELIVERY_SUCCESS]:
|
924 |
if order == None or order.status not in [OrderStatus.SHIPPED_FROM_WH, OrderStatus.DELIVERED_AT_STORE, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.REACHED_DESTINATION_CITY, OrderStatus.FIRST_DELIVERY_ATTEMPT_MADE, OrderStatus.DELIVERY_SUCCESS]:
|
| 923 |
return False
|
925 |
return False
|
| 924 |
order.status = OrderStatus.RTO_IN_TRANSIT
|
926 |
order.status = OrderStatus.RTO_IN_TRANSIT
|
| 925 |
order.delivery_timestamp = datetime.datetime.now()
|
927 |
order.delivery_timestamp = datetime.datetime.now()
|
| 926 |
order.statusDescription = "Order Returned to Origin:"
|
928 |
order.statusDescription = "Order Returned to Origin"
|
| 927 |
update_trust_level(order)
|
929 |
update_trust_level(order)
|
| 928 |
session.commit()
|
930 |
session.commit()
|
| 929 |
return True
|
931 |
return True
|
| 930 |
|
932 |
|
| 931 |
def get_order(order_id):
|
933 |
def get_order(order_id):
|
| Line 4522... |
Line 4524... |
| 4522 |
|
4524 |
|
| 4523 |
def get_recharge_transactions(storeId):
|
4525 |
def get_recharge_transactions(storeId):
|
| 4524 |
query = RechargeTransaction.query.filter(RechargeTransaction.storeId == storeId)
|
4526 |
query = RechargeTransaction.query.filter(RechargeTransaction.storeId == storeId)
|
| 4525 |
return query.all()
|
4527 |
return query.all()
|
| 4526 |
|
4528 |
|
| - |
|
4529 |
def get_recharge_trans(storeId, startdate,enddate, status):
|
| - |
|
4530 |
if startdate == -1:
|
| - |
|
4531 |
startdate = None
|
| - |
|
4532 |
if enddate == -1:
|
| - |
|
4533 |
enddate = None
|
| - |
|
4534 |
if storeId== 0:
|
| - |
|
4535 |
storeId = None
|
| - |
|
4536 |
if status == 0:
|
| - |
|
4537 |
status = None
|
| - |
|
4538 |
|
| - |
|
4539 |
query = RechargeTransaction.query
|
| - |
|
4540 |
if storeId is not None:
|
| - |
|
4541 |
query = query.filter(RechargeTransaction.storeId == storeId)
|
| - |
|
4542 |
if startdate is not None and enddate is not None:
|
| - |
|
4543 |
startdate = to_py_date(startdate).date()
|
| - |
|
4544 |
enddate = to_py_date(enddate).date()
|
| - |
|
4545 |
if startdate == enddate:
|
| - |
|
4546 |
query = query.filter(cast(RechargeTransaction.transactionTime, DATE) == enddate)
|
| - |
|
4547 |
elif enddate < startdate:
|
| - |
|
4548 |
query = query.filter(between(cast(RechargeTransaction.transactionTime, DATE), enddate, startdate))
|
| - |
|
4549 |
else:
|
| - |
|
4550 |
query = query.filter(between(cast(RechargeTransaction.transactionTime, DATE), startdate, enddate))
|
| - |
|
4551 |
elif startdate is not None:
|
| - |
|
4552 |
startdate = to_py_date(startdate).date()
|
| - |
|
4553 |
query = query.filter(cast(RechargeTransaction.transactionTime, DATE) >= startdate)
|
| - |
|
4554 |
elif enddate is not None:
|
| - |
|
4555 |
enddate = to_py_date(enddate).date()
|
| - |
|
4556 |
query = query.filter(cast(RechargeTransaction.transactionTime, DATE) <= enddate)
|
| - |
|
4557 |
if status is not None:
|
| - |
|
4558 |
query = query.filter(RechargeTransaction.status == status)
|
| - |
|
4559 |
|
| - |
|
4560 |
return query.all()
|
| - |
|
4561 |
|
| - |
|
4562 |
|
| - |
|
4563 |
|
| - |
|
4564 |
|
| 4527 |
def update_recharge_transaction_status(id, status, refundTime):
|
4565 |
def update_recharge_transaction_status(id, status, refundTime):
|
| 4528 |
rechargeTransaction = RechargeTransaction.get_by(id=id)
|
4566 |
rechargeTransaction = RechargeTransaction.get_by(id=id)
|
| 4529 |
if status == RechargeOrderStatus.RECHARGE_FAILED_REFUNDED:
|
4567 |
if status == RechargeOrderStatus.RECHARGE_FAILED_REFUNDED:
|
| 4530 |
rechargeTransaction.status = RechargeOrderStatus.RECHARGE_FAILED_REFUNDED
|
4568 |
rechargeTransaction.status = RechargeOrderStatus.RECHARGE_FAILED_REFUNDED
|
| 4531 |
rechargeTransaction.responseTime = refundTime
|
4569 |
rechargeTransaction.responseTime = refundTime
|
| Line 4674... |
Line 4712... |
| 4674 |
amount = recharge.amount
|
4712 |
amount = recharge.amount
|
| 4675 |
telNum = "+91 " + str(recharge.deviceNum)
|
4713 |
telNum = "+91 " + str(recharge.deviceNum)
|
| 4676 |
customerName = recharge.name
|
4714 |
customerName = recharge.name
|
| 4677 |
invNum = str(recharge.invoiceNumber)
|
4715 |
invNum = str(recharge.invoiceNumber)
|
| 4678 |
billingTime = recharge.responseTime
|
4716 |
billingTime = recharge.responseTime
|
| - |
|
4717 |
payMethod = recharge.payMethod
|
| 4679 |
return __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime)
|
4718 |
return __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime, payMethod)
|
| 4680 |
|
4719 |
|
| 4681 |
def __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime):
|
4720 |
def __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime, payMethod):
|
| 4682 |
PAGE_HEIGHT=defaultPageSize[1];
|
4721 |
PAGE_HEIGHT=defaultPageSize[1];
|
| 4683 |
styles = getSampleStyleSheet()
|
4722 |
styles = getSampleStyleSheet()
|
| 4684 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
4723 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
| 4685 |
styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
|
4724 |
styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
|
| 4686 |
styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
|
4725 |
styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
|
| Line 4710... |
Line 4749... |
| 4710 |
Story.append(Paragraph('{0:7s}{1:>11s}{2: %d/%m/%Y %H:%M:%S}'.format("INV NO:", invNum, billingTime).replace(" ", " "), textStyle))
|
4749 |
Story.append(Paragraph('{0:7s}{1:>11s}{2: %d/%m/%Y %H:%M:%S}'.format("INV NO:", invNum, billingTime).replace(" ", " "), textStyle))
|
| 4711 |
drawLine(Story, lineStyle)
|
4750 |
drawLine(Story, lineStyle)
|
| 4712 |
|
4751 |
|
| 4713 |
Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", " "), textStyle))
|
4752 |
Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", " "), textStyle))
|
| 4714 |
Story.append(Paragraph("{0:<9s}{1:<31s}".format("TEL NO.:", telNum).replace(" ", " "), textStyle))
|
4753 |
Story.append(Paragraph("{0:<9s}{1:<31s}".format("TEL NO.:", telNum).replace(" ", " "), textStyle))
|
| - |
|
4754 |
Story.append(Paragraph("{0:<9s}{1:<31s}".format("PAYMENT MODE:", PayMethod._VALUES_TO_NAMES[payMethod]).replace(" ", " "), textStyle))
|
| 4715 |
drawLine(Story, lineStyle)
|
4755 |
drawLine(Story, lineStyle)
|
| 4716 |
|
4756 |
|
| 4717 |
Story.append(Paragraph(('{0:<16s}{1:>13s}{2:11.2f}').format(operator, "RECHARGE", amount).replace(' ', ' '),textStyle))
|
4757 |
Story.append(Paragraph(('{0:<16s}{1:>13s}{2:11.2f}').format(operator, "RECHARGE", amount).replace(' ', ' '),textStyle))
|
| 4718 |
drawLine(Story, lineStyle)
|
4758 |
drawLine(Story, lineStyle)
|
| 4719 |
doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
|
4759 |
doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
|