sspd_payment.py
3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from datetime import datetime
from sqlalchemy import (
Column, Integer, DateTime, ForeignKey, UniqueConstraint,
String, SmallInteger, BigInteger, Float, cast, func, Time)
from sqlalchemy.schema import FetchedValue
from sqlalchemy.orm import (relationship, backref)
from . import PAD_TABLE_ARGS, DefaultModel, Base
from . import (PjdlInvoice, DBSession)
class PjdlPayment(Base, DefaultModel):
__tablename__ = 'pad_sspd'
__table_args__ = (
UniqueConstraint('tahun', 'sspdno'),
PAD_TABLE_ARGS
)
id = Column(BigInteger, primary_key=True, index=True)
tahun = Column(Integer, nullable=False, index=True)
sspdno = Column(Integer, nullable=False, index=True)
sspdtgl = Column(DateTime, nullable=False, index=True)
spt_id = Column(ForeignKey(PjdlInvoice.id), nullable=False, index=True)
bunga = Column(Float(53), server_default=FetchedValue())
bulan_telat = Column(Integer, server_default=FetchedValue())
hitung_bunga = Column(SmallInteger, server_default=FetchedValue())
printed = Column(SmallInteger, server_default=FetchedValue())
enabled = Column(SmallInteger, server_default=FetchedValue())
create_date = Column(DateTime)
create_uid = Column(Integer)
write_date = Column(DateTime)
write_uid = Column(Integer)
sspdjam = Column(Time)
tp_id = Column(Integer, server_default=FetchedValue())
is_validated = Column(Integer, server_default=FetchedValue())
keterangan = Column(String(255))
denda = Column(BigInteger, server_default=FetchedValue())
jml_bayar = Column(BigInteger, server_default=FetchedValue())
is_valid = Column(Integer, server_default=FetchedValue())
cancel_bunga = Column(BigInteger)
cancel_denda = Column(BigInteger)
cancel_date = Column(DateTime)
cancel_jml_bayar = Column(BigInteger)
cancel_uid = Column(Integer)
opsen_denda = Column(BigInteger)
opsen_bayar = Column(BigInteger)
opsen_bunga = Column(BigInteger)
posted = Column(SmallInteger, nullable=False,
server_default=FetchedValue())
posting_simda_penetapan = Column(
SmallInteger, nullable=False, server_default=FetchedValue())
posting_simda_non_penetapan = Column(
SmallInteger, nullable=False, server_default=FetchedValue())
spt = relationship(
'PjdlInvoice', primaryjoin='PjdlPayment.spt_id == PjdlInvoice.id', backref='pad_sspds')
@classmethod
def get_no_bayar(cls):
strid = cast(cls.id, String)
strid = func.lpad(strid, 6, '0')
hasil = func.concat(cls.tahun, '-')
hasil = func.concat(hasil, strid)
return hasil
@classmethod
def get_bayarno(cls):
strTahun = cast(cls.tahun, String)
strSspdno = cast(cls.sspdno, String)
fixSspdno = func.lpad(strSspdno, 6, '0')
result = strTahun + '-' + fixSspdno
return result
@classmethod
def get_sspd_no(cls, row=None):
if not row:
tahun = datetime.now().year
else:
tahun = row.tahun
result = DBSession.query(func.max(cls.sspdno)).\
filter_by(tahun=tahun).scalar()
result = result and result > 0 and result+1 or 1
return result