Commit 7662cd4b by Owo Sugiana

Di Tangsel wajib ada kohir saat inquiry

1 parent 35836760
0.4.6 2022-12-13
----------------
- Tangerang Selatan mewajibkan keberadaan Kohir saat inquiry. Kalau tidak ada
record-nya maka invoice juga dianggap tidak ada.
0.4.5 2022-10-20
----------------
- Models khusus untuk Kabupaten Tangerang karena tabel kohir berbeda.
......
......@@ -50,6 +50,7 @@ class BaseInquiry:
invoice_id_structure = INVOICE_ID
def __init__(self, invoice_id, conf=dict()):
self.conf = conf
self.invoice = None
real_inv_id = self.get_invoice_id(invoice_id)
if len(real_inv_id) != self.get_invoice_id_length():
......@@ -58,17 +59,19 @@ class BaseInquiry:
self.invoice_id.set_raw(real_inv_id)
if not self.invoice_id['SptNo']:
return
self.conf = conf
Invoice = self.get_invoice_model()
DBSession = get_db_session()
q = DBSession.query(Invoice).filter_by(
tahun=self.invoice_id['Tahun'], sptno=self.invoice_id['SptNo'])
self.invoice = q.first()
self.invoice = self.get_invoice()
if not self.invoice:
return
if not self.is_available():
self.invoice = None
def get_invoice(self):
Invoice = self.get_invoice_model()
DBSession = get_db_session()
q = DBSession.query(Invoice).filter_by(
tahun=self.invoice_id['Tahun'], sptno=self.invoice_id['SptNo'])
return q.first()
def get_invoice_id_length(self):
length = 0
for name, size, typ in self.invoice_id_structure:
......
......@@ -21,7 +21,10 @@ from ..models.tangsel import (
SptType,
Kohir,
)
from .base import satu_kalimat
from .base import (
get_db_session,
satu_kalimat,
)
AWAL_DISC = date(2022, 8, 1)
......@@ -31,6 +34,13 @@ MASA_PAJAK = date(2022, 6, 30)
class Inquiry(BaseInquiry):
def get_invoice(self): # Override
DBSession = get_db_session()
q = DBSession.query(Invoice).filter_by(
tahun=self.invoice_id['Tahun'], sptno=self.invoice_id['SptNo'])
q = q.filter(Kohir.spt_id == Invoice.id)
return q.first()
def get_invoice_id(self, raw): # Override
if raw.find('367602') == 0: # 3676: Tangsel, 02: PAD
return raw[6:]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!