forked from free-lancers/electricity_bill_calc_service
		
	
		
			
				
	
	
		
			138 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package model
 | |
| 
 | |
| import (
 | |
| 	"electricity_bill_calc/types"
 | |
| 
 | |
| 	"github.com/shopspring/decimal"
 | |
| )
 | |
| 
 | |
| type ReportIndex struct {
 | |
| 	Id                    string          `json:"id"`
 | |
| 	Park                  string          `json:"parkId" db:"park_id"`
 | |
| 	Period                types.DateRange `json:"period"`
 | |
| 	Category              int16           `json:"category"`
 | |
| 	MeterType             int16           `json:"meter04kvType" db:"meter_04kv_type"`
 | |
| 	PricePolicy           int16           `json:"pricePolicy"`
 | |
| 	BasisPooled           int16           `json:"basisPooled"`
 | |
| 	AdjustPooled          int16           `json:"adjustPooled"`
 | |
| 	LossPooled            int16           `json:"lossPooled"`
 | |
| 	PublicPooled          int16           `json:"publicPooled"`
 | |
| 	Published             bool            `json:"published"`
 | |
| 	PublishedAt           *types.DateTime `json:"publishedAt" db:"published_at"`
 | |
| 	Withdraw              int16           `json:"withdraw"`
 | |
| 	LastWithdrawAppliedAt *types.DateTime `json:"lastWithdrawAppliedAt" db:"last_withdraw_applied_at"`
 | |
| 	LastWithdrawAuditAt   *types.DateTime `json:"lastWithdrawAuditAt" db:"last_withdraw_audit_at"`
 | |
| 	Status                *int16          `json:"status"`
 | |
| 	Message               *string         `json:"message"`
 | |
| 	CreatedAt             types.DateTime  `json:"createdAt" db:"created_at"`
 | |
| 	LastModifiedAt        types.DateTime  `json:"lastModifiedAt" db:"last_modified_at"`
 | |
| }
 | |
| 
 | |
| type ReportSummary struct {
 | |
| 	ReportId                     string              `json:"reportId" db:"report_id"`
 | |
| 	OverallArea                  decimal.Decimal     `json:"overallArea" db:"overall_area"`
 | |
| 	Overall                      ConsumptionUnit     `json:"overall"`
 | |
| 	ConsumptionFee               decimal.NullDecimal `json:"consumptionFee" db:"consumption_fee"`
 | |
| 	Critical                     ConsumptionUnit     `json:"critical"`
 | |
| 	Peak                         ConsumptionUnit     `json:"peak"`
 | |
| 	Flat                         ConsumptionUnit     `json:"flat"`
 | |
| 	Valley                       ConsumptionUnit     `json:"valley"`
 | |
| 	Loss                         decimal.NullDecimal `json:"loss"`
 | |
| 	LossFee                      decimal.NullDecimal `json:"lossFee" db:"loss_fee"`
 | |
| 	LossProportion               decimal.NullDecimal `json:"lossProportion" db:"loss_proportion"`
 | |
| 	AuthorizeLoss                *ConsumptionUnit    `json:"authorizeLoss" db:"authorize_loss"`
 | |
| 	BasicFee                     decimal.Decimal     `json:"basicFee" db:"basic_fee"`
 | |
| 	BasicPooledPriceConsumption  decimal.NullDecimal `json:"basicPooledPriceConsumption" db:"basic_pooled_price_consumption"`
 | |
| 	BasicPooledPriceArea         decimal.NullDecimal `json:"basicPooledPriceArea" db:"basic_pooled_price_area"`
 | |
| 	AdjustFee                    decimal.Decimal     `json:"adjustFee" db:"adjust_fee"`
 | |
| 	AdjustPooledPriceConsumption decimal.NullDecimal `json:"adjustPooledPriceConsumption" db:"adjust_pooled_price_consumption"`
 | |
| 	AdjustPooledPriceArea        decimal.NullDecimal `json:"adjustPooledPriceArea" db:"adjust_pooled_price_area"`
 | |
| 	LossDilutedPrice             decimal.NullDecimal `json:"lossDilutedPrice" db:"loss_diluted_price"`
 | |
| 	TotalConsumption             decimal.Decimal     `json:"totalConsumption" db:"total_consumption"`
 | |
| 	FinalDilutedOverall          decimal.NullDecimal `json:"finalDilutedOverall" db:"final_diluted_overall"`
 | |
| }
 | |
| 
 | |
| func (rs ReportSummary) GetConsumptionFee() decimal.Decimal {
 | |
| 	if !rs.ConsumptionFee.Valid {
 | |
| 		return rs.Overall.Fee.Sub(rs.BasicFee).Sub(rs.AdjustFee)
 | |
| 	}
 | |
| 	return rs.ConsumptionFee.Decimal
 | |
| }
 | |
| 
 | |
| type ReportPublicConsumption struct {
 | |
| 	ReportId         string          `json:"reportId" db:"report_id"`
 | |
| 	MeterId          string          `json:"parkMeterId" db:"park_meter_id"`
 | |
| 	Overall          ConsumptionUnit `json:"overall"`
 | |
| 	Critical         ConsumptionUnit `json:"critical"`
 | |
| 	Peak             ConsumptionUnit `json:"peak"`
 | |
| 	Flat             ConsumptionUnit `json:"flat"`
 | |
| 	Valley           ConsumptionUnit `json:"valley"`
 | |
| 	LossAdjust       ConsumptionUnit `json:"lossAdjust"`
 | |
| 	ConsumptionTotal decimal.Decimal `json:"consumptionTotal" db:"consumption_total"`
 | |
| 	LossAdjustTotal  decimal.Decimal `json:"lossAdjustTotal" db:"loss_adjust_total"`
 | |
| 	FinalTotal       decimal.Decimal `json:"finalTotal" db:"final_total"`
 | |
| 	PublicPooled     int16           `json:"publicPooled" db:"public_pooled"`
 | |
| }
 | |
| 
 | |
| type ReportDetailedPublicConsumption struct {
 | |
| 	MeterDetail
 | |
| 	ReportPublicConsumption
 | |
| }
 | |
| 
 | |
| type ReportPooledConsumption struct {
 | |
| 	ReportId   string          `json:"reportId" db:"report_id"`
 | |
| 	MeterId    string          `json:"pooledMeterId" db:"pooled_meter_id"`
 | |
| 	Overall    ConsumptionUnit `json:"overall"`
 | |
| 	Critical   ConsumptionUnit `json:"critical"`
 | |
| 	Peak       ConsumptionUnit `json:"peak"`
 | |
| 	Flat       ConsumptionUnit `json:"flat"`
 | |
| 	Valley     ConsumptionUnit `json:"valley"`
 | |
| 	PooledArea decimal.Decimal `json:"pooledArea" db:"pooled_area"`
 | |
| 	Diluted    []NestedMeter   `json:"diluted"`
 | |
| }
 | |
| 
 | |
| type ReportDetailedPooledConsumption struct {
 | |
| 	MeterDetail
 | |
| 	ReportPooledConsumption
 | |
| 	PublicPooled int16 `json:"publicPooled"`
 | |
| }
 | |
| 
 | |
| type ReportDetailNestedMeterConsumption struct {
 | |
| 	Meter       MeterDetail `json:"meter"`
 | |
| 	Consumption NestedMeter `json:"consumption"`
 | |
| }
 | |
| 
 | |
| type ReportTenement struct {
 | |
| 	ReportId        string          `json:"reportId" db:"report_id"`
 | |
| 	Tenement        string          `json:"tenementId" db:"tenement_id"`
 | |
| 	Detail          Tenement        `json:"tenementDetail" db:"tenement_detail"`
 | |
| 	Period          types.DateRange `json:"calcPeriod" db:"calc_period"`
 | |
| 	Overall         ConsumptionUnit `json:"overall"`
 | |
| 	Critical        ConsumptionUnit `json:"critical"`
 | |
| 	Peak            ConsumptionUnit `json:"peak"`
 | |
| 	Flat            ConsumptionUnit `json:"flat"`
 | |
| 	Valley          ConsumptionUnit `json:"valley"`
 | |
| 	BasicFeePooled  decimal.Decimal `json:"basicFeePooled" db:"basic_fee_pooled"`
 | |
| 	AdjustFeePooled decimal.Decimal `json:"adjustFeePooled" db:"adjust_fee_pooled"`
 | |
| 	LossFeePooled   decimal.Decimal `json:"lossFeePooled" db:"loss_fee_pooled"`
 | |
| 	FinalPooled     decimal.Decimal `json:"finalPooled" db:"final_pooled"`
 | |
| 	FinalCharge     decimal.Decimal `json:"finalCharge" db:"final_charge"`
 | |
| 	Invoice         []string        `json:"invoice" db:"invoice"`
 | |
| 	Meters          []NestedMeter   `json:"meters" db:"meters"`
 | |
| 	Pooled          []NestedMeter   `json:"pooled" db:"pooled"`
 | |
| }
 | |
| 
 | |
| type ReportTask struct {
 | |
| 	Id             string         `json:"id"`
 | |
| 	LastModifiedAt types.DateTime `json:"lastModifiedAt" db:"last_modified_at"`
 | |
| 	Status         int16          `json:"status"`
 | |
| 	Message        *string        `json:"message"`
 | |
| }
 | |
| 
 | |
| type SimplifiedTenementCharge struct {
 | |
| 	ReportId         string          `json:"reportId" db:"report_id"`
 | |
| 	Period           types.DateRange `json:"period"`
 | |
| 	TotalConsumption decimal.Decimal `json:"totalConsumption" db:"total_consumption"`
 | |
| 	FinalCharge      decimal.Decimal `json:"finalCharge" db:"final_charge"`
 | |
| }
 |