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 f58994e1
authored
Feb 09, 2022
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Penyempurnaan round_up()
1 parent
8110854e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
5 deletions
CHANGES.txt
opensipkd/__init__.py
opensipkd/hitung.py
test/denda.py
CHANGES.txt
View file @
f58994e
0.2 2022-02-09
----------------
- round_up() disempurnakan yaitu bila pecahan kurang dari 0.1 maka akan
dibulatkan ke bawah. Ini terkait masalah operasi bilangan pecahan yang
disebutkan di
https://stackoverflow.com/questions/588004/is-floating-point-math-broken
- Penggunaan pkgutil agar lebih fleksibel saat pip install -e
0.1.8 2020-10-17
----------------
- Baru, STAN (System Trace Audit Number) generator
...
...
opensipkd/__init__.py
View file @
f58994e
__path__
=
__import__
(
'pkgutil'
)
.
extend_path
(
__path__
,
__name__
)
opensipkd/hitung.py
View file @
f58994e
...
...
@@ -6,11 +6,10 @@ from datetime import (
def
round_up
(
n
):
i
=
int
(
n
)
if
n
==
i
:
return
i
if
n
>
0
:
return
i
+
1
return
i
-
1
plus
=
(
int
(
n
*
10
)
-
int
(
n
)
*
10
)
and
1
if
n
<
0
:
return
i
-
plus
return
i
+
plus
def
bulan_tunggakan_berdasarkan_tgl
(
jatuh_tempo
,
tgl_hitung
):
...
...
test/denda.py
View file @
f58994e
...
...
@@ -3,6 +3,7 @@ from datetime import date
from
opensipkd.hitung
import
(
bulan_tunggakan_berdasarkan_tgl
as
by_date
,
bulan_tunggakan_berdasarkan_bln
as
by_month
,
round_up
,
)
...
...
@@ -42,5 +43,28 @@ class Denda(unittest.TestCase):
self
.
bandingkan
(
tgl_bayar
,
4
)
class
Round
(
unittest
.
TestCase
):
def
test_round_0
(
self
):
self
.
assertEqual
(
round_up
(
0
),
0
)
def
test_round_5
(
self
):
self
.
assertEqual
(
round_up
(
5
),
5
)
def
test_round_5_1
(
self
):
self
.
assertEqual
(
round_up
(
5.1
),
6
)
def
test_round_5_09
(
self
):
self
.
assertEqual
(
round_up
(
5.09
),
5
)
def
test_round_minus_5
(
self
):
self
.
assertEqual
(
round_up
(
-
5
),
-
5
)
def
test_round_minus_5_1
(
self
):
self
.
assertEqual
(
round_up
(
-
5.1
),
-
6
)
def
test_round_minus_5_09
(
self
):
self
.
assertEqual
(
round_up
(
-
5.09
),
-
5
)
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