forked from free-lancers/electricity_bill_calc_service
enhance(calculate):基本完成摊薄总计部分的计算改动。
This commit is contained in:
@@ -41,27 +41,7 @@ type EndUserOverallPart struct {
|
||||
ValleyFee decimal.NullDecimal `json:"valleyFee"`
|
||||
}
|
||||
|
||||
type DilutedConsumptionOverallPart struct {
|
||||
Overall decimal.Decimal `json:"overall"`
|
||||
OverallPrice decimal.Decimal `json:"overallPrice"`
|
||||
ConsumptionFee decimal.Decimal `json:"consumptionFee"`
|
||||
OverallFee decimal.Decimal `json:"overallFee"`
|
||||
Critical decimal.NullDecimal `json:"critical"`
|
||||
CriticalPrice decimal.NullDecimal `json:"criticalPrice"`
|
||||
CriticalFee decimal.NullDecimal `json:"criticalFee"`
|
||||
Peak decimal.NullDecimal `json:"peak"`
|
||||
PeakPrice decimal.NullDecimal `json:"peakPrice"`
|
||||
PeakFee decimal.NullDecimal `json:"peakFee"`
|
||||
Flat decimal.NullDecimal `json:"flat"`
|
||||
FlatPrice decimal.NullDecimal `json:"flatPrice"`
|
||||
FlatFee decimal.NullDecimal `json:"flatFee"`
|
||||
Valley decimal.NullDecimal `json:"valley"`
|
||||
ValleyPrice decimal.NullDecimal `json:"valleyPrice"`
|
||||
ValleyFee decimal.NullDecimal `json:"valleyFee"`
|
||||
Proportion decimal.Decimal `json:"proportion"`
|
||||
}
|
||||
|
||||
type PublicConsumptionOverallPart struct {
|
||||
type ConsumptionOverallPart struct {
|
||||
Overall decimal.Decimal `json:"overall"`
|
||||
OverallPrice decimal.Decimal `json:"overallPrice"`
|
||||
ConsumptionFee decimal.Decimal `json:"consumptionFee"`
|
||||
@@ -122,15 +102,15 @@ type EndUserSummary struct {
|
||||
}
|
||||
|
||||
type Publicity struct {
|
||||
Report Report `json:"index"`
|
||||
User UserDetail `json:"enterprise"`
|
||||
Park Park `json:"park"`
|
||||
Paid PaidPart `json:"paid"`
|
||||
EndUser EndUserOverallPart `json:"endUserSum"`
|
||||
Loss LossPart `json:"loss"`
|
||||
DilutedConsumptionOverall DilutedConsumptionOverallPart `json:"diluted"`
|
||||
PublicConsumptionOverall PublicConsumptionOverallPart `json:"public"`
|
||||
OtherCollections OtherShouldCollectionPart `json:"others"`
|
||||
Maintenance MaintenancePart `json:"maintenance"`
|
||||
EndUserDetails []EndUserSummary `json:"endUser"`
|
||||
Report Report `json:"index"`
|
||||
User UserDetail `json:"enterprise"`
|
||||
Park Park `json:"park"`
|
||||
Paid PaidPart `json:"paid"`
|
||||
EndUser ConsumptionOverallPart `json:"endUserSum"`
|
||||
Loss LossPart `json:"loss"`
|
||||
DilutedConsumptionOverall ConsumptionOverallPart `json:"diluted"`
|
||||
PublicConsumptionOverall ConsumptionOverallPart `json:"public"`
|
||||
OtherCollections OtherShouldCollectionPart `json:"others"`
|
||||
Maintenance MaintenancePart `json:"maintenance"`
|
||||
EndUserDetails []EndUserSummary `json:"endUser"`
|
||||
}
|
||||
|
@@ -57,6 +57,22 @@ type Consumptions struct {
|
||||
Proportion decimal.NullDecimal `json:"proportion"`
|
||||
}
|
||||
|
||||
func NewConsumptions() Consumptions {
|
||||
return Consumptions{
|
||||
Consumption: decimal.NewNullDecimal(decimal.Zero),
|
||||
ConsumptionFee: decimal.NewNullDecimal(decimal.Zero),
|
||||
Critical: decimal.NewNullDecimal(decimal.Zero),
|
||||
Peak: decimal.NewNullDecimal(decimal.Zero),
|
||||
PeakFee: decimal.NewNullDecimal(decimal.Zero),
|
||||
Flat: decimal.NewNullDecimal(decimal.Zero),
|
||||
CriticalFee: decimal.NewNullDecimal(decimal.Zero),
|
||||
FlatFee: decimal.NewNullDecimal(decimal.Zero),
|
||||
Valley: decimal.NewNullDecimal(decimal.Zero),
|
||||
ValleyFee: decimal.NewNullDecimal(decimal.Zero),
|
||||
Proportion: decimal.NewNullDecimal(decimal.Zero),
|
||||
}
|
||||
}
|
||||
|
||||
func (s ReportSummary) Validate() (bool, error) {
|
||||
amountSum := decimal.Sum(s.Critical, s.Peak, s.Valley)
|
||||
if amountSum.GreaterThan(s.Overall) {
|
||||
|
Reference in New Issue
Block a user