Fix export accounting, added Domain List

This commit is contained in:
Deon George 2014-01-07 23:29:18 +11:00
parent 82c51de550
commit 3cbf48721b
7 changed files with 76 additions and 44 deletions

View File

@ -0,0 +1,42 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Admin Domain functions
*
* @package Domain
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Service_Domain extends Controller_Domain {
protected $secure_actions = array(
'list'=>TRUE,
);
public function action_list() {
Block::factory()
->title('Domains By Supplier')
->title_icon('icon-th-list')
->body(Table::factory()
->data(ORM::factory('Service')->where_authorised($this->ao)->list_byplugin('DOMAIN'))
->jssort('domain')
->columns(array(
'id'=>'ID',
'name()'=>'Domain',
'status'=>'Active',
'suspend_billing'=>'Not Bill',
'plugin()->display("domain_expire")'=>'Expire',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Charge',
'account->accnum()'=>'Cust ID',
'account->name()'=>'Customer',
'plugin()->registrar->name'=>'Registrar',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
}
}
?>

View File

@ -0,0 +1,14 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Domain management
*
* @package Domain
* @category Controllers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Domain extends Controller_TemplateDefault {
}
?>

View File

@ -89,10 +89,10 @@ class Export_Plugin_Quicken extends Export_Plugin {
continue;
// Get the mapping item for account purposes
if ($iio->product_id) {
if ($iio->module() instanceof Model_Product) {
$edo = ORM::factory('Export_DataMap')
->where('module_id','=',$iio->product->mid())
->and_where('item_id','=',$iio->product_id)
->where('module_id','=',$iio->module_id)
->and_where('item_id','=',$iio->module_ref)
->find();
if ($edo->loaded()) {
@ -103,7 +103,7 @@ class Export_Plugin_Quicken extends Export_Plugin {
throw HTTP_Exception::factory(501,'Missing product map data for :product (:id)',array(':product'=>$iio->product->title(),':id'=>$iio->product_id));
}
$items[$c]['MEMO'] = sprintf('%s (%s)',$iio->product->title(),$iio->period());
$items[$c]['MEMO'] = sprintf('%s (%s)',$iio->module()->title(),$iio->period());
// Non product item
} else {
@ -133,9 +133,16 @@ class Export_Plugin_Quicken extends Export_Plugin {
$items[$c]['TAXAMOUNT'] = 0;
}
// @todo This rounding should be a system config.
$items[$c]['PRICE'] = sprintf('%3.2f',round($iio->subtotal()-$iio->discount(),2));
$items[$c]['AMOUNT'] = sprintf('%3.2f',round($iio->subtotal()-$iio->discount(),2)*-1);
if ($iio->module() instanceof Model_Charge) {
$items[$c]['QNTY'] *= $iio->module()->quantity;
$items[$c]['PRICE'] = sprintf('%3.2f',round($iio->subtotal()-$iio->discount(),2));
$items[$c]['AMOUNT'] = sprintf('%3.2f',round($iio->module()->amount-$iio->discount(),2)*-1);
} else {
// @todo This rounding should be a system config.
$items[$c]['PRICE'] = sprintf('%3.2f',round($iio->subtotal()-$iio->discount(),2));
$items[$c]['AMOUNT'] = sprintf('%3.2f',round($iio->subtotal()-$iio->discount(),2)*-1);
}
$c++;
}

View File

@ -191,7 +191,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
$processed = array();
foreach ($this->subitems() as $iio) {
if (in_array($iio->id,$processed))
if ($iio->id AND in_array($iio->id,$processed))
continue;
if ($iio->recurring_schedule) {

View File

@ -189,8 +189,8 @@ class Model_Invoice_Item extends ORM_OSB {
$result = array();
foreach ($this->subitems() as $iito) {
if (! isset($result[$iit->tax_id]))
$result[$iit->tax_id] = 0;
if (! isset($result[$iito->tax_id]))
$result[$iito->tax_id] = 0;
$result[$iito->tax_id] += $iito->amount;
}

View File

@ -14,7 +14,6 @@ class Controller_Admin_Service extends Controller_Service {
'add'=>TRUE,
'ajaxaddplugin'=>TRUE,
'edit'=>TRUE,
'listdomainservicesbysupplier'=>TRUE,
'listdomainservicesbydnshost'=>TRUE,
'listhostservicesbysupplier'=>TRUE,
'view'=>TRUE,
@ -161,39 +160,6 @@ $(document).ready(function() {
}
public function action_listdomainservicesbysupplier() {
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->domain_registrar_id,name()');
$list = array();
foreach ($svs as $so)
$list[$so->plugin()->domain_registrar_id][] = $so;
foreach (array_keys($list) as $sid)
Block::add(array(
'title'=>sprintf(_('Domain Names by Supplier %s'),$sid),
'body'=>Table::display(
$list[$sid],
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
}
public function action_listdomainservicesbydnshost() {
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->host,name()');

View File

@ -58,6 +58,9 @@ class Model_Service extends ORM_OSB {
'recur_schedule'=>array(
array('StaticList_RecurSchedule::get',array(':value')),
),
'suspend_billing'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
),
'status'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
),