Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhieta committed Sep 3, 2024
2 parents f918885 + 48eb4bf commit 0720bdc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.1] - 2024-09-03

### Added

- Add VAT-percents to Django Admin ([305c396](https://github.com/City-of-Helsinki/parking-permits/commit/305c396091d68e49657f1299210e233678edf96b))
- Add vat and vat_percent properties to Order ([0e6612d](https://github.com/City-of-Helsinki/parking-permits/commit/0e6612d6031d9d7ade6a7422b1e6b3ecd2a9a513))

### Fixed

- Wrap accepted refund to list in email sending ([eeebdbc](https://github.com/City-of-Helsinki/parking-permits/commit/eeebdbc4355066ca15eaaaf591861eba1e2f1c02))

## [1.2.0] - 2024-08-30

### Added
Expand Down
17 changes: 16 additions & 1 deletion parking_permits/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class RefundAdmin(admin.ModelAdmin):
"status",
"created_at",
"accepted_at",
"vat",
"get_vat_percent",
)
list_select_related = ("order",)
ordering = ("-created_at",)
Expand All @@ -222,6 +222,10 @@ class RefundAdmin(admin.ModelAdmin):
"permits",
)

@admin.display(description="VAT percent")
def get_vat_percent(self, obj):
return format(obj.vat_percent, ".2f")


@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -253,11 +257,13 @@ class OrderAdmin(admin.ModelAdmin):
"address_text",
"parking_zone_name",
"vehicles",
"get_vat_percent",
)
list_select_related = ("customer",)
readonly_fields = (
"talpa_order_id",
"total_payment_price",
"get_vat_percent",
)
search_fields = (
"customer__last_name",
Expand All @@ -273,6 +279,10 @@ class OrderAdmin(admin.ModelAdmin):
)
ordering = ("-created_at",)

@admin.display(description="Vat percent")
def get_vat_percent(self, obj):
return format(obj.vat_percent, ".2f") if obj.vat_percent else None


@admin.register(OrderItem)
class OrderItemAdmin(admin.ModelAdmin):
Expand All @@ -284,11 +294,16 @@ class OrderItemAdmin(admin.ModelAdmin):
"unit_price",
"payment_unit_price",
"quantity",
"get_vat_percent",
)
list_select_related = ("order", "subscription", "product", "permit")
readonly_fields = ("talpa_order_item_id",)
ordering = ("-pk",)

@admin.display(description="Vat percent")
def get_vat_percent(self, obj):
return format(obj.vat_percentage, ".2f")


@admin.register(ParkingPermitExtensionRequest)
class ParkingPermitExtensionRequestAdmin(admin.ModelAdmin):
Expand Down
2 changes: 1 addition & 1 deletion parking_permits/admin_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ def resolve_accept_refunds(obj, info, ids):
id__in=ids, status=RefundStatus.ACCEPTED
).select_related("order__customer")
for refund in accepted_refunds:
send_refund_email(RefundEmailType.ACCEPTED, refund.order.customer, refund)
send_refund_email(RefundEmailType.ACCEPTED, refund.order.customer, [refund])
return qs.count()


Expand Down
9 changes: 9 additions & 0 deletions parking_permits/models/order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from decimal import Decimal
from urllib.parse import urljoin

import requests
Expand Down Expand Up @@ -510,6 +511,14 @@ def total_payment_price_net(self):
def total_payment_price_vat(self):
return sum([item.total_payment_price_vat for item in self.order_items.all()])

@property
def vat(self):
return self.order_items.first().vat if self.order_items.exists() else Decimal(0)

@property
def vat_percent(self):
return self.vat * 100

def _cancel_talpa_order(self):
headers = {
"api-key": settings.TALPA_API_KEY,
Expand Down

0 comments on commit 0720bdc

Please sign in to comment.