<h3 class="dashboard_widget_title"> <span><?php self::_e('Invoice Dashboard'); ?> </span> </h3> <div class="dashboard_widget inside"> <div class="main"> <?php $invoice_data = SI_Reporting::total_invoice_data(); $week_payment_data = SI_Reporting::total_payment_data('week'); $last_week_payment_data = SI_Reporting::total_payment_data('lastweek'); $month_payment_data = SI_Reporting::total_payment_data('month'); $last_month_payment_data = SI_Reporting::total_payment_data('lastmonth'); $year_payment_data = SI_Reporting::total_payment_data('year'); $last_year_payment_data = SI_Reporting::total_invoice_data('lastyear'); ?> <dl> <dt><?php self::_e('Outstanding'); ?> </dt> <dd><?php sa_formatted_money($invoice_data['balance']); ?> </dd> <dt><?php self::_e('Paid (this week)'); ?>
<div class="dashboard_widget inside"> <div class="main"> <?php $invoice_data = SI_Reporting::total_invoice_data(); $week_payment_data = SI_Reporting::total_payment_data('week'); $last_week_payment_data = SI_Reporting::total_payment_data('lastweek'); $month_payment_data = SI_Reporting::total_payment_data('month'); $last_month_payment_data = SI_Reporting::total_payment_data('lastmonth'); $year_payment_data = SI_Reporting::total_payment_data('year'); $last_year_payment_data = SI_Reporting::total_payment_data('lastyear'); ?> <dl> <dt><?php _e('Outstanding', 'sprout-invoices'); ?> </dt> <dd><?php sa_formatted_money($invoice_data['balance']); ?> </dd> <dt><?php _e('Paid (this week)', 'sprout-invoices'); ?> </dt> <dd><?php sa_formatted_money($week_payment_data['totals']); ?> </dd>
function test_last_year_paid() { $invoice_totaled = 0; $payment_totaled = 0; $context_totaled = 0; $context2_totaled = 0; $invoice_totals = array(1000, 1000, 1000, 1000, 1000, 2000); $payment_totals = array(500, 200, 400, 50, 700, 100.75); // 1950.75 // Build invoices and payments from last month foreach ($invoice_totals as $key => $total) { $id = $this->build_test_invoice($total); $this->build_test_payment($id, $payment_totals[$key], strtotime('-1 year')); $invoice_totaled += (double) $total; $payment_totaled += (double) $payment_totals[$key]; $context_totaled += (double) $payment_totals[$key]; } // time not last year. $min_epoch = strtotime('2009-01-01'); $max_epoch = strtotime('2012-12-21'); // Random invoices and payments for ($i = 0; $i < 10; $i++) { $invoice_total = rand(10000, 100000); $payment_total = rand(100, 10000); $rand_time = rand($min_epoch, $max_epoch); $id = $this->build_test_invoice($invoice_total); $this->build_test_payment($id, $payment_total, $rand_time); // tally the invoice balances $invoice_totaled += (double) $invoice_total; $payment_totaled += (double) $payment_total; } // Build some invoices with voided payments foreach ($invoice_totals as $key => $total) { $id = $this->build_test_invoice($total); $rand_time = rand($min_epoch, $max_epoch); $this->build_test_payment($id, $rand_time, false, SI_Payment::STATUS_VOID); // tally the invoice balances $invoice_totaled += (double) $total; } // Build some invoices with current payments foreach ($invoice_totals as $key => $total) { $id = $this->build_test_invoice($total); $this->build_test_payment($id, $payment_totals[$key]); // tally the invoice balances $invoice_totaled += (double) $total; $payment_totaled += (double) $payment_totals[$key]; $context2_totaled += (double) $payment_totals[$key]; } // check payment totals $payment_data = SI_Reporting::total_payment_data('lastyear'); // Totals should equal last months payments $this->assertEquals($payment_data['totals'], $context_totaled); // check payment totals $payment_data = SI_Reporting::total_payment_data('year'); // Total should equal all payments, except those that were created for last month. $this->assertEquals($payment_data['totals'], $context2_totaled); }