satellite/payments/stripecoinpayments: add basic summary for invoice
generation commands https://storjlabs.atlassian.net/browse/USR-823 Change-Id: I24a7dec56973abcbbb66e70842e3aa2b7c01a4b3
This commit is contained in:
parent
410d897840
commit
e48177ce81
@ -627,6 +627,7 @@ func (service *Service) InvoiceApplyProjectRecords(ctx context.Context, period t
|
|||||||
return Error.New("allowed for past periods only")
|
return Error.New("allowed for past periods only")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projectRecords := 0
|
||||||
recordsPage, err := service.db.ProjectRecords().ListUnapplied(ctx, 0, service.listingLimit, start, end)
|
recordsPage, err := service.db.ProjectRecords().ListUnapplied(ctx, 0, service.listingLimit, start, end)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
@ -636,6 +637,8 @@ func (service *Service) InvoiceApplyProjectRecords(ctx context.Context, period t
|
|||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projectRecords += len(recordsPage.Records)
|
||||||
|
|
||||||
for recordsPage.Next {
|
for recordsPage.Next {
|
||||||
if err = ctx.Err(); err != nil {
|
if err = ctx.Err(); err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
@ -650,8 +653,11 @@ func (service *Service) InvoiceApplyProjectRecords(ctx context.Context, period t
|
|||||||
if err = service.applyProjectRecords(ctx, recordsPage.Records); err != nil {
|
if err = service.applyProjectRecords(ctx, recordsPage.Records); err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projectRecords += len(recordsPage.Records)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service.log.Info("Number of processed project records.", zap.Int("Project Records", projectRecords))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,6 +748,7 @@ func (service *Service) InvoiceApplyCoupons(ctx context.Context, period time.Tim
|
|||||||
return Error.New("allowed for past periods only")
|
return Error.New("allowed for past periods only")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
couponsUsages := 0
|
||||||
usagePage, err := service.db.Coupons().ListUnapplied(ctx, 0, service.listingLimit, start)
|
usagePage, err := service.db.Coupons().ListUnapplied(ctx, 0, service.listingLimit, start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
@ -751,6 +758,8 @@ func (service *Service) InvoiceApplyCoupons(ctx context.Context, period time.Tim
|
|||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
couponsUsages += len(usagePage.Usages)
|
||||||
|
|
||||||
for usagePage.Next {
|
for usagePage.Next {
|
||||||
if err = ctx.Err(); err != nil {
|
if err = ctx.Err(); err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
@ -765,8 +774,11 @@ func (service *Service) InvoiceApplyCoupons(ctx context.Context, period time.Tim
|
|||||||
if err = service.applyCoupons(ctx, usagePage.Usages); err != nil {
|
if err = service.applyCoupons(ctx, usagePage.Usages); err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
couponsUsages += len(usagePage.Usages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service.log.Info("Number of processed coupons usages.", zap.Int("Coupons Usages", couponsUsages))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,6 +947,7 @@ func (service *Service) CreateInvoices(ctx context.Context, period time.Time) (e
|
|||||||
return Error.New("allowed for past periods only")
|
return Error.New("allowed for past periods only")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invoices := 0
|
||||||
cusPage, err := service.db.Customers().List(ctx, 0, service.listingLimit, end)
|
cusPage, err := service.db.Customers().List(ctx, 0, service.listingLimit, end)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
@ -950,6 +963,8 @@ func (service *Service) CreateInvoices(ctx context.Context, period time.Time) (e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invoices += len(cusPage.Customers)
|
||||||
|
|
||||||
for cusPage.Next {
|
for cusPage.Next {
|
||||||
if err = ctx.Err(); err != nil {
|
if err = ctx.Err(); err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
@ -969,8 +984,11 @@ func (service *Service) CreateInvoices(ctx context.Context, period time.Time) (e
|
|||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invoices += len(cusPage.Customers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service.log.Info("Number of created draft invoices.", zap.Int("Invoices", invoices))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user