fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-28 10:29 am

[dw-free] relabel check/money order as check/money order/points

[commit: http://hg.dwscoalition.org/dw-free/rev/69063ffdba54]

http://bugs.dwscoalition.org/show_bug.cgi?id=4000

BUG 4000! More helpfully: show users when they used points as the payment
method in their order history and receipts (this doesn't affect how it's
stored in the backend)

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/Shop/Cart.pm
  • htdocs/admin/pay/index.bml
  • htdocs/admin/pay/view.bml
  • htdocs/shop/history.bml
  • htdocs/shop/receipt.bml
  • htdocs/shop/receipt.bml.text
--------------------------------------------------------------------------------
diff -r 92691b2e94a0 -r 69063ffdba54 cgi-bin/DW/Shop/Cart.pm
--- a/cgi-bin/DW/Shop/Cart.pm	Fri Oct 28 17:55:38 2011 +0800
+++ b/cgi-bin/DW/Shop/Cart.pm	Fri Oct 28 18:29:34 2011 +0800
@@ -465,6 +465,15 @@
     return $self->{paymentmethod};
 }
 
+# payment method the user should be aware of
+sub paymentmethod_visible {
+    my $self = $_[0];
+
+    my $paymentmethod = $self->{paymentmethod};
+    return $paymentmethod unless $paymentmethod eq "checkmoneyorder";
+    return ( $self->total_cash == 0 ) ? "points" : $paymentmethod;
+}
+
 
 # get/set email address
 sub email {
diff -r 92691b2e94a0 -r 69063ffdba54 htdocs/admin/pay/index.bml
--- a/htdocs/admin/pay/index.bml	Fri Oct 28 17:55:38 2011 +0800
+++ b/htdocs/admin/pay/index.bml	Fri Oct 28 18:29:34 2011 +0800
@@ -159,7 +159,7 @@
             $body .= "<th>Payment Method</th><th>Status</th><th>Details</th></tr></thead>";
             foreach my $cart ( @carts ) {
                 my $state = $cart->state;
-                my $paymentmethod = $cart->paymentmethod;
+                my $paymentmethod = $cart->paymentmethod_visible;
                 my $paystr = ( $paymentmethod ?
                                    $ML{"/shop/receipt.bml.cart.paymentmethod.$paymentmethod"} :
                                    "(not yet selected)" );
diff -r 92691b2e94a0 -r 69063ffdba54 htdocs/admin/pay/view.bml
--- a/htdocs/admin/pay/view.bml	Fri Oct 28 17:55:38 2011 +0800
+++ b/htdocs/admin/pay/view.bml	Fri Oct 28 18:29:34 2011 +0800
@@ -101,8 +101,9 @@
     my $from = ( defined $u ? $u->ljuser_display : "Logged-out user with uniq: " . $cart->uniq );
 
     my $paymentmethod = $cart->paymentmethod;
-    my $paystr = ( $paymentmethod ?
-                       $ML{"/shop/receipt.bml.cart.paymentmethod.$paymentmethod"} :
+    my $paymentmethod_userfacing = $cart->paymentmethod_visible;
+    my $paystr = ( $paymentmethod_userfacing ?
+                       $ML{"/shop/receipt.bml.cart.paymentmethod.$paymentmethod_userfacing"} :
                        "(not yet selected)" );
 
     $body .= "<h2>Cart #$cartid</h2>";
diff -r 92691b2e94a0 -r 69063ffdba54 htdocs/shop/history.bml
--- a/htdocs/shop/history.bml	Fri Oct 28 17:55:38 2011 +0800
+++ b/htdocs/shop/history.bml	Fri Oct 28 18:29:34 2011 +0800
@@ -43,7 +43,7 @@
     $ret .= "<th>$ML{'.cart.header.paymentmethod'}</th><th>$ML{'.cart.header.status'}</th><th>$ML{'.cart.header.details'}</th></tr></thead>";
     foreach my $cart ( @carts ) {
         my $state = $cart->state;
-        my $paymentmethod = $cart->paymentmethod;
+        my $paymentmethod = $cart->paymentmethod_visible;
         my $date = DateTime->from_epoch( epoch => $cart->starttime );
 
         $ret .= "<tr>";
diff -r 92691b2e94a0 -r 69063ffdba54 htdocs/shop/receipt.bml
--- a/htdocs/shop/receipt.bml	Fri Oct 28 17:55:38 2011 +0800
+++ b/htdocs/shop/receipt.bml	Fri Oct 28 18:29:34 2011 +0800
@@ -34,7 +34,7 @@
         unless $cart;
 
     my $state = $cart->state;
-    my $paymentmethod = $cart->paymentmethod;
+    my $paymentmethod = $cart->paymentmethod_visible;
     my $orderdate = DateTime->from_epoch( epoch => $cart->starttime );
 
     # cart cannot be in open, closed, or checkout state
diff -r 92691b2e94a0 -r 69063ffdba54 htdocs/shop/receipt.bml.text
--- a/htdocs/shop/receipt.bml.text	Fri Oct 28 17:55:38 2011 +0800
+++ b/htdocs/shop/receipt.bml.text	Fri Oct 28 18:29:34 2011 +0800
@@ -15,6 +15,8 @@
 
 .cart.paymentmethod.paypal=PayPal Account
 
+.cart.paymentmethod.points=Points
+
 .cart.status=<strong>Current Order Status:</strong> [[status]]
 
 .cart.status.1|note=This status should never be possible on the receipt page!
--------------------------------------------------------------------------------