Page MenuHomekolab.org

Wallet magic
ClosedPublic

Authored by vanmeeuwen on Apr 8 2020, 5:17 PM.

Details

Reviewers
machniak
vanmeeuwen
Group Reviewers
Restricted Project
Commits
rKda13578ce560: Wallet magic
Summary

Show-case implementation of how to calculate until when a wallet's balance lasts.

Test Plan
$ ./artisan user:wallets john@kolab.org
5337dced-7227-4cac-8c66-4b4720cca873
$ ./artisan wallet:expected
expect charging wallet 5337dced-7227-4cac-8c66-4b4720cca873 for user john@kolab.org with 999
$ ./artisan wallet:until $(./artisan user:wallets john@kolab.org)
0 lasts until 2020-04-08 15:10:21 (a month costs 3541)
$ ./artisan wallet:set-balance $(./artisan user:wallets john@kolab.org) $(( 999 + 3541 ))
$ ./artisan wallet:until $(./artisan user:wallets john@kolab.org)
4540 lasts until 2020-05-08 15:10:21 (a month costs 3541)

Diff Detail

Repository
rK kolab
Branch
arcpatch-D1150
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 29623
Build 10903: arc lint + arc unit

Event Timeline

vanmeeuwen requested review of this revision.Apr 8 2020, 5:17 PM
vanmeeuwen created this revision.
vanmeeuwen planned changes to this revision.Apr 8 2020, 5:42 PM
vanmeeuwen edited the test plan for this revision. (Show Details)Apr 8 2020, 5:52 PM
vanmeeuwen updated this revision to Diff 3424.May 28 2020, 12:33 PM
  • Remove superfluous commands already a part of different differentials
vanmeeuwen added a reviewer: Restricted Project.May 28 2020, 12:33 PM
vanmeeuwen added a subscriber: Restricted Project.
machniak requested changes to this revision.May 28 2020, 12:44 PM
machniak added a subscriber: machniak.

I think we'll need this code as a method on the Wallet object, as it will be needed also for UI. And we need a test. I don't understand the code, so I might get back to it later.

src/app/Console/Commands/WalletUntil.php
70

This is the same query but different order as above. I guess, we could do a single select.

This revision now requires changes to proceed.May 28 2020, 12:44 PM
vanmeeuwen updated this revision to Diff 3436.May 28 2020, 1:26 PM
  • Single query
vanmeeuwen updated this revision to Diff 3442.May 28 2020, 1:55 PM
  • Remove superfluous commands already a part of different differentials
  • Single query
  • Some initial extras
  • A simpler version of the same thing
vanmeeuwen updated this revision to Diff 3445.May 28 2020, 1:57 PM
  • Remove superfluous commands already a part of different differentials
  • Single query
  • Some initial extras
vanmeeuwen updated this revision to Diff 3448.May 28 2020, 2:01 PM
  • Same test for wallet function
vanmeeuwen updated this revision to Diff 3451.May 28 2020, 2:03 PM
  • Simpler version
vanmeeuwen updated this revision to Diff 3454.May 28 2020, 2:05 PM
  • Implement costsPerDay()
vanmeeuwen added inline comments.May 28 2020, 2:06 PM
src/app/Utils.php
27

Note that this is fixed in a different differential.

machniak updated this revision to Diff 3541.Jun 5 2020, 1:44 PM
  • Fix error due to missing use statements
  • Create Wallet::balanceLastsUntil()
machniak requested changes to this revision.EditedJun 5 2020, 1:47 PM

@vanmeeuwen, I rebased, fixed obvious bugs and refactored the code so now we have Wallet::balanceLastsUntil() that we need tests for in tests/Feature/WalletTest::testBalanceLastsUntil().

This revision now requires changes to proceed.Jun 5 2020, 1:47 PM
vanmeeuwen accepted this revision.Jun 10 2020, 11:30 AM
This revision was not accepted when it landed; it landed in state Needs Revision.Jun 10 2020, 11:41 AM
Closed by commit rKda13578ce560: Wallet magic (authored by machniak). · Explain Why
This revision was automatically updated to reflect the committed changes.