Skip to content

Commit

Permalink
Merge fda2907 into 7238c0d
Browse files Browse the repository at this point in the history
  • Loading branch information
xzzy authored Mar 5, 2021
2 parents 7238c0d + fda2907 commit a7862d4
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from django.core.management.base import BaseCommand
from django.utils import timezone
from ledger.payments.bpoint.models import BpointTransaction, BpointToken
#from ledger.payments.models import Invoice,OracleInterface,CashTransaction
#from oscar.apps.order.models import Order
#from ledger.basket.models import Basket
from django.conf import settings
from datetime import timedelta, datetime
from ledger.payments.bpoint.facade import Facade
from ledger.emails.emails import sendHtmlEmail

class Command(BaseCommand):
help = 'Check for payment which have been completed but are missing a booking.'

def add_arguments(self, parser):
yesterday = datetime.today() - timedelta(days=1)
settlement_date_search = yesterday.strftime("%Y%m%d")
parser.add_argument('settlement_date', nargs='?', default=settlement_date_search)

def handle(self, *args, **options):
rows = []
#system = settings.PS_PAYMENT_SYSTEM_ID
#system = system.replace('S','0')
#rows = bpoint_integrity_checks(system,100,2)
SYSTEM_ID = ''
if settings.PS_PAYMENT_SYSTEM_ID:
SYSTEM_ID = settings.PS_PAYMENT_SYSTEM_ID.replace("S","0")

yesterday = datetime.today() - timedelta(days=1)
settlement_date_search = yesterday.strftime("%Y%m%d")
if options['settlement_date']:
settlement_date_search = options['settlement_date']
print ("Checking :"+settlement_date_search)
bpoint_facade = Facade()
b = bpoint_facade.fetch_transaction_by_settlement_date(settlement_date_search)
for c in b:
if c.bank_response_code == '00':
amount = str(c.amount)[:-2]+'.'+str(c.amount)[-2:]
rows.append({'txn_number': c.txn_number,'crn1': c.crn1,'processed_date_time': c.processed_date_time, 'settlement_date': c.settlement_date, 'action': c.action, 'amount': amount})
if (len(rows)) > 0:
print ("Sending Report")
context = {
'settlement_date' : settlement_date_search,
'rows' : rows
}
email_list = []
for email_to in settings.NOTIFICATION_EMAIL.split(","):
email_list.append(email_to)
sendHtmlEmail(tuple(email_list),"[LEDGER] Bpoint Settlement Report (from payment gateway) "+SYSTEM_ID,context,'email/missing_payments.html',None,None,settings.EMAIL_FROM,'system-oim',attachments=None)

0 comments on commit a7862d4

Please sign in to comment.