@@ -776,18 +776,6 @@ func (payment Payments) ProductCharges(ctx context.Context, since, before time.T
776776 return payment .service .accounts .ProductCharges (ctx , user .ID , since , before )
777777}
778778
779- // ProjectsCharges returns how much money current user will be charged for each project which he owns.
780- func (payment Payments ) ProjectsCharges (ctx context.Context , since , before time.Time ) (_ payments.ProjectChargesResponse , err error ) {
781- defer mon .Task ()(& ctx )(& err )
782-
783- user , err := payment .service .getUserAndAuditLog (ctx , "project charges" )
784- if err != nil {
785- return nil , Error .Wrap (err )
786- }
787-
788- return payment .service .accounts .ProjectCharges (ctx , user .ID , since , before )
789- }
790-
791779// ShouldApplyMinimumCharge checks if the minimum charge should be applied to the user.
792780func (payment Payments ) ShouldApplyMinimumCharge (ctx context.Context ) (bool , error ) {
793781 var err error
@@ -5295,27 +5283,24 @@ func (s *Service) GetUsageReport(ctx context.Context, param GetUsageReportParam)
52955283 UserAgent : p .UserAgent ,
52965284 }
52975285
5298- var priceModel payments.ProductUsagePriceModel
5299- if s .config .ProductBasedInvoicing {
5300- _ , priceModel = s .accounts .ProductIdAndPriceForUsageKey (key )
5286+ _ , priceModel := s .accounts .ProductIdAndPriceForUsageKey (key )
53015287
5302- partner := ""
5303- placement := int (storj .DefaultPlacement )
5288+ partner := ""
5289+ placement := int (storj .DefaultPlacement )
53045290
5305- // Split the key to extract partner and placement.
5306- parts := strings .Split (key , "|" )
5307- if len (parts ) >= 1 {
5308- partner = parts [0 ]
5309- }
5310- if len (parts ) >= 2 {
5311- placement64 , err := strconv .ParseInt (parts [1 ], 10 , 32 )
5312- if err == nil {
5313- placement = int (placement64 )
5314- }
5291+ // Split the key to extract partner and placement.
5292+ parts := strings .Split (key , "|" )
5293+ if len (parts ) >= 1 {
5294+ partner = parts [0 ]
5295+ }
5296+ if len (parts ) >= 2 {
5297+ placement64 , err := strconv .ParseInt (parts [1 ], 10 , 32 )
5298+ if err == nil {
5299+ placement = int (placement64 )
53155300 }
5316- item .Placement = storj .PlacementConstraint (placement )
5317- item .UserAgent = []byte (partner )
53185301 }
5302+ item .Placement = storj .PlacementConstraint (placement )
5303+ item .UserAgent = []byte (partner )
53195304
53205305 item , err = s .transformProjectReportItem (item , param .IncludeCost , priceModel )
53215306 if err != nil {
@@ -5351,15 +5336,15 @@ func (s *Service) GetReportRow(param GetUsageReportParam, reportItem accounting.
53515336 if ! param .GroupByProject {
53525337 row = append (row , reportItem .BucketName )
53535338 }
5354- if s .config .ProductBasedInvoicing && s . config . SkuEnabled {
5339+ if s .config .SkuEnabled {
53555340 row = append (row , reportItem .StorageSKU )
53565341 }
53575342 row = append (row , fmt .Sprintf ("%f" , reportItem .Storage ))
53585343 row = append (row , fmt .Sprintf ("%f" , reportItem .StorageTbMonth ))
53595344 if param .IncludeCost {
53605345 row = append (row , fmt .Sprintf ("%f" , reportItem .StorageCost ))
53615346 }
5362- if s .config .ProductBasedInvoicing && s . config . SkuEnabled {
5347+ if s .config .SkuEnabled {
53635348 row = append (row , reportItem .EgressSKU )
53645349 }
53655350 row = append (row , fmt .Sprintf ("%f" , reportItem .Egress ))
@@ -5368,7 +5353,7 @@ func (s *Service) GetReportRow(param GetUsageReportParam, reportItem accounting.
53685353 row = append (row , fmt .Sprintf ("%f" , reportItem .EgressCost ))
53695354 }
53705355 row = append (row , fmt .Sprintf ("%f" , reportItem .ObjectCount ))
5371- if s .config .ProductBasedInvoicing && s . config . SkuEnabled {
5356+ if s .config .SkuEnabled {
53725357 row = append (row , reportItem .SegmentSKU )
53735358 }
53745359 row = append (row , fmt .Sprintf ("%f" , reportItem .SegmentCount ))
@@ -5399,7 +5384,7 @@ func (s *Service) GetUsageReportHeaders(param GetUsageReportParam) (disclaimer [
53995384 "Segment Price (Estimated)" , "Estimated Total Amount" , "Since" , "Before" ,
54005385 }
54015386
5402- if ! s .config .ProductBasedInvoicing || ! s . config . SkuEnabled {
5387+ if ! s .config .SkuEnabled {
54035388 updateHeaders := make ([]string , 0 , len (headers )- 4 )
54045389 for _ , header := range headers {
54055390 if strings .Contains (header , "SKU" ) {
@@ -5438,15 +5423,9 @@ func (s *Service) GetUsageReportHeaders(param GetUsageReportParam) (disclaimer [
54385423func (s * Service ) transformProjectReportItem (item accounting.ProjectReportItem , addCost bool , priceModel payments.ProductUsagePriceModel ) (_ accounting.ProjectReportItem , err error ) {
54395424 hoursPerMonthDecimal := decimal .NewFromInt (hoursPerMonth )
54405425 if priceModel == (payments.ProductUsagePriceModel {}) {
5441- if s .config .ProductBasedInvoicing {
5442- _ , priceModel , err = s .accounts .GetPartnerPlacementPriceModel (string (item .UserAgent ), item .Placement )
5443- if err != nil {
5444- return accounting.ProjectReportItem {}, err
5445- }
5446- } else {
5447- priceModel = payments.ProductUsagePriceModel {
5448- ProjectUsagePriceModel : s .accounts .GetProjectUsagePriceModel (string (item .UserAgent )),
5449- }
5426+ _ , priceModel , err = s .accounts .GetPartnerPlacementPriceModel (string (item .UserAgent ), item .Placement )
5427+ if err != nil {
5428+ return accounting.ProjectReportItem {}, err
54505429 }
54515430 }
54525431 item .ProductName = priceModel .ProductName
0 commit comments