Wallet discounts

Authored by machniak on Mar 26 2020, 9:26 AM.



This is an incomplete implementation in that neither;

  • does the UI reflect an opportunity to set a discount to a wallet (or all wallets owned by the user), nor
  • does the UI apply that discount to the listed prices, nor
  • is it tested as part of CI (only manually verified).
Test Plan

None yet

Diff Detail

rK kolab
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vanmeeuwen requested review of this revision.Mar 26 2020, 9:26 AM
vanmeeuwen created this revision.
machniak commandeered this revision.Mar 26 2020, 11:41 AM
machniak added a reviewer: vanmeeuwen.
machniak added a subscriber: machniak.

We'll move forward with a new table: discounts { id, discount, description, code (for vouchers), active } and wallets.discount_id.

machniak updated this revision to Diff 2848.Mar 30 2020, 4:12 PM
  • Wallet discounts (by a separate table)
machniak retitled this revision from Add a discount column to the Wallet model, and commands to control such a discount to Wallet discounts.Mar 31 2020, 7:51 AM
vanmeeuwen requested changes to this revision.Mar 31 2020, 8:22 AM

This will also need a rebase on master for tests to pass.


I've needed to apply;

diff --git a/src/database/migrations/2020_03_30_100000_create_discounts.php b/src/database/migrations/2020_03_30_100000_create_discounts.php
index 282b7de..b522449 100644
--- a/src/database/migrations/2020_03_30_100000_create_discounts.php
+++ b/src/database/migrations/2020_03_30_100000_create_discounts.php
@@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Schema;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
+// phpcs:ignore
 class CreateDiscounts extends Migration
@@ -29,7 +30,7 @@ class CreateDiscounts extends Migration
             function (Blueprint $table) {
-                $table->integer('discount_id')->nullable();
+                $table->integer('discount_id')->unsigned()->nullable();
                     ->on('discounts')->onDelete('set null');
@@ -44,13 +45,14 @@ class CreateDiscounts extends Migration
     public function down()
-        Schema::dropIfExists('discounts');
             function (Blueprint $table) {
+                $table->dropForeign(['discount_id']);
+        Schema::dropIfExists('discounts');
This revision now requires changes to proceed.Mar 31 2020, 8:22 AM
machniak updated this revision to Diff 2878.Mar 31 2020, 5:27 PM
  • Wallet discounts (by a separate table)
  • Fix discount migration, use uuid as discount identifier
  • Add simple discount tests
  • Add discount test
  • Display discounted prices in UI
vanmeeuwen updated this revision to Diff 2884.Mar 31 2020, 5:59 PM
  • Validate with added
  • Make the columns for this output sorted
vanmeeuwen accepted this revision.Mar 31 2020, 6:02 PM

A previous careless merge caused tests that counted on 3 users for to fail, I hope you don't mind I simply fixed them here.

I also made the discount:list output machine-readable.


This revision is now accepted and ready to land.Mar 31 2020, 6:02 PM
This revision was automatically updated to reflect the committed changes.