Committer: vtroitsky
LJSUP-13935: Show correct Journal Promo transactions in the user's wallet historyU trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm U trunk/cgi-bin/LJ/Widget/Shop/History.pm
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm =================================================================== --- trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm 2012-10-17 12:07:31 UTC (rev 12777) +++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm 2012-10-17 12:52:14 UTC (rev 12778) @@ -27,6 +27,18 @@ return $self->{promoted_object} ? $self->{promoted_object}->owner : undef; } +=item get_promotion + Return promotion, in case in exists for current PayItem +=cut +sub get_promotion { + my ($self) = @_; + $self->{promotion} ||= LJ::Pay::Promotion->new_from_cart_item($self); + return $self->{promotion}; +} + +=item get_product_name + Get product name +=cut sub get_product_name { my ($self, $subitem) = @_; $subitem = $self->get_subitem(); @@ -67,6 +79,25 @@ }; } +=item get_wallet_history_desc + Return +=cut +sub get_wallet_history_desc { + my ($self, $buyer) = @_; + my $subitem = $self->get_subitem(); + + my $prefix = ($subitem && $subitem =~ /^commercial/ ? 'commercial' : ( $subitem =~ /^journal/ ? 'journals' : 'selfpromo')); + if ( $self->get_prop($prefix.'_type') eq 'buyout' ) { + return LJ::Lang::ml( + 'wallet.widget.history.des.'.$prefix.'_refund', + { 'buyer' => $buyer->ljuser_display } + ); + } + return LJ::Lang::ml( + 'wallet.widget.history.des.'.$prefix.'_refund.generic' + ); +} + sub is_tangible {1} sub allow_repeat_cart {0} Modified: trunk/cgi-bin/LJ/Widget/Shop/History.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/Shop/History.pm 2012-10-17 12:07:31 UTC (rev 12777) +++ trunk/cgi-bin/LJ/Widget/Shop/History.pm 2012-10-17 12:52:14 UTC (rev 12778) @@ -163,16 +163,7 @@ } if ( my $it = $it{'SelfPromo'} ) { - if ( $it->get_prop('selfpromo_type') eq 'buyout' ) { - return LJ::Lang::ml( - 'wallet.widget.history.des.selfpromo_refund', - { 'buyer' => $buyer->ljuser_display } - ); - } - - return LJ::Lang::ml( - 'wallet.widget.history.des.selfpromo_refund.generic' - ); + return $it->get_wallet_history_desc($buyer); } if ( $logitem->userid == $buyer_userid ) {