diff --git a/backend/trip/alembic/versions/7e331b851cb7_trip_currency.py b/backend/trip/alembic/versions/7e331b851cb7_trip_currency.py new file mode 100644 index 0000000..748854a --- /dev/null +++ b/backend/trip/alembic/versions/7e331b851cb7_trip_currency.py @@ -0,0 +1,27 @@ +"""Trip currency + +Revision ID: 7e331b851cb7 +Revises: 26c89b7466f2 +Create Date: 2025-08-23 15:06:50.387366 + +""" + +import sqlalchemy as sa +import sqlmodel.sql.sqltypes +from alembic import op + +# revision identifiers, used by Alembic. +revision = "7e331b851cb7" +down_revision = "26c89b7466f2" +branch_labels = None +depends_on = None + + +def upgrade(): + with op.batch_alter_table("trip", schema=None) as batch_op: + batch_op.add_column(sa.Column("currency", sqlmodel.sql.sqltypes.AutoString(), nullable=True)) + + +def downgrade(): + with op.batch_alter_table("trip", schema=None) as batch_op: + batch_op.drop_column("currency") diff --git a/backend/trip/models/models.py b/backend/trip/models/models.py index ec8d39c..6416b42 100644 --- a/backend/trip/models/models.py +++ b/backend/trip/models/models.py @@ -250,6 +250,7 @@ class PlaceRead(PlaceBase): class TripBase(SQLModel): name: str archived: bool | None = None + currency: str | None = settings.DEFAULT_CURRENCY class Trip(TripBase, table=True): @@ -294,6 +295,7 @@ class TripReadBase(TripBase): image_id=obj.image_id, days=len(obj.days), collaborators=[TripMemberRead.serialize(m) for m in obj.memberships], + currency=obj.currency if obj.currency else settings.DEFAULT_CURRENCY, ) @@ -318,6 +320,7 @@ class TripRead(TripBase): places=[PlaceRead.serialize(place) for place in obj.places], collaborators=[TripMemberRead.serialize(m) for m in obj.memberships], shared=bool(obj.shares), + currency=obj.currency if obj.currency else settings.DEFAULT_CURRENCY, ) diff --git a/src/src/app/components/dashboard/dashboard.component.html b/src/src/app/components/dashboard/dashboard.component.html index f1e2bce..29b27a1 100644 --- a/src/src/app/components/dashboard/dashboard.component.html +++ b/src/src/app/components/dashboard/dashboard.component.html @@ -248,8 +248,7 @@
- +
diff --git a/src/src/app/components/dashboard/dashboard.component.ts b/src/src/app/components/dashboard/dashboard.component.ts index 02d88c7..2e07042 100644 --- a/src/src/app/components/dashboard/dashboard.component.ts +++ b/src/src/app/components/dashboard/dashboard.component.ts @@ -96,7 +96,6 @@ export class DashboardComponent implements OnInit, AfterViewInit { markerClusterGroup?: L.MarkerClusterGroup; gpxLayerGroup?: L.LayerGroup; settings?: Settings; - currencySigns = UtilsService.currencySigns(); doNotDisplayOptions: SelectItemGroup[] = []; places: Place[] = []; @@ -117,8 +116,6 @@ export class DashboardComponent implements OnInit, AfterViewInit { private router: Router, private fb: FormBuilder, ) { - this.currencySigns = UtilsService.currencySigns(); - this.settingsForm = this.fb.group({ map_lat: [ "", diff --git a/src/src/app/components/shared-trip/shared-trip.component.html b/src/src/app/components/shared-trip/shared-trip.component.html index 4c89196..6a81449 100644 --- a/src/src/app/components/shared-trip/shared-trip.component.html +++ b/src/src/app/components/shared-trip/shared-trip.component.html @@ -19,7 +19,7 @@ severity="help" /> {{ - (totalPrice | number:'1.0-2') || '-' }} {{ currency$ | async }} + (totalPrice | number:'1.0-2') || '-' }} @if (totalPrice) { {{ trip.currency }} } @@ -131,7 +131,7 @@ } @if (tripTableSelectedColumns.includes('price')) {@if (tripitem.price) {{{ - tripitem.price }} {{ currency$ | async }}}} + tripitem.price }} @if (tripitem.price) { {{ trip.currency }} }}} @if (tripTableSelectedColumns.includes('status')) {@if (tripitem.status) {{{ @@ -180,7 +180,7 @@ } @if (tripTableSelectedColumns.includes('price')) {@if (tripitem.price) {{{ - tripitem.price }} {{ currency$ | async }}}} + tripitem.price }} @if (tripitem.price) { {{ trip.currency }} }}} @if (tripTableSelectedColumns.includes('status')) {@if (tripitem.status) {{{ @@ -267,7 +267,7 @@ @if (selectedItem.price) {

Price

-

{{ selectedItem.price }} {{ currency$ | async }}

+

{{ selectedItem.price }} @if (selectedItem.price) { {{ trip.currency }} }

} @@ -353,7 +353,7 @@ {{ p.price || '-' - }} {{ currency$ | async }} + }} @if (p.price) { {{ trip.currency }} }
@if (trip.collaborators.length) { {{ p.user @@ -402,7 +402,7 @@
{{ - getDayStats(d).price || '-' }} {{ currency$ | async }} + getDayStats(d).price || '-' }} @if (getDayStats(d).price) { {{ trip.currency }} } {{ getDayStats(d).places }}
diff --git a/src/src/app/components/shared-trip/shared-trip.component.ts b/src/src/app/components/shared-trip/shared-trip.component.ts index 54fa5e6..a8ab52a 100644 --- a/src/src/app/components/shared-trip/shared-trip.component.ts +++ b/src/src/app/components/shared-trip/shared-trip.component.ts @@ -54,14 +54,12 @@ import { InputTextModule } from "primeng/inputtext"; FormsModule, MultiSelectModule, CheckboxModule, - AsyncPipe, ], templateUrl: "./shared-trip.component.html", styleUrls: ["./shared-trip.component.scss"], }) export class SharedTripComponent implements AfterViewInit { token?: string; - currency$: Observable; statuses: TripStatus[] = []; trip?: Trip; places: Place[] = []; @@ -180,7 +178,6 @@ export class SharedTripComponent implements AfterViewInit { private utilsService: UtilsService, private route: ActivatedRoute, ) { - this.currency$ = this.utilsService.currency$; this.statuses = this.utilsService.statuses; this.tripTableSearchInput.valueChanges .pipe(takeUntilDestroyed(), debounceTime(300)) diff --git a/src/src/app/components/trip/trip.component.html b/src/src/app/components/trip/trip.component.html index d99a817..2181223 100644 --- a/src/src/app/components/trip/trip.component.html +++ b/src/src/app/components/trip/trip.component.html @@ -35,7 +35,7 @@ {{ - (totalPrice | number:'1.0-2') || '-' }} {{ currency$ | async }} + (totalPrice | number:'1.0-2') || '-' }} @if (totalPrice) { {{ trip?.currency }} }
@@ -161,7 +161,7 @@ } @if (tripTableSelectedColumns.includes('price')) {@if (tripitem.price) {{{ - tripitem.price }} {{ currency$ | async }}}} + tripitem.price }} @if (tripitem.price) { {{ trip?.currency }} }}} @if (tripTableSelectedColumns.includes('status')) {@if (tripitem.status) {{{ @@ -210,7 +210,7 @@ } @if (tripTableSelectedColumns.includes('price')) {@if (tripitem.price) {{{ - tripitem.price }} {{ currency$ | async }}}} + tripitem.price }} @if (tripitem.price) { {{ trip?.currency }} }}} @if (tripTableSelectedColumns.includes('status')) {@if (tripitem.status) {{{ @@ -310,7 +310,8 @@ @if (selectedItem.price) {

Price

-

{{ selectedItem.price }} {{ currency$ | async }}

+

{{ selectedItem.price }} @if (selectedItem.price) { {{ trip?.currency }} } +

} @@ -401,7 +402,7 @@ {{ p.price || '-' - }} {{ currency$ | async }} + }} @if (p.price) { {{ trip?.currency }} }
@if (trip?.collaborators?.length) { {{ p.user @@ -454,7 +455,7 @@
{{ - getDayStats(d).price || '-' }} {{ currency$ | async }} + getDayStats(d).price || '-' }} @if (getDayStats(d).price) { {{ trip?.currency }} } {{ getDayStats(d).places }} @@ -649,7 +650,7 @@
- - {{ currency$ | async }} + {{ trip?.currency }}