Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
opensipkd-hitung
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 75ad1224
authored
Aug 12, 2021
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Perubahan multi stage development production
1 parent
8110854e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
197 additions
and
192 deletions
CHANGES.txt
__init__.py
opensipkd/__init__.py
opensipkd/hitung.py → opensipkd/hitung/__init__.py
opensipkd/waktu.py → opensipkd/waktu/__init__.py
CHANGES.txt
View file @
75ad122
0.2.0b 2020-10-17
-----------------
Beta Perubahan menjadi multi stage development dan production
0.1.8 2020-10-17
----------------
- Baru, STAN (System Trace Audit Number) generator
...
...
__init__.py
0 → 100644
View file @
75ad122
File mode changed
opensipkd/__init__.py
View file @
75ad122
__path__
=
__import__
(
'pkgutil'
)
.
extend_path
(
__path__
,
__name__
)
\ No newline at end of file
opensipkd/hitung.py
→
opensipkd/hitung
/__init__
.py
View file @
75ad122
from
datetime
import
(
date
,
datetime
,
)
def
round_up
(
n
):
i
=
int
(
n
)
if
n
==
i
:
return
i
if
n
>
0
:
return
i
+
1
return
i
-
1
def
bulan_tunggakan_berdasarkan_tgl
(
jatuh_tempo
,
tgl_hitung
):
x
=
(
tgl_hitung
.
year
-
jatuh_tempo
.
year
)
*
12
y
=
tgl_hitung
.
month
-
jatuh_tempo
.
month
n
=
x
+
y
if
n
<
0
:
return
0
if
tgl_hitung
.
day
>
jatuh_tempo
.
day
:
n
+=
1
if
n
>
24
:
return
24
return
n
def
bulan_tunggakan_berdasarkan_bln
(
jatuh_tempo
,
tgl_hitung
):
x
=
(
tgl_hitung
.
year
-
jatuh_tempo
.
year
)
*
12
y
=
tgl_hitung
.
month
-
jatuh_tempo
.
month
n
=
x
+
y
if
n
<
0
:
return
0
if
n
>
24
:
return
24
return
n
def
hitung_denda
(
tagihan
,
jatuh_tempo
,
persen_denda
,
tgl_hitung
=
None
,
func_hitung_bulan
=
bulan_tunggakan_berdasarkan_tgl
):
if
jatuh_tempo
is
None
:
return
0
,
0
if
tgl_hitung
is
None
:
tgl_hitung
=
date
.
today
()
if
isinstance
(
jatuh_tempo
,
datetime
):
jatuh_tempo
=
jatuh_tempo
.
date
()
if
jatuh_tempo
>=
tgl_hitung
or
persen_denda
<=
0
:
return
0
,
0
bulan
=
func_hitung_bulan
(
jatuh_tempo
,
tgl_hitung
)
denda
=
bulan
*
float
(
persen_denda
)
/
100
*
tagihan
return
bulan
,
denda
from
datetime
import
(
date
,
datetime
,
)
def
round_up
(
n
):
i
=
int
(
n
)
if
n
==
i
:
return
i
if
n
>
0
:
return
i
+
1
return
i
-
1
def
bulan_tunggakan_berdasarkan_tgl
(
jatuh_tempo
,
tgl_hitung
):
x
=
(
tgl_hitung
.
year
-
jatuh_tempo
.
year
)
*
12
y
=
tgl_hitung
.
month
-
jatuh_tempo
.
month
n
=
x
+
y
if
n
<
0
:
return
0
if
tgl_hitung
.
day
>
jatuh_tempo
.
day
:
n
+=
1
if
n
>
24
:
return
24
return
n
def
bulan_tunggakan_berdasarkan_bln
(
jatuh_tempo
,
tgl_hitung
):
x
=
(
tgl_hitung
.
year
-
jatuh_tempo
.
year
)
*
12
y
=
tgl_hitung
.
month
-
jatuh_tempo
.
month
n
=
x
+
y
if
n
<
0
:
return
0
if
n
>
24
:
return
24
return
n
def
hitung_denda
(
tagihan
,
jatuh_tempo
,
persen_denda
,
tgl_hitung
=
None
,
func_hitung_bulan
=
bulan_tunggakan_berdasarkan_tgl
):
if
jatuh_tempo
is
None
:
return
0
,
0
if
tgl_hitung
is
None
:
tgl_hitung
=
date
.
today
()
if
isinstance
(
jatuh_tempo
,
datetime
):
jatuh_tempo
=
jatuh_tempo
.
date
()
if
jatuh_tempo
>=
tgl_hitung
or
persen_denda
<=
0
:
return
0
,
0
bulan
=
func_hitung_bulan
(
jatuh_tempo
,
tgl_hitung
)
denda
=
bulan
*
float
(
persen_denda
)
/
100
*
tagihan
return
bulan
,
denda
opensipkd/waktu.py
→
opensipkd/waktu
/__init__
.py
View file @
75ad122
import
calendar
from
datetime
import
(
date
,
datetime
,
)
import
pytz
settings
=
{
'timezone'
:
'Asia/Jakarta'
,
}
def
get_timezone
():
return
pytz
.
timezone
(
settings
[
'timezone'
])
def
create_datetime
(
year
,
month
,
day
,
hour
=
0
,
minute
=
7
,
second
=
0
,
microsecond
=
0
):
tz
=
get_timezone
()
without_tz
=
datetime
(
year
,
month
,
day
,
hour
,
minute
,
second
,
microsecond
)
return
tz
.
localize
(
without_tz
)
def
create_date
(
year
,
month
,
day
):
return
create_datetime
(
year
,
month
,
day
)
def
as_timezone
(
tz_date
):
localtz
=
get_timezone
()
if
not
tz_date
.
tzinfo
:
tz_date
=
create_datetime
(
tz_date
.
year
,
tz_date
.
month
,
tz_date
.
day
,
tz_date
.
hour
,
tz_date
.
minute
,
tz_date
.
second
,
tz_date
.
microsecond
)
return
tz_date
.
astimezone
(
localtz
)
def
create_now
():
tz
=
get_timezone
()
return
datetime
.
now
(
tz
)
def
date_from_str
(
value
):
separator
=
None
value
=
value
.
split
()[
0
]
# dd-mm-yyyy HH:MM:SS
for
s
in
[
'-'
,
'/'
]:
if
value
.
find
(
s
)
>
-
1
:
separator
=
s
break
if
separator
:
t
=
map
(
lambda
x
:
int
(
x
),
value
.
split
(
separator
))
y
,
m
,
d
=
t
[
2
],
t
[
1
],
t
[
0
]
if
d
>
999
:
# yyyy-mm-dd
y
,
d
=
d
,
y
else
:
y
,
m
,
d
=
int
(
value
[:
4
]),
int
(
value
[
4
:
6
]),
int
(
value
[
6
:])
return
date
(
y
,
m
,
d
)
def
split_time
(
s
):
t
=
s
.
split
(
':'
)
# HH:MM:SS
hour
=
int
(
t
[
0
])
minutes
=
seconds
=
0
if
t
[
1
:]:
minutes
=
int
(
t
[
1
])
if
t
[
2
:]:
seconds
=
int
(
t
[
2
])
return
hour
,
minutes
,
seconds
# dd-mm-yyyy
# yyyy-mm-dd
# dd/mm/yyyy
# yyyy/mm/dd
# yyyymmdd
def
split_date
(
s
):
separator
=
None
for
sep
in
[
'-'
,
'/'
]:
if
s
.
find
(
sep
)
>
-
1
:
separator
=
sep
break
if
separator
:
d
,
m
,
y
=
[
int
(
x
)
for
x
in
s
.
split
(
separator
)]
if
d
>
999
:
# yyyy-mm-dd
y
,
d
=
d
,
y
else
:
y
,
m
,
d
=
int
(
value
[:
4
]),
int
(
value
[
4
:
6
]),
int
(
value
[
6
:])
return
y
,
m
,
d
def
split_datetime
(
s
):
t
=
s
.
split
()
# dd-mm-yyyy HH:MM:SS
year
,
month
,
day
=
split_date
(
t
[
0
])
if
t
[
1
:]:
hours
,
minutes
,
seconds
=
split_time
(
t
[
1
])
else
:
hours
=
minutes
=
seconds
=
0
return
year
,
month
,
day
,
hours
,
minutes
,
seconds
def
date_from_str
(
s
):
y
,
m
,
d
,
hh
,
mm
,
ss
=
split_datetime
(
s
)
return
date
(
y
,
m
,
d
)
def
datetime_from_str
(
s
):
y
,
m
,
d
,
hh
,
mm
,
ss
=
split_datetime
(
s
)
return
create_datetime
(
y
,
m
,
d
,
hh
,
mm
,
ss
)
def
dmy
(
tgl
):
return
tgl
.
strftime
(
'
%
d-
%
m-
%
Y'
)
def
dmyhms
(
t
):
return
t
.
strftime
(
'
%
d-
%
m-
%
Y
%
H:
%
M:
%
S'
)
def
next_month
(
year
,
month
):
if
month
==
12
:
month
=
1
year
+=
1
else
:
month
+=
1
return
year
,
month
def
best_date
(
year
,
month
,
day
):
try
:
return
date
(
year
,
month
,
day
)
except
ValueError
:
last_day
=
calendar
.
monthrange
(
year
,
month
)[
1
]
return
date
(
year
,
month
,
last_day
)
def
next_month_day
(
year
,
month
,
day
):
year
,
month
=
next_month
(
year
,
month
)
return
best_date
(
year
,
month
,
day
)
import
calendar
from
datetime
import
(
date
,
datetime
,
)
import
pytz
settings
=
{
'timezone'
:
'Asia/Jakarta'
,
}
def
get_timezone
():
return
pytz
.
timezone
(
settings
[
'timezone'
])
def
create_datetime
(
year
,
month
,
day
,
hour
=
0
,
minute
=
7
,
second
=
0
,
microsecond
=
0
):
tz
=
get_timezone
()
without_tz
=
datetime
(
year
,
month
,
day
,
hour
,
minute
,
second
,
microsecond
)
return
tz
.
localize
(
without_tz
)
def
create_date
(
year
,
month
,
day
):
return
create_datetime
(
year
,
month
,
day
)
def
as_timezone
(
tz_date
):
localtz
=
get_timezone
()
if
not
tz_date
.
tzinfo
:
tz_date
=
create_datetime
(
tz_date
.
year
,
tz_date
.
month
,
tz_date
.
day
,
tz_date
.
hour
,
tz_date
.
minute
,
tz_date
.
second
,
tz_date
.
microsecond
)
return
tz_date
.
astimezone
(
localtz
)
def
create_now
():
tz
=
get_timezone
()
return
datetime
.
now
(
tz
)
def
date_from_str
(
value
):
separator
=
None
value
=
value
.
split
()[
0
]
# dd-mm-yyyy HH:MM:SS
for
s
in
[
'-'
,
'/'
]:
if
value
.
find
(
s
)
>
-
1
:
separator
=
s
break
if
separator
:
t
=
map
(
lambda
x
:
int
(
x
),
value
.
split
(
separator
))
y
,
m
,
d
=
t
[
2
],
t
[
1
],
t
[
0
]
if
d
>
999
:
# yyyy-mm-dd
y
,
d
=
d
,
y
else
:
y
,
m
,
d
=
int
(
value
[:
4
]),
int
(
value
[
4
:
6
]),
int
(
value
[
6
:])
return
date
(
y
,
m
,
d
)
def
split_time
(
s
):
t
=
s
.
split
(
':'
)
# HH:MM:SS
hour
=
int
(
t
[
0
])
minutes
=
seconds
=
0
if
t
[
1
:]:
minutes
=
int
(
t
[
1
])
if
t
[
2
:]:
seconds
=
int
(
t
[
2
])
return
hour
,
minutes
,
seconds
# dd-mm-yyyy
# yyyy-mm-dd
# dd/mm/yyyy
# yyyy/mm/dd
# yyyymmdd
def
split_date
(
s
):
separator
=
None
for
sep
in
[
'-'
,
'/'
]:
if
s
.
find
(
sep
)
>
-
1
:
separator
=
sep
break
if
separator
:
d
,
m
,
y
=
[
int
(
x
)
for
x
in
s
.
split
(
separator
)]
if
d
>
999
:
# yyyy-mm-dd
y
,
d
=
d
,
y
else
:
y
,
m
,
d
=
int
(
value
[:
4
]),
int
(
value
[
4
:
6
]),
int
(
value
[
6
:])
return
y
,
m
,
d
def
split_datetime
(
s
):
t
=
s
.
split
()
# dd-mm-yyyy HH:MM:SS
year
,
month
,
day
=
split_date
(
t
[
0
])
if
t
[
1
:]:
hours
,
minutes
,
seconds
=
split_time
(
t
[
1
])
else
:
hours
=
minutes
=
seconds
=
0
return
year
,
month
,
day
,
hours
,
minutes
,
seconds
def
date_from_str
(
s
):
y
,
m
,
d
,
hh
,
mm
,
ss
=
split_datetime
(
s
)
return
date
(
y
,
m
,
d
)
def
datetime_from_str
(
s
):
y
,
m
,
d
,
hh
,
mm
,
ss
=
split_datetime
(
s
)
return
create_datetime
(
y
,
m
,
d
,
hh
,
mm
,
ss
)
def
dmy
(
tgl
):
return
tgl
.
strftime
(
'
%
d-
%
m-
%
Y'
)
def
dmyhms
(
t
):
return
t
.
strftime
(
'
%
d-
%
m-
%
Y
%
H:
%
M:
%
S'
)
def
next_month
(
year
,
month
):
if
month
==
12
:
month
=
1
year
+=
1
else
:
month
+=
1
return
year
,
month
def
best_date
(
year
,
month
,
day
):
try
:
return
date
(
year
,
month
,
day
)
except
ValueError
:
last_day
=
calendar
.
monthrange
(
year
,
month
)[
1
]
return
date
(
year
,
month
,
last_day
)
def
next_month_day
(
year
,
month
,
day
):
year
,
month
=
next_month
(
year
,
month
)
return
best_date
(
year
,
month
,
day
)
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment