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 2b3e5390
authored
Jan 14, 2020
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
hitung_denda() berdasarkan bulan
1 parent
40c457d1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
16 deletions
CHANGES.txt
opensipkd/__init__.py
opensipkd/hitung.py
opensipkd/string/__init__.py
setup.py
test/denda.py
CHANGES.txt
View file @
2b3e539
0.1.4 2019-11-11
----------------
- hitung_denda() kini bisa berdasarkan bulan.
0.1.3 2019-07-05
0.1.3 2019-07-05
----------------
----------------
- Penambahan FixLength.to_dict()
- Penambahan FixLength.to_dict()
...
...
opensipkd/__init__.py
0 → 100644
View file @
2b3e539
File mode changed
opensipkd/hitung.py
View file @
2b3e539
...
@@ -13,20 +13,33 @@ def round_up(n):
...
@@ -13,20 +13,33 @@ def round_up(n):
return
i
-
1
return
i
-
1
def
bulan_tunggakan
(
jatuh_tempo
,
tgl_hitung
):
def
bulan_tunggakan
_berdasarkan_tgl
(
jatuh_tempo
,
tgl_hitung
):
x
=
(
tgl_hitung
.
year
-
jatuh_tempo
.
year
)
*
12
x
=
(
tgl_hitung
.
year
-
jatuh_tempo
.
year
)
*
12
y
=
tgl_hitung
.
month
-
jatuh_tempo
.
month
y
=
tgl_hitung
.
month
-
jatuh_tempo
.
month
n
=
x
+
y
+
1
n
=
x
+
y
if
tgl_hitung
.
day
<=
jatuh_tempo
.
day
:
if
n
<
0
:
n
-=
1
return
0
if
n
<
1
:
if
tgl_hitung
.
day
>
jatuh_tempo
.
day
:
n
=
0
n
+=
1
if
n
>
24
:
if
n
>
24
:
n
=
24
return
24
return
n
return
n
def
hitung_denda
(
tagihan
,
jatuh_tempo
,
persen_denda
,
tgl_hitung
=
None
):
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
:
if
jatuh_tempo
is
None
:
return
0
,
0
return
0
,
0
if
tgl_hitung
is
None
:
if
tgl_hitung
is
None
:
...
@@ -35,6 +48,6 @@ def hitung_denda(tagihan, jatuh_tempo, persen_denda, tgl_hitung=None):
...
@@ -35,6 +48,6 @@ def hitung_denda(tagihan, jatuh_tempo, persen_denda, tgl_hitung=None):
jatuh_tempo
=
jatuh_tempo
.
date
()
jatuh_tempo
=
jatuh_tempo
.
date
()
if
jatuh_tempo
>=
tgl_hitung
or
persen_denda
<=
0
:
if
jatuh_tempo
>=
tgl_hitung
or
persen_denda
<=
0
:
return
0
,
0
return
0
,
0
bulan
=
bulan_tunggak
an
(
jatuh_tempo
,
tgl_hitung
)
bulan
=
func_hitung_bul
an
(
jatuh_tempo
,
tgl_hitung
)
denda
=
bulan
*
float
(
persen_denda
)
/
100
*
tagihan
denda
=
bulan
*
float
(
persen_denda
)
/
100
*
tagihan
return
bulan
,
denda
return
bulan
,
denda
opensipkd/string/__init__.py
View file @
2b3e539
setup.py
View file @
2b3e539
import
os
import
os
from
setuptools
import
setup
from
setuptools
import
(
setup
,
find_packages
,
)
here
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
here
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
...
@@ -15,11 +18,6 @@ requires = [
...
@@ -15,11 +18,6 @@ requires = [
'pytz'
,
'pytz'
,
]
]
packages
=
[
'opensipkd'
,
'opensipkd.string'
,
]
setup
(
setup
(
name
=
'opensipkd-hitung'
,
name
=
'opensipkd-hitung'
,
version
=
version
,
version
=
version
,
...
@@ -28,7 +26,7 @@ setup(
...
@@ -28,7 +26,7 @@ setup(
author
=
'Owo Sugiana'
,
author
=
'Owo Sugiana'
,
author_email
=
'sugiana@gmail.com'
,
author_email
=
'sugiana@gmail.com'
,
license
=
'PostgreSQL License'
,
license
=
'PostgreSQL License'
,
packages
=
packages
,
packages
=
find_packages
()
,
install_requires
=
requires
,
install_requires
=
requires
,
zip_safe
=
False
,
zip_safe
=
False
,
)
)
test/denda.py
0 → 100644
View file @
2b3e539
import
unittest
from
datetime
import
date
from
opensipkd.hitung
import
(
bulan_tunggakan_berdasarkan_tgl
as
by_date
,
bulan_tunggakan_berdasarkan_bln
as
by_month
,
)
class
Denda
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
jatuh_tempo
=
date
(
2019
,
9
,
20
)
def
by_date
(
self
,
tgl_bayar
,
jml_bln
):
self
.
assertEqual
(
by_date
(
self
.
jatuh_tempo
,
tgl_bayar
),
jml_bln
)
def
by_month
(
self
,
tgl_bayar
,
jml_bln
):
self
.
assertEqual
(
by_month
(
self
.
jatuh_tempo
,
tgl_bayar
),
jml_bln
)
def
bandingkan
(
self
,
tgl_bayar
,
jml_bln
):
self
.
by_date
(
tgl_bayar
,
jml_bln
)
self
.
by_month
(
tgl_bayar
,
jml_bln
)
def
test_sebelum_jatuh_tempo
(
self
):
tgl_bayar
=
date
(
2019
,
8
,
31
)
self
.
bandingkan
(
tgl_bayar
,
0
)
def
test_saat_jatuh_tempo
(
self
):
tgl_bayar
=
date
(
2019
,
9
,
20
)
self
.
bandingkan
(
tgl_bayar
,
0
)
def
test_setelah_jatuh_tempo_bulan_sama
(
self
):
tgl_bayar
=
date
(
2019
,
9
,
21
)
self
.
by_date
(
tgl_bayar
,
1
)
self
.
by_month
(
tgl_bayar
,
0
)
def
test_setelah_jatuh_tempo_bulan_beda
(
self
):
tgl_bayar
=
date
(
2019
,
10
,
1
)
self
.
bandingkan
(
tgl_bayar
,
1
)
def
test_setelah_jatuh_tempo_tahun_beda
(
self
):
tgl_bayar
=
date
(
2020
,
1
,
2
)
self
.
bandingkan
(
tgl_bayar
,
4
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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