sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[ljcom] r12857: LJSUP-14051: Show Journal Promo profit i...

Committer: vtroitsky
LJSUP-14051: Show Journal Promo profit in paidsummary.bml
U   trunk/htdocs/admin/accounts/paidsummary.bml
Modified: trunk/htdocs/admin/accounts/paidsummary.bml
===================================================================
--- trunk/htdocs/admin/accounts/paidsummary.bml	2012-10-31 13:51:56 UTC (rev 12856)
+++ trunk/htdocs/admin/accounts/paidsummary.bml	2012-10-31 14:26:22 UTC (rev 12857)
@@ -158,6 +158,7 @@
                     next;       # skip this item
                 }
                 # left only free items that are refunds for commercial promo
+                # TODO: also we have left admin refunds for journal promo
             }
             $payitems_ref->{$piid} = LJ::Pay::Payment::PayItem->new_memonly(%$row);
             $piid_dates_ref->{$piid} = $payments_ref->{$payid}->{daterecv};
@@ -209,11 +210,23 @@
 
         my $piids = $payid_piids_ref->{ $row->{'payid'} };
         my @items = map { $payitems_ref->{$_} } @$piids;
-        if ( @items == 1 && $items[0]->get_item eq 'selfpromo' && $payments_ref->{ $row->{'payid'} }{'method'} ne 'free' ) {
-            my $it = $items[0];
-            $amount -= $it->get_prop('selfpromo_refund') /
-                LJ::Pay::Wallet::EXCHANGE_RATE;
+
+        if ( @items == 1 && $items[0]->get_item eq 'selfpromo') {
+            my $subitem = $items[0]->get_subitem();
+            if ($subitem && $subitem =~ /^journal/) { # journal promo items
+                my $it = $items[0];
+                my $profit = $it->get_prop('selfpromo_profit');
+                $profit ||= $it->get_prop('journals_profit');
+                $profit ||= 0;
+                $amount = $profit / LJ::Pay::Wallet::EXCHANGE_RATE;
+            } else {
+                if ( $payments_ref->{ $row->{'payid'} }{'method'} ne 'free' ) {
+                    my $it = $items[0];
+                    $amount -= $it->get_prop('selfpromo_refund') /
+                        LJ::Pay::Wallet::EXCHANGE_RATE;
 #warn "selfpromo ".$row->{payid}." amount: $amount";
+                }
+            }
         }
         if ( @items == 1 && $items[0]->get_item eq 'notificationpromo' && $payments_ref->{ $row->{'payid'} }{'method'} ne 'free' ) {
             my $it = $items[0];
@@ -289,7 +302,8 @@
         my $tokens = $payments_ref->{$it->{payid}}->{method} eq 'wallet';
 
         my $amount = $it->{'amt'};
-        if ( $it->get_item eq 'selfpromo' && $payments_ref->{ $it->{'payid'} }{'method'} ne 'free' ) {
+        my $subitem = $it->get_subitem();
+        if ( $it->get_item eq 'selfpromo' && $payments_ref->{ $it->{'payid'} }{'method'} ne 'free' && $subitem !~ /^journal/ ) {
             $amount -= $it->get_prop('selfpromo_refund') /
                 LJ::Pay::Wallet::EXCHANGE_RATE;
 #warn "selfpromo ".$it->{payid}." amount: $amount";
@@ -299,6 +313,12 @@
                 LJ::Pay::Wallet::EXCHANGE_RATE;
         }
 
+        if ( $it->get_item eq 'selfpromo' && $subitem =~ /^journal/) {  # journal promo items
+             my $profit = $it->get_prop('selfpromo_profit');
+             $profit ||= $it->get_prop('journals_profit');
+             $profit ||= 0;
+             $amount = $profit / LJ::Pay::Wallet::EXCHANGE_RATE;
+        }
 
         # find item and subitem key strings
         my $item = $it->{item};
@@ -314,6 +334,8 @@
             my $subitem = $it->get_subitem();
             if ($subitem && $subitem =~ /^commercial/) {
                 $subkey = 'calendar';
+            } elsif ($subitem && $subitem =~ /^journal/) {  # detect journal promo rows
+                $subkey = 'journalpromo';
             } else { 
                 my $sp_type = $it->get_prop('selfpromo') || 'entry';
                 my $sp_country = $it->get_prop('selfpromo_country') || 'cyr';

Tags: bml, ljcom, sunnyman, vtroitsky
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