Minor updatess

This commit is contained in:
Deon George 2013-02-26 14:19:32 +11:00
parent 288d974cfa
commit 2cdd130d1a
16 changed files with 117 additions and 50 deletions

View File

@ -31,15 +31,6 @@ class Config extends Kohana_Config {
public function __construct() { public function __construct() {
if (defined('PHPUNITTEST')) if (defined('PHPUNITTEST'))
$_SERVER['SERVER_NAME'] = PHPUNITTEST; $_SERVER['SERVER_NAME'] = PHPUNITTEST;
// We need to know our site here, so that we can subsequently load our enabled modules.
if (Kohana::$is_cli) {
if (! $site = Minion_CLI::options('site'))
// @todo Need to figure out how to make this CLI error nicer.
throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI'));
else
$_SERVER['SERVER_NAME'] = $site;
}
} }
/** /**
@ -116,9 +107,19 @@ class Config extends Kohana_Config {
public static function modules() { public static function modules() {
static $return = array(); static $return = array();
if (! count($return)) if (! count($return)) {
// We need to know our site here, so that we can subsequently load our enabled modules.
if (PHP_SAPI === 'cli') {
if (! $site = Minion_CLI::options('site'))
// @todo Need to figure out how to make this CLI error nicer.
throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI'));
else
$_SERVER['SERVER_NAME'] = $site;
}
foreach (ORM::factory('Module')->list_external() as $mo) foreach (ORM::factory('Module')->list_external() as $mo)
$return[$mo->name] = MODPATH.$mo->name; $return[$mo->name] = MODPATH.$mo->name;
}
return $return; return $return;
} }

View File

@ -16,6 +16,7 @@ class URL extends Kohana_URL {
'admin'=>'a', 'admin'=>'a',
'affiliate'=>'affiliate', // @todo To retire 'affiliate'=>'affiliate', // @todo To retire
'reseller'=>'r', 'reseller'=>'r',
'task'=>'task',
'user'=>'u', 'user'=>'u',
); );

View File

@ -12,7 +12,7 @@
*/ */
return array( return array(
'appname' => 'OS Billing', 'appname' => 'OS Billing', // Our application name, as shown in the title bar of pages
'cache_type' => 'file', 'cache_type' => 'file',
'email_from' => array('noreply@graytech.net.au'=>'Graytech Hosting'), 'email_from' => array('noreply@graytech.net.au'=>'Graytech Hosting'),
'email_admin_only'=> array( 'email_admin_only'=> array(

View File

@ -0,0 +1,46 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
return array
(
// Enable the API browser. TRUE or FALSE
'api_browser' => TRUE,
// Enable these packages in the API browser. TRUE for all packages, or a string of comma seperated packages, using 'None' for a class with no @package
// Example: 'api_packages' => 'Kohana,Kohana/Database,Kohana/ORM,None',
'api_packages' => TRUE,
// Enables Disqus comments on the API and User Guide pages
'show_comments' => Kohana::$environment === Kohana::PRODUCTION,
// Leave this alone
'modules' => array(
'kohana' => array('enabled'=>FALSE),
'auth' => array('enabled'=>FALSE),
'cache' => array('enabled'=>FALSE),
'database' => array('enabled'=>FALSE),
'minion' => array('enabled'=>FALSE),
'orm' => array('enabled'=>FALSE),
'pagination' => array('enabled'=>FALSE),
// This should be the path to this modules userguide pages, without the 'guide/'. Ex: '/guide/modulename/' would be 'modulename'
'userguide' => array(
// Whether this modules userguide pages should be shown
'enabled' => TRUE,
// The name that should show up on the userguide index page
'name' => 'Userguide',
// A short description of this module, shown on the index page
'description' => 'Documentation viewer and api generation.',
// Copyright message, shown in the footer for this module
'copyright' => '&copy; 20082012 Kohana Team',
)
),
// Set transparent class name segments
'transparent_prefixes' => array(
'Kohana' => TRUE,
)
);

View File

@ -11,7 +11,7 @@
* @license http://dev.leenooks.net/license.html * @license http://dev.leenooks.net/license.html
*/ */
class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal { class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal {
private $test_mode = TRUE; private $test_mode = FALSE;
/** /**
* Set payment via Paypal * Set payment via Paypal

View File

@ -147,14 +147,14 @@ class Export_Quicken extends Export {
# @todo, get this from OSB # @todo, get this from OSB
$qto->TAXCODE = 'GST'; $qto->TAXCODE = 'GST';
$qto->TAXRATE = sprintf('%3.2f%%','0.10'); $qto->TAXRATE = sprintf('%3.2f%%','0.10');
$tax = round($pio->invoice->credit_amt/11,2); $tax = round($pio->invoice->total_credits()/11,2);
$qto->TAXAMOUNT = sprintf('%3.2f',$tax); $qto->TAXAMOUNT = sprintf('%3.2f',$tax);
} else { } else {
$qto->TAXAMOUNT = 0; $qto->TAXAMOUNT = 0;
} }
$qto->PRICE = sprintf('%3.2f',round(($pio->invoice->credit_amt-$tax)*-1,2)); $qto->PRICE = sprintf('%3.2f',round(($pio->invoice->total_credits()-$tax)*-1,2));
$qto->AMOUNT = sprintf('%3.2f',round(($pio->invoice->credit_amt-$tax),2)); $qto->AMOUNT = sprintf('%3.2f',round(($pio->invoice->total_credits()-$tax),2));
$qio->addInvoiceItem($qto); $qio->addInvoiceItem($qto);
$qo->addInvoice($qio); $qo->addInvoice($qio);

View File

@ -40,16 +40,23 @@ class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
* Show a list of invoices * Show a list of invoices
*/ */
public function action_list() { public function action_list() {
$id = $this->request->param('id');
$invs = ORM::factory('Invoice');
if ($id)
$invs->where('account_id','=',$id);
Block::add(array( Block::add(array(
'title'=>_('System Customer Invoices'), 'title'=>_('System Customer Invoices'),
'body'=>Table::display( 'body'=>Table::display(
ORM::factory('Invoice')->find_all(), $invs->find_all(),
25, 25,
array( array(
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')), 'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
'date_orig'=>array('label'=>'Date'), 'date_orig'=>array('label'=>'Date'),
'total(TRUE)'=>array('label'=>'Total','class'=>'right'), 'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
'credit_amt'=>array('label'=>'Credits','class'=>'right'), 'total_credits(TRUE)'=>array('label'=>'Credits','class'=>'right'),
'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'), 'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'),
'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'), 'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'), 'account->accnum()'=>array('label'=>'Cust ID'),

View File

@ -128,7 +128,7 @@ class Controller_Task_Invoice extends Controller_Task {
$et->variables = array( $et->variables = array(
'DUE'=>$io->due(TRUE), 'DUE'=>$io->due(TRUE),
'DUE_DATE'=>$io->display('due_date'), 'DUE_DATE'=>$io->display('due_date'),
'EMAIL'=>Company::email(), 'EMAIL'=>Company::instance()->email(),
'FIRST_NAME'=>$io->account->first_name, 'FIRST_NAME'=>$io->account->first_name,
'INV_NUM'=>$io->refnum(), 'INV_NUM'=>$io->refnum(),
'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'), 'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'),
@ -299,7 +299,7 @@ class Controller_Task_Invoice extends Controller_Task {
$et->variables = array( $et->variables = array(
'DUE'=>$io->due(TRUE), 'DUE'=>$io->due(TRUE),
'DUE_DATE'=>$io->display('due_date'), 'DUE_DATE'=>$io->display('due_date'),
'EMAIL'=>Company::email(), 'EMAIL'=>Company::instance()->email(),
'FIRST_NAME'=>$io->account->first_name, 'FIRST_NAME'=>$io->account->first_name,
'HTML_INVOICE'=>$io->html(), 'HTML_INVOICE'=>$io->html(),
'INV_NUM'=>$io->refnum(), 'INV_NUM'=>$io->refnum(),

View File

@ -31,7 +31,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
'date_orig'=>array('label'=>'Date Issued'), 'date_orig'=>array('label'=>'Date Issued'),
'due_date'=>array('label'=>'Date Due'), 'due_date'=>array('label'=>'Date Due'),
'total(TRUE)'=>array('label'=>'Total','class'=>'right'), 'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
'credit_amt'=>array('label'=>'Credits','class'=>'right'), 'total_credits(TRUE)'=>array('label'=>'Credits','class'=>'right'),
'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'), 'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'),
'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'), 'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'),
), ),

View File

@ -135,7 +135,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
// Draw a box. // Draw a box.
$this->SetFillColor(245); $this->SetFillColor(245);
$this->SetXY($x-1,$y-1); $this->Cell(0,35+5+($this->io->credit_amt ? 5 : 0),'',1,0,'',1); $this->SetXY($x-1,$y-1); $this->Cell(0,35+5+($this->io->total_credits() ? 5 : 0),'',1,0,'',1);
// Draw a box around the invoice due date and amount due. // Draw a box around the invoice due date and amount due.
$this->SetFont('helvetica','B',11); $this->SetFont('helvetica','B',11);
@ -172,12 +172,12 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetFont('helvetica','B',11); $this->SetFont('helvetica','B',11);
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->io->payments_total('TRUE'),0,0,'R'); $this->SetXY($x+55,$y); $this->Cell(0,0,$this->io->payments_total('TRUE'),0,0,'R');
if ($this->io->credit_amt) { if ($this->io->total_credits()) {
$y += 5; $y += 5;
$this->SetFont('helvetica','',10); $this->SetFont('helvetica','',10);
$this->SetXY($x,$y); $this->Cell(0,0,'Credits Received'); $this->SetXY($x,$y); $this->Cell(0,0,'Credits Received');
$this->SetFont('helvetica','B',11); $this->SetFont('helvetica','B',11);
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->io->display('credit_amt'),0,0,'R'); $this->SetXY($x+55,$y); $this->Cell(0,0,$this->io->total_credits(TRUE),0,0,'R');
} }
$y += 5; $y += 5;
@ -319,7 +319,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetFillColor(245); $this->SetFillColor(245);
$this->SetXY($x-1,$y-1); $this->SetXY($x-1,$y-1);
$this->Cell(0,5*( $this->Cell(0,5*(
1+1+1+3+($this->io->discount_amt ? 1 : 0)+1+($this->io->credit_amt ? 1 : 0)+$box 1+1+1+3+($this->io->total_discounts() ? 1 : 0)+1+($this->io->total_credits() ? 1 : 0)+$box
)+1+4,'',1,0,'',1); )+1+4,'',1,0,'',1);
$this->SetFont('helvetica','B',11); $this->SetFont('helvetica','B',11);
@ -355,7 +355,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
// Calculate our rounding error // Calculate our rounding error
// @todo This shouldnt be required. // @todo This shouldnt be required.
$subtotal = Currency::round($subtotal-$this->io->discount_amt); #$subtotal = Currency::round($subtotal-$this->io->total_discounts());
if (Currency::round($this->io->subtotal()) != $subtotal) { if (Currency::round($this->io->subtotal()) != $subtotal) {
$this->SetFont('helvetica','',9); $this->SetFont('helvetica','',9);
@ -369,7 +369,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
} }
// Draw Discounts. // Draw Discounts.
if ($this->io->discount_amt) { if ($this->io->total_discounts()) {
$y += 5; $y += 5;
$this->SetY($y); $this->SetY($y);
@ -377,7 +377,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetX($x+8); $this->SetX($x+8);
$this->Cell(0,0,_('Discount')); $this->Cell(0,0,_('Discount'));
$this->SetX($x+135); $this->SetX($x+135);
$this->Cell(0,0,Currency::display(-$this->io->discount_amt),0,0,'R'); $this->Cell(0,0,Currency::display(-$this->io->total_discounts()),0,0,'R');
} }
// Subtotal and tax. // Subtotal and tax.
@ -415,7 +415,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetX($x+135); $this->SetX($x+135);
$this->Cell(0,0,$this->io->payments_total(TRUE),0,0,'R'); $this->Cell(0,0,$this->io->payments_total(TRUE),0,0,'R');
if ($this->io->credit_amt) { if ($this->io->total_credits()) {
$y += 5; $y += 5;
$this->SetY($y); $this->SetY($y);
@ -423,7 +423,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetX($x+8); $this->SetX($x+8);
$this->Cell(0,0,_('Less Credits')); $this->Cell(0,0,_('Less Credits'));
$this->SetX($x+135); $this->SetX($x+135);
$this->Cell(0,0,Currency::display(-$this->io->credit_amt),0,0,'R'); $this->Cell(0,0,Currency::display(-$this->io->total_credits()),0,0,'R');
} }
$y += 5; $y += 5;
@ -479,7 +479,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
$this->SetFont('helvetica','',8); $this->SetFont('helvetica','',8);
$this->SetX($x); $this->SetX($x);
$this->Cell(0,0,$ito->service->service_name()); $this->Cell(0,0,sprintf('%s - %s',$ito->product->name(),$ito->service->name()));
if ($ito->price_base) { if ($ito->price_base) {
$this->SetX($x+160); $this->SetX($x+160);

View File

@ -503,12 +503,10 @@ class Model_Invoice extends ORM_OSB implements Cartable {
if ($this->loaded() AND ! count($this->items())) if ($this->loaded() AND ! count($this->items()))
$this->_load_sub_items(); $this->_load_sub_items();
// This will include charges and credits
foreach ($this->items() as $ito) foreach ($this->items() as $ito)
$result += $ito->total(); $result += $ito->total();
// Reduce by any credits
$result -= $this->credit_amt;
return $format ? Currency::display($result) : Currency::round($result); return $format ? Currency::display($result) : Currency::round($result);
} }
@ -524,17 +522,13 @@ class Model_Invoice extends ORM_OSB implements Cartable {
public function total_credits($format=FALSE) { public function total_credits($format=FALSE) {
$result = 0; $result = 0;
// @todo Remove when credit_amt is dropped.
if ($this->credit_amt)
$result = $this->credit_amt;
foreach ($this->items('CREDIT') as $ito) foreach ($this->items('CREDIT') as $ito)
$result += ($ito->subtotal()+$ito->tax())*-1; $result += ($ito->subtotal()+$ito->tax())*-1;
return $format ? Currency::display($result) : Currency::round($result); return $format ? Currency::display($result) : Currency::round($result);
} }
public function total_discount($format=FALSE) { public function total_discounts($format=FALSE) {
$result = 0; $result = 0;
foreach ($this->items() as $ito) foreach ($this->items() as $ito)

View File

@ -111,10 +111,10 @@
<td class="head" colspan="3">Sub Total of Items:</td> <td class="head" colspan="3">Sub Total of Items:</td>
<td class="bold-right"><?php echo $io->subtotal(TRUE); ?>&nbsp;</td> <td class="bold-right"><?php echo $io->subtotal(TRUE); ?>&nbsp;</td>
</tr> </tr>
<?php if ($io->discount()) { ?> <?php if ($io->total_discounts()) { ?>
<tr> <tr>
<td class="head" colspan="3">Discounts:</td> <td class="head" colspan="3">Discounts:</td>
<td class="bold-right">(<?php echo $io->discount(TRUE); ?>)</td> <td class="bold-right">(<?php echo $io->total_discounts(TRUE); ?>)</td>
</tr> </tr>
<?php } ?> <?php } ?>
<tr> <tr>

View File

@ -168,19 +168,19 @@
<td class="bold-right" colspan="2"><?php echo $io->subtotal(TRUE); ?></td> <td class="bold-right" colspan="2"><?php echo $io->subtotal(TRUE); ?></td>
</tr> </tr>
<!-- END Invoice Sub Total --> <!-- END Invoice Sub Total -->
<?php if ($io->credit_amt) { ?> <?php if ($io->total_credits()) { ?>
<!-- Invoice Credits --> <!-- Invoice Credits -->
<tr> <tr>
<td class="head" colspan="2">Credits Received:</td> <td class="head" colspan="2">Credits Received:</td>
<td class="bold-right" colspan="2"><?php echo $io->display('credit_amt'); ?></td> <td class="bold-right" colspan="2"><?php echo $io->total_credits(TRUE); ?></td>
</tr> </tr>
<!-- END Invoice Credits --> <!-- END Invoice Credits -->
<?php } ?> <?php } ?>
<?php if ($io->total_discount()) { ?> <?php if ($io->total_discounts()) { ?>
<!-- Invoice Discounts Total --> <!-- Invoice Discounts Total -->
<tr> <tr>
<td class="head" colspan="2">Discounts:</td> <td class="head" colspan="2">Discounts:</td>
<td class="bold-right" colspan="2">(<?php echo $io->total_discount(TRUE); ?>)</td> <td class="bold-right" colspan="2">(<?php echo $io->total_discounts(TRUE); ?>)</td>
</tr> </tr>
<!-- END Invoice Discounts Total --> <!-- END Invoice Discounts Total -->
<?php } ?> <?php } ?>

View File

@ -42,7 +42,7 @@ class Payment_Bulk_Ezypay {
// Field 4 has our account reference // Field 4 has our account reference
if (preg_match('/^'.Company::instance()->site(TRUE).'-/',$array[4]) AND $array[10] == 'Cleared') { if (preg_match('/^'.Company::instance()->site(TRUE).'-/',$array[4]) AND $array[10] == 'Cleared') {
$aid = preg_replace('/^'.Compan::instance()->site(TRUE).'-/','',$array[4]); $aid = preg_replace('/^'.Company::instance()->site(TRUE).'-/','',$array[4]);
$po = ORM::factory('Payment'); $po = ORM::factory('Payment');
$po->account_id = $aid; $po->account_id = $aid;
@ -85,7 +85,7 @@ class Payment_Bulk_Ezypay {
} }
$return = ''; $return = '';
$return .= View::Factory('Payment/Admin/Addbulk/Ezypay/head'); $return .= View::Factory('payment/admin/addbulk/ezypay/head');
$total = $fees = 0; $total = $fees = 0;
foreach ($payments as $po) { foreach ($payments as $po) {
@ -94,11 +94,11 @@ class Payment_Bulk_Ezypay {
$total += $po->total_amt; $total += $po->total_amt;
$fees += $po->fees_amt; $fees += $po->fees_amt;
$return .= View::Factory('Payment/Admin/Addbulk/Ezypay/body') $return .= View::Factory('payment/admin/addbulk/ezypay/body')
->set('o',$po); ->set('o',$po);
} }
$return .= View::Factory('Payment/Admin/Addbulk/Ezypay/foot') $return .= View::Factory('payment/admin/addbulk/ezypay/foot')
->set('total',$total) ->set('total',$total)
->set('fees',$fees);; ->set('fees',$fees);;

View File

@ -68,10 +68,17 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
* Show a list of services * Show a list of services
*/ */
public function action_list() { public function action_list() {
$id = $this->request->param('id');
$svs = ORM::factory('Service');
if ($id)
$svs->where_active()->and_where('account_id','=',$id);
Block::add(array( Block::add(array(
'title'=>_('Customer Services'), 'title'=>_('Customer Services'),
'body'=>Table::display( 'body'=>Table::display(
ORM::factory('Service')->find_all(), $svs->find_all(),
25, 25,
array( array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
@ -195,7 +202,16 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
} }
public function action_listadslservices() { public function action_listadslservices() {
$svs = ORM::factory('Service')->list_bylistgroup('ADSL'); $id = $this->request->param('id');
$svs = $list = ORM::factory('Service')->list_bylistgroup('ADSL');
if ($id) {
$svs = array();
foreach ($list as $so)
if ($so->account_id == $id)
array_push($svs,$so);
}
$google = GoogleChart::factory('ComboChart') $google = GoogleChart::factory('ComboChart')
->dataurl(URL::link('admin','service/ajaxjson_traffic',TRUE)) ->dataurl(URL::link('admin','service/ajaxjson_traffic',TRUE))
@ -732,6 +748,8 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
$save = (isset($_REQUEST['go']) && $_REQUEST['go']=1) ? 1 : 0; $save = (isset($_REQUEST['go']) && $_REQUEST['go']=1) ? 1 : 0;
$xsid=197; $xsid=197;
foreach ($so->transactions()->where('item_type','=',0)->find_all() as $iio) { foreach ($so->transactions()->where('item_type','=',0)->find_all() as $iio) {
if (! $iio->invoice->status) continue;
// @todo This hard coding of 3070 should be removed.
if ($iio->service_id == $xsid AND $iio->invoice_id < 3070) continue; if ($iio->service_id == $xsid AND $iio->invoice_id < 3070) continue;
if ($iio->quantity < 0 OR $iio->price_base < 0) if ($iio->quantity < 0 OR $iio->price_base < 0)
continue; continue;