penambahan kembali nop_to_id

1 parent 3d2826b1
......@@ -106,7 +106,7 @@ class BaseFixLength(SetFixLength):
class FixDati2(BaseFixLength):
def get_structure(self):
return DATI2
def kd_dati2(self):
return self["kd_propinsi"]+'.'+self['kd_dati2']
......@@ -114,12 +114,15 @@ class FixDati2(BaseFixLength):
class FixKecamatan(FixDati2):
def get_structure(self):
return KECAMATAN
def kd_kecamatan(self):
return super().kd_dati2+'.'+self['kd_kecamatan']
class FixKelurahan(FixKecamatan):
def get_structure(self):
return KELURAHAN
def kd_kelurahan(self):
return super().kd_kecamatan+'.'+self['kd_kelurahan']
......@@ -127,6 +130,7 @@ class FixKelurahan(FixKecamatan):
class FixBlok(FixKelurahan):
def get_structure(self):
return BLOK
def kd_blok(self):
return super().kd_kelurahan+'.'+self['kd_blok']
......@@ -134,6 +138,7 @@ class FixBlok(FixKelurahan):
class FixKantor(BaseFixLength):
def get_structure(self):
return KANTOR
def kd_kantor(self):
return self['kd_kanwil']+'.'+self['kd_kantor']
......@@ -141,24 +146,26 @@ class FixKantor(BaseFixLength):
class FixBank(FixKantor):
def get_structure(self):
return BANK
def kd_bank(self):
return self['kd_kanwil']+'.'+self['kd_kantor']+'.'+self['kd_tp']
class FixBankSismiop(FixKantor):
def get_structure(self):
return BANK_SISMIOP
def kd_bank(self):
return self['kd_kanwil_bank']+'.'+self['kd_kppbb_bank']+'.'+self['kd_bank_tunggal']+'.'+self['kd_bank_persepsi']+'.'+self['kd_tp']
class FixNop(FixBlok):
def get_structure(self):
return NOP
def nop(self):
return ".".join([self.kd_blok(), self["no_urut"], self["kd_jns_op"]])
def get_formatted(self):
s = ''
for name, size, typ in self.struct:
......@@ -176,6 +183,7 @@ class FixNop(FixBlok):
class FixSppt(FixNop):
def get_structure(self):
return SPPT
def sppt(self):
return self.nop() + "." + self['thn_pajak_sppt']
......@@ -251,7 +259,7 @@ class FixBerkas(BaseFixLength):
def get_nopel_det(self):
return get_value(self, NOPELDET)
def get_tahun_pajak(self):
return self['thn_pajak_sppt']
......@@ -319,39 +327,44 @@ def nop_formatted(row):
row.kd_kelurahan, row.kd_blok, row.no_urut, row.kd_jns_op)
# def nop_to_id(row):
# if type(row) in (StringType, UnicodeType):
# row = FixNop(row)
# return "%s%s%s%s%s%s%s" % (row.kd_propinsi, row.kd_dati2, row.kd_kecamatan,
# row.kd_kelurahan, row.kd_blok, row.no_urut,
# row.kd_jns_op)
def query_nop(table): #digunakan oleh e2apbb
return func.concat(table.kd_propinsi,
func.concat(
'.',
func.concat(
table.kd_dati2,
func.concat(
'-',
func.concat(
table.kd_kecamatan,
func.concat(
'.',
func.concat(
table.kd_kelurahan,
func.concat(
'-',
func.concat(
table.kd_blok,
func.concat(
'.',
func.concat(
table.no_urut,
func.concat(
'-',
table.kd_jns_op))))))))))))
def nop_to_id(row):
if type(row) == str:
row = FixNop(row)
elif type(row) != dict:
row = dict(row.__dict__)
row.pop('_sa_instance_state', None)
return "%s%s%s%s%s%s%s" % (
row.get("kd_propinsi"), row.get("kd_dati2"),
row.get("kd_kecamatan"), row.get("kd_kelurahan"),
row.get("kd_blok"), row.get("no_urut"),
row.get("kd_jns_op"))
def column_concat(*args):
cols = []
for arg in args:
if type(arg) == list:
# for a in arg:
cols.extend(arg)
else:
cols.append(arg)
if not cols:
return ''
elif len(cols) == 1:
return cols[0]
# saat ini menggunakan recursive spertinya ada syntax pythonic
# func.concat(cols[i], for col in cols)
# lambda_concat = lambda args: func.concat(x, y) for x, y in zip(args[:-1], args[1:])
return func.concat(cols[0], column_concat(*cols[1:])) # pylint: disable=not-callable
def query_nop(table): # digunakan oleh e2apbb
return column_concat(table.kd_propinsi, '.', table.kd_dati2, '-',
table.kd_kecamatan, '.', table.kd_kelurahan, '-',
table.kd_blok, '.', table.no_urut, '-', table.kd_jns_op)
# JEnis REstitusi Kompensasi
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!