From a17586b3a2897db7238e0337f0b408f9427cc763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Jurmanovi=C4=87?= Date: Sat, 19 Jun 2021 14:23:44 +0200 Subject: [PATCH] added end date to subscription model --- pkg/models/subscriptions.go | 4 ++++ pkg/services/subscriptions.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/pkg/models/subscriptions.go b/pkg/models/subscriptions.go index 131e96b..016afde 100644 --- a/pkg/models/subscriptions.go +++ b/pkg/models/subscriptions.go @@ -10,6 +10,8 @@ type Subscription struct { BaseModel Description string `json:"description" pg:"description"` StartDate time.Time `json:"startDate" pg:"start_date"` + EndDate time.Time `json:"endDate" pg:"end_date"` + HasEnd bool `json:"hasEnd" pg:"hasEnd"` SubscriptionTypeID string `json:"subscriptionTypeId" pg:"subscription_type_id"` SubscriptionType *SubscriptionType `json:"subscriptionType", pg:"rel:has-one, fk:subscription_type_id"` CustomRange int `json:"customRange", pg:"custom_range"` @@ -27,6 +29,8 @@ type NewSubscriptionBody struct { SubscriptionTypeID string `json:"subscriptionTypeId" pg:"subscription_type_id"` CustomRange json.Number `json:"customRange", pg:"custom_range"` StartDate time.Time `json:"startDate" pg:"start_date"` + EndDate time.Time `json:"endDate" pg:"end_date"` + HasEnd bool `json:"hasEnd" pg:"hasEnd"` Description string `json:"description" form:"description"` Amount json.Number `json:"amount" form:"amount"` } diff --git a/pkg/services/subscriptions.go b/pkg/services/subscriptions.go index 606369f..9a638f6 100644 --- a/pkg/services/subscriptions.go +++ b/pkg/services/subscriptions.go @@ -24,6 +24,8 @@ func (as *SubscriptionService) New(body *models.NewSubscriptionBody) *models.Sub tm.CustomRange = int(customRange) tm.Description = body.Description tm.StartDate = body.StartDate + tm.HasEnd = body.HasEnd + tm.EndDate = body.EndDate tm.Amount = int(amount) if body.StartDate.IsZero() {