package IIffdf54f1494b3bf443f066e7a818a029::mod_stats_sales; use strict; use base qw/II720d6e18aa34327713eb014408fc9144/; use IIbbd7c6cf33a8b724d5937c621b455d05; use IIc006e1d88f66a3969ffd0192be9acb1b; sub search { my ($class, $qh) = @_; my (@sea, @sea_sales, @sea_comms); push @sea, made_after => $qh->{date_after} if $qh->{date_after}; push @sea, made_until => $qh->{date_before} if $qh->{date_before}; push @sea, packs => $qh->{packs} if $qh->{packs}; push @sea, prods => $qh->{prods} if $qh->{prods}; if ($qh->{no_recur}) { push @sea_sales, recur_opt => 0; push @sea_comms, recur_no => 1; } my %dataSales = map { $_->{refunded} => $_ } II720d6e18aa34327713eb014408fc9144::lIIlIIlIIIIlIIIl($II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$II982446f8950cc3dc59e487adba22df54::llIllIIIIIIIlIIl},100,$II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllllIIIIIlIllIl})->getRecords( "count(*) as num,sum(jin_sale.amount) as amount,jin_sale.refunded", @sea, @sea_sales, paid => 1, GROUP => "jin_sale.refunded", ); my %dataComms = map { my $k = $_->{paid}.$_->{cancelled}; $k => $_ } II982446f8950cc3dc59e487adba22df54::IIlllIlIIllIIlll($II720d6e18aa34327713eb014408fc9144::llIlIIIlIlIlIlIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIIlIlIlIlIIIl},121,$II720d6e18aa34327713eb014408fc9144::llIlIIIlIlIlIlIl{$II982446f8950cc3dc59e487adba22df54::lIIlIIIIIlIlIllI})->getRecords( "count(*) as num,sum(jin_commission.amount) as amount,jin_commission.paid,jin_commission.cancelled", @sea, @sea_comms, paid_only => 1, GROUP => "jin_commission.paid,jin_commission.cancelled", ); [ { name => 'All sales', sum => ($dataSales{0}{amount} + $dataSales{1}{amount}), num => (0 + $dataSales{0}{num}), }, { name => 'Refunded sales', sum => $dataSales{1}{amount}, num => (0 + $dataSales{1}{num}), }, { name => 'Commissions', sum => ($dataComms{'00'}{amount} + $dataComms{'10'}{amount}), num => (0 + $dataComms{'00'}{num} + $dataComms{'10'}{num}), }, { name => 'Paid commissions', sum => $dataComms{'10'}{amount}, num => (0 + $dataComms{'10'}{num}), }, { name => 'Unpaid commissions', sum => $dataComms{'00'}{amount}, num => (0 + $dataComms{'00'}{num}), }, { name => 'Refunded commissions', sum => ($dataComms{'01'}{amount} + $dataComms{'11'}{amount}), num => (0 + $dataComms{'01'}{num} + $dataComms{'11'}{num}), }, { name => 'Admin gross profit', sum => (0 + $dataSales{0}{amount} - $dataComms{'00'}{amount} - $dataComms{'10'}{amount}), }, ]; } 1; 