Skip to content

Commit

Permalink
fix: remove deprecated internet banking and human amount error in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesx00 committed Mar 30, 2023
1 parent d1af322 commit 8bc3582
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 35 deletions.
2 changes: 1 addition & 1 deletion django_omise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.2.14"
__version__ = "0.2.15"
VERSION = __version__
4 changes: 2 additions & 2 deletions django_omise/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ class PayWithInternetBankingForm(forms.Form):
choices=(
(ChargeSourceType.INTERNET_BANKING_BAY, _("Krungsri Bank")),
(ChargeSourceType.INTERNET_BANKING_BBL, _("Bangkok Bank")),
(ChargeSourceType.INTERNET_BANKING_KTB, _("Krungthai Bank")),
(ChargeSourceType.INTERNET_BANKING_SCB, _("SCB Bank")),
# (ChargeSourceType.INTERNET_BANKING_KTB, _("Krungthai Bank")),
# (ChargeSourceType.INTERNET_BANKING_SCB, _("SCB Bank")),
),
widget=forms.RadioSelect,
required=False,
Expand Down
9 changes: 5 additions & 4 deletions django_omise/models/schedule.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Optional
from .base import OmiseBaseModel, OmiseMetadata, OmiseDeletableModel
from .choices import Currency, OccurrenceStatus, ScheduleStatus, SchedulePeriod

Expand All @@ -9,7 +10,6 @@


class Schedule(OmiseBaseModel, OmiseDeletableModel):

NON_DEFAULT_FIELDS = OmiseBaseModel.NON_DEFAULT_FIELDS + [
"charges",
]
Expand Down Expand Up @@ -64,7 +64,6 @@ class Schedule(OmiseBaseModel, OmiseDeletableModel):


class Occurrence(OmiseBaseModel):

message = models.CharField(max_length=255, blank=True)
processed_at = models.DateTimeField(blank=True, null=True)

Expand All @@ -82,7 +81,6 @@ class Occurrence(OmiseBaseModel):


class ChargeSchedule(OmiseBaseModel, OmiseMetadata):

amount = models.IntegerField(
help_text="Refund amount in smallest unit of charge currency.",
)
Expand Down Expand Up @@ -111,7 +109,10 @@ class ChargeSchedule(OmiseBaseModel, OmiseMetadata):
description = models.TextField(blank=True)

@property
def human_amount(self) -> float:
def human_amount(self) -> Optional[str]:
if self.amount is None:
return None

if self.currency == Currency.JPY:
return f"{self.amount:,.2f}"
return f"{self.amount / 100:,.2f}"
180 changes: 153 additions & 27 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-omise"
version = "0.2.14"
version = "0.2.15"
description = "Django models for Omise"
authors = ["James Tansiri <tansirijames@gmail.com>"]
license = "MIT"
Expand All @@ -21,6 +21,7 @@ psycopg2 = "^2.9.3"
pytest-cov = "^3.0.0"
coveralls = "^3.3.1"
poethepoet = "^0.16.2"
black = "^23.3.0"

[tool.poe.tasks]
test = 'pytest --verbose'
Expand Down

0 comments on commit 8bc3582

Please sign in to comment.