changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[ljcom] r7558: LJSUP-4585

Committer: gproschaev
LJSUP-4585


U   branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm
U   branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm
U   branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
U   branches/shop/cgi-bin/paylib.pl
U   branches/shop/htdocs/manage/account/modify.bml
U   branches/shop/htdocs/shop/view.bml
U   branches/shop/ssldocs/manage/account/cc.bml
Modified: branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm
===================================================================
--- branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm	2009-08-10 07:22:06 UTC (rev 7557)
+++ branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm	2009-08-10 08:34:26 UTC (rev 7558)
@@ -3,7 +3,8 @@
 use base LJ::Pay::Payment::PayItem::Addon;
 
 sub is_valid_bool_bonus {
-    my ($item, $qty, $is_rec) = @_;
+    my $self = shift;
+    my ($item, $qty) = ($self->{item}, $self->{qty});
 
     # allow passing of an $it hash
     if (ref $item) {
@@ -15,7 +16,7 @@
     return 0 unless ref $itrec;
     return 0 unless $itrec->{type} eq 'bool';
     return 0 unless ref $itrec->{items}->{$qty};
-    return 0 unless defined $itrec->{items}->{$qty}->{$is_rec ? 'amount_rec' : 'amount'};
+    return 0 unless defined $itrec->{items}->{$qty}->{'amount_rec'};
     return 1;
 }
 
@@ -105,10 +106,8 @@
     my $self = shift;
     my %opts = @_;
     
-    my $item = $self->item;
-
-    return undef unless LJ::Pay::is_valid_bool_bonus($item, $self->{qty}, 1);
-    return $LJ::Pay::Payment::PayItem::Addon::bonus{$item}->{items}->{$self->{qty}}->{'amount_rec'};
+    return undef unless $self->is_valid_bool_bonus;
+    return $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{items}->{$self->{qty}}->{'amount_rec'};
 }
 
 sub can_be_added {
@@ -134,7 +133,7 @@
 sub calculate_price {
     my ($self, $is_gift, $cartobj) = @_;
 
-    if (is_valid_bool_bonus($self->{item}, $self->{qty})) {
+    if ($self->is_valid_bool_bonus) {
         $self->{'amt'} = $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{items}->{$self->{qty}}->{'amount'};
     } else {
         $self->{'amt'} = undef;

Modified: branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm
===================================================================
--- branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm	2009-08-10 07:22:06 UTC (rev 7557)
+++ branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm	2009-08-10 08:34:26 UTC (rev 7558)
@@ -123,7 +123,9 @@
 }
 
 sub is_valid_sized_bonus {
-    my ($item, $size, $qty, $is_rec) = @_;
+    my $self = shift;
+    my ($size, $qty) = ($self->{subitem}, $self->{qty});
+    my $is_rec = shift || 1;
 
     # allow passing of an $it hash
     if (ref $item) {
@@ -142,8 +144,11 @@
 }
 
 sub get_sized_bonus_price {
-    my ($u, $cartobj, $item, $size, $qty) = @_;
+    my $self = shift;
+    my ($u, $cartobj) = @_;
 
+    my ($item, $size, $qty) = ($self->{item}, $self->{size}, $self->{qty});
+
     my $userid = LJ::want_userid($u);
 
     # allow passing of an $it hash
@@ -155,8 +160,9 @@
     }
 
     # easy/obvious checks
+    my $item_obj = LJ::Pay::Payment::PayItem->new_memonly(item => $item, subitem => $size, qty => $qty);
     return undef unless $userid && $size > 0 &&
-        is_valid_sized_bonus($item, $size, $qty, 0);
+        $item_obj->is_valid_sized_bonus(0);
 
     # total price of this item with no comp
     my $total_price = $LJ::Pay::Payment::PayItem::Addon::bonus{$item}->{'items'}->{$size}->{'qty'}->{$qty}->{'amount'};
@@ -222,10 +228,8 @@
     my $self = shift;
     my %opts = @_;
 
-    my $item = $self->item;
-
-    return undef unless LJ::Pay::is_valid_sized_bonus($item, $self->{amt}, $self->{qty});
-    return $LJ::Pay::Payment::PayItem::Addon::bonus{$item}->{'items'}->{$self->{amt}}->{'qty'}->{$self->{qty}}->{'amount_rec'};
+    return undef unless $self->is_valid_sized_bonus;
+    return $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{'items'}->{$self->{amt}}->{'qty'}->{$self->{qty}}->{'amount_rec'};
 }
 
 sub can_be_added {
@@ -261,7 +265,7 @@
     my ($prev_exp, $prev_size) = get_bonus_dim($remote, $self->{item});
     $self->{'subitem'} = "$self->{subitem}-$prev_exp-$prev_size";
 
-    $self->{'amt'} = get_sized_bonus_price($remote, $cartobj, $self);
+    $self->{'amt'} = $self->get_sized_bonus_price($remote, $cartobj);
 }
 
 

Modified: branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
===================================================================
--- branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2009-08-10 07:22:06 UTC (rev 7557)
+++ branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2009-08-10 08:34:26 UTC (rev 7558)
@@ -54,8 +54,10 @@
 #       99:    permanent account (historically)
 #       100+:  exact unixtime when item should expire
 sub apply_bonus_item {
-    my ($u, $item, $subitem, $qty, $payid) = @_;
+    my ($self, $u, $payid) = @_;
 
+    my ($item, $subitem, $qty) = ($self->{item}, $self->{subitem}, $self->{qty});
+
     # allow u/payitem objects passed optionally
     my $userid = LJ::want_userid($u);
     if (ref $item) {
@@ -287,7 +289,8 @@
 
     my $new_exp = $to_exp + $add_secs;
 
-    apply_bonus_item($to, $item, '', $new_exp);
+    my $item_obj = LJ::Pay::Payment::PayItem->new_memonly( item => $item, qty => $new_exp );
+    $item_obj->apply_bonus_item($to);
     expire_bonus($from, $item, "force");
 
     return $add_secs;
@@ -522,7 +525,7 @@
     return (0, undef, undef) unless LJ::Pay::get_lock($rcpt_u);
 
     # apply the bonus item to the recipient user's account
-    my $res = apply_bonus_item($rcpt_u, $self);
+    my $res = $self->apply_bonus_item($rcpt_u);
 
     # release lock and close regardless of results of operation
     LJ::Pay::release_lock($rcpt_u);

Modified: branches/shop/cgi-bin/paylib.pl
===================================================================
--- branches/shop/cgi-bin/paylib.pl	2009-08-10 07:22:06 UTC (rev 7557)
+++ branches/shop/cgi-bin/paylib.pl	2009-08-10 08:34:26 UTC (rev 7558)
@@ -76,15 +76,11 @@
 sub remove_paid_time   { return LJ::Pay::Payment::PayItem::PaidAccount::remove_paid_time(@_); }
 sub clothing_availability { return LJ::Pay::Payment::PayItem::Clothes::clothing_availability(@_); }
 sub get_bonus_dim      { return LJ::Pay::Payment::PayItem::Addon::Sized::get_bonus_dim(@_); }
-sub apply_bonus_item   { return LJ::Pay::Payment::PayItem::Addon::apply_bonus_item(@_); }
 sub expire_bonus       { return LJ::Pay::Payment::PayItem::Addon::expire_bonus(@_); }
 sub transfer_bonus     { return LJ::Pay::Payment::PayItem::Addon::transfer_bonus(@_); }
 sub activate_frozen_bonus { return LJ::Pay::Payment::PayItem::Addon::activate_frozen_bonus(@_); }
 sub freeze_bonus       { return LJ::Pay::Payment::PayItem::Addon::freeze_bonus(@_); }
 sub remove_paid_account   { return LJ::Pay::Payment::PayItem::PaidAccount::remove_paid_account(@_); }
-sub is_valid_bool_bonus   { return LJ::Pay::Payment::PayItem::Addon::Boolean::is_valid_bool_bonus(@_); }
-sub is_valid_sized_bonus  { return LJ::Pay::Payment::PayItem::Addon::Sized::is_valid_sized_bonus(@_); }
-sub get_sized_bonus_price { return LJ::Pay::Payment::PayItem::Addon::Sized::get_sized_bonus_price(@_); }
 sub paid_account_price { return LJ::Pay::Payment::PayItem::PaidAccount::paid_account_price(@_); }
 sub new_coupon         { return LJ::Pay::Payment::PayItem::Coupon::new_coupon(@_); }
 sub coupon_loadrow     { return LJ::Pay::Payment::PayItem::Coupon::coupon_loadrow(@_); }

Modified: branches/shop/htdocs/manage/account/modify.bml
===================================================================
--- branches/shop/htdocs/manage/account/modify.bml	2009-08-10 07:22:06 UTC (rev 7557)
+++ branches/shop/htdocs/manage/account/modify.bml	2009-08-10 08:34:26 UTC (rev 7558)
@@ -559,12 +559,7 @@
                             $max->($rec->get_next_check, $rit->get_exptime) :
                             $rec->get_next_check;
 
-                        $rv = LJ::Pay::apply_bonus_item(
-                                                        $u,
-                                                        $name,
-                                                        $size,
-                                                        $qty
-                                                        );
+                        $rv = $pit->apply_bonus_item( $u );
                         return $err->(BML::ml('.error.cantapplybonusitem', {'item' => $name, 'errormsg' => $@}), 1) unless $rv;
                     }
                 }

Modified: branches/shop/htdocs/shop/view.bml
===================================================================
--- branches/shop/htdocs/shop/view.bml	2009-08-10 07:22:06 UTC (rev 7557)
+++ branches/shop/htdocs/shop/view.bml	2009-08-10 08:34:26 UTC (rev 7558)
@@ -376,7 +376,7 @@
                         # will be interpretted as item-subitem-qty
                         my $amt = $sizeit->{'qty'}->{$qty}->{'amount'};
                         next unless $amt;
-                        my $amt_comp = LJ::Pay::get_sized_bonus_price($remote, $cartobj, "diskquota", $size, $qty);
+                        my $amt_comp = $item->get_sized_bonus_price($remote, $cartobj);
                         my $name  = BML::ml('.xmonths', {'nummonths' => $qty});
                         my $price = " - \$$amt.00 USD";
                         $price .= ($amt == $amt_comp ? "" : "; to upgrade: \$$amt_comp");

Modified: branches/shop/ssldocs/manage/account/cc.bml
===================================================================
--- branches/shop/ssldocs/manage/account/cc.bml	2009-08-10 07:22:06 UTC (rev 7557)
+++ branches/shop/ssldocs/manage/account/cc.bml	2009-08-10 08:34:26 UTC (rev 7558)
@@ -376,13 +376,7 @@
 
                             my $payid = $pmt->get_payid;
 
-                            $rv = LJ::Pay::apply_bonus_item(
-                                                            $u,
-                                                            $name,
-                                                            $size,
-                                                            $qty,
-                                                            $payid
-                                                            );
+                            $rv = $pit->apply_bonus_item( $u, $payid );
                             $die->( BML::ml('.error.cantapplybonusitem', {'item' => $name}), 1, $pmt ) unless $rv;
                         }
 

Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments