34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package model
|
|
|
|
import (
|
|
"electricity_bill_calc/types"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type TopUp struct {
|
|
TopUpCode string `json:"topUpCode" db:"top_up_code"`
|
|
Park string `json:"parkId" db:"park_id"`
|
|
Tenement string `json:"tenementId" db:"tenement_id"`
|
|
TenementName string `json:"tenementName" db:"tenement_name"`
|
|
Meter string `json:"meterId" db:"meter_id"`
|
|
MeterAddress *string `json:"meterAddress" db:"meter_address"`
|
|
ToppedUpAt types.DateTime `json:"toppedUpAt" db:"topped_up_at"`
|
|
Amount decimal.Decimal `json:"amount" db:"amount"`
|
|
PaymentType int16 `json:"paymentType" db:"payment_type"`
|
|
SuccessfulSynchronized bool `json:"successfulSynchronized" db:"successful_synchronized"`
|
|
SynchronizedAt *types.DateTime `json:"synchronizedAt" db:"synchronized_at"`
|
|
CancelledAt *types.DateTime `json:"cancelledAt" db:"cancelled_at"`
|
|
}
|
|
|
|
func (t TopUp) SyncStatus() int16 {
|
|
switch {
|
|
case t.SuccessfulSynchronized && t.SynchronizedAt != nil:
|
|
return 1
|
|
case !t.SuccessfulSynchronized && t.SynchronizedAt != nil:
|
|
return 2
|
|
default:
|
|
return 0
|
|
}
|
|
}
|