Commit 6bc5cb93 by Owo Sugiana

Bug fixed belum rollback usai deteksi JSON Log

1 parent f15b1dd1
......@@ -82,16 +82,13 @@ class AlternativePayment(PaymentMixin, Base):
dict(schema='public'))
class IsoPayment(Base):
class IsoPaymentMixin:
__tablename__ = 'bphtb_payment'
__table_args__ = dict(schema='bphtb')
id = Column(Integer, ForeignKey(Payment.id), primary_key=True)
tgl = Column(DateTime(timezone=True), nullable=False)
iso_request = Column(String(1024), nullable=False)
transmission = Column(DateTime(timezone=True), nullable=False)
settlement = Column(Date, nullable=False)
stan = Column(Integer, nullable=False)
invoice_id = Column(Integer, ForeignKey(Invoice.id), nullable=False)
invoice_no = Column(String(32), nullable=False)
ntb = Column(String(32), nullable=False)
ntp = Column(String(32), nullable=False, unique=True)
......@@ -99,6 +96,22 @@ class IsoPayment(Base):
channel_id = Column(Integer)
bank_ip = Column(String(15), nullable=False)
@declared_attr
def id(self):
return Column(Integer, ForeignKey(Payment.id), primary_key=True)
@declared_attr
def invoice_id(self):
return Column(Integer, ForeignKey(Invoice.id), nullable=False)
class IsoPayment(IsoPaymentMixin, Base):
__table_args__ = dict(schema='bphtb')
class AlternativeIsoPayment(IsoPaymentMixin, Base):
pass
class SukabumiKotaLog(Base):
__tablename__ = 'iso_log'
......@@ -133,6 +146,7 @@ class App(BaseApp):
return
self.base_q_func = self.prod_session.query(func.count())
self.is_sukabumi_kota = False
self.is_cartenz = False
try:
self.set_default_models()
except (ProgrammingError, OperationalError, DatabaseError):
......@@ -172,6 +186,7 @@ class App(BaseApp):
self.h2h_session.query(JsonLog.bits).first()
self.is_json_log = True
except ProgrammingError:
self.h2h_session.rollback()
self.is_json_log = False
self.base_q_log = self.get_base_q_log()
try:
......@@ -180,6 +195,13 @@ class App(BaseApp):
self.h2h_session.rollback()
# Berarti Log ISO8583 masih di tabel versi 1
self.base_q_log = None
self.base_q_iso_payment = self.prod_session.query(IsoPayment)
try:
self.base_q_iso_payment.first()
except ProgrammingError:
self.prod_session.rollback()
self.base_q_iso_payment = self.prod_session.query(
AlternativeIsoPayment)
def set_default_models(self):
self.base_q_inv = self.prod_session.query(Invoice)
......@@ -288,7 +310,7 @@ class App(BaseApp):
return q.order_by(self.Payment.tanggal, self.Payment.jam)
def get_iso_v1(self, pay):
q = self.prod_session.query(IsoPayment).filter_by(id=pay.id)
q = self.base_q_iso_payment.filter_by(id=pay.id)
row = q.first()
if not row:
return
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!