Page MenuHomePhorge

Wallet discounts
ClosedPublic

Authored by machniak on Mar 26 2020, 9:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 22, 5:05 PM
Unknown Object (File)
Fri, Mar 8, 2:36 AM
Unknown Object (File)
Sun, Mar 3, 7:08 AM
Unknown Object (File)
Feb 26 2024, 5:34 AM
Unknown Object (File)
Feb 22 2024, 2:21 AM
Unknown Object (File)
Feb 14 2024, 9:03 PM
Unknown Object (File)
Feb 11 2024, 11:15 AM
Unknown Object (File)
Feb 7 2024, 10:09 PM
Subscribers
Restricted Project

Details

Summary

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

Repository
rK kolab
Branch
arcpatch-D1063
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 28867
Build 10438: arc lint + arc unit

Event Timeline

vanmeeuwen created this revision.
machniak added a reviewer: vanmeeuwen.
machniak subscribed.

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

  • 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

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

src/database/migrations/2020_03_30_100000_create_discounts.php
56

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
         Schema::table(
             'wallets',
             function (Blueprint $table) {
-                $table->integer('discount_id')->nullable();
+                $table->integer('discount_id')->unsigned()->nullable();
 
                 $table->foreign('discount_id')->references('id')
                     ->on('discounts')->onDelete('set null');
@@ -44,13 +45,14 @@ class CreateDiscounts extends Migration
      */
     public function down()
     {
-        Schema::dropIfExists('discounts');
-
         Schema::table(
             'wallets',
             function (Blueprint $table) {
+                $table->dropForeign(['discount_id']);
                 $table->dropColumn('discount_id');
             }
         );
+
+        Schema::dropIfExists('discounts');
     }
 }
This revision now requires changes to proceed.Mar 31 2020, 8:22 AM
  • 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
  • Validate with joe@kolab.org added
  • Make the columns for this output sorted

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

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

LGTM.

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.