forked from free-lancers/electricity_bill_calc_service
feat(report):完成电费公示报表的计算功能。
This commit is contained in:
@@ -36,7 +36,7 @@ type EndUserDetail struct {
|
||||
AdjustValley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustValley"`
|
||||
Overall decimal.NullDecimal `xorm:"numeric(14,2)" json:"overall"`
|
||||
OverallFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"overallFee"`
|
||||
OverallProporttion decimal.Decimal `xorm:"numeric(16,15) not null default 0" json:"-"`
|
||||
OverallProportion decimal.Decimal `xorm:"numeric(16,15) not null default 0" json:"-"`
|
||||
Critical decimal.NullDecimal `xorm:"numeric(14,2)" json:"critical"`
|
||||
CriticalFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"criticalFee"`
|
||||
Peak decimal.NullDecimal `xorm:"numeric(14,2)" json:"peak"`
|
||||
|
@@ -26,7 +26,7 @@ type PaidPart struct {
|
||||
type EndUserOverallPart struct {
|
||||
Overall decimal.Decimal `json:"overall"`
|
||||
OverallPrice decimal.Decimal `json:"overallPrice"`
|
||||
OverallFee decimal.Decimal `json:"overallFee"`
|
||||
OverallFee decimal.Decimal `json:"consumptionFee"`
|
||||
Critical decimal.NullDecimal `json:"critical"`
|
||||
CriticalPrice decimal.NullDecimal `json:"criticalPrice"`
|
||||
CriticalFee decimal.NullDecimal `json:"criticalFee"`
|
||||
@@ -107,7 +107,7 @@ type Publicity struct {
|
||||
EndUser EndUserOverallPart `json:"endUserSum"`
|
||||
Loss LossPart `json:"loss"`
|
||||
PublicConsumptionOverall PublicConsumptionOverallPart `json:"public"`
|
||||
OtherCollections OtherShouldCollectionPart `json:"other"`
|
||||
OtherCollections OtherShouldCollectionPart `json:"others"`
|
||||
Maintenance MaintenancePart `json:"maintenance"`
|
||||
EndUserDetails []EndUserSummary `json:"endUser"`
|
||||
}
|
||||
|
@@ -76,7 +76,11 @@ func (s ReportSummary) Validate() (bool, error) {
|
||||
|
||||
func (s *ReportSummary) CalculatePrices() {
|
||||
s.ConsumptionFee = decimal.NewNullDecimal(s.OverallFee.Sub(s.BasicFee).Sub(s.AdjustFee))
|
||||
s.OverallPrice = decimal.NewNullDecimal(s.ConsumptionFee.Decimal.Div(s.Overall).RoundBank(8))
|
||||
if s.Overall.GreaterThan(decimal.Zero) {
|
||||
s.OverallPrice = decimal.NewNullDecimal(s.ConsumptionFee.Decimal.Div(s.Overall).RoundBank(8))
|
||||
} else {
|
||||
s.OverallPrice = decimal.NewNullDecimal(decimal.Zero)
|
||||
}
|
||||
if s.Critical.GreaterThan(decimal.Zero) {
|
||||
s.CriticalPrice = decimal.NewNullDecimal(s.CriticalFee.Div(s.Critical).RoundBank(8))
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user