Fixes to OSB to work with KH 3.3
This commit is contained in:
70
modules/export/classes/Quicken.php
Normal file
70
modules/export/classes/Quicken.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Quicken exporting capabilities.
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Export
|
||||
* @category Classes/Quicken
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Quicken extends OSBExport {
|
||||
protected $defaults = array();
|
||||
|
||||
protected function keys() {
|
||||
return array_merge(array_keys($this->defaults),parent::keys());
|
||||
}
|
||||
|
||||
protected function vals() {
|
||||
return array_merge(array_values($this->defaults),parent::vals());
|
||||
}
|
||||
|
||||
public function addInvoice(Quicken_Invoice $item) {
|
||||
array_push($this->_items,$item);
|
||||
}
|
||||
|
||||
public function export() {
|
||||
$export = '';
|
||||
|
||||
foreach ($this->_items as $inv) {
|
||||
# Invoices
|
||||
$export .= "!TRNS\t";
|
||||
$export .= implode("\t",$inv->keys())."\n";
|
||||
$export .= "TRNS\t";
|
||||
$export .= implode("\t",$inv->vals())."\n";
|
||||
|
||||
# Invoice Items
|
||||
$spl = 0;
|
||||
foreach ($inv->_items as $invitem) {
|
||||
if (! $spl) {
|
||||
$export .= "!SPL\tSPLID\t";
|
||||
$export .= implode("\t",$invitem->keys())."\n";
|
||||
}
|
||||
|
||||
$export .= sprintf("SPL\t%s\t%s",$spl++,implode("\t",$invitem->vals()))."\n";
|
||||
}
|
||||
|
||||
$export .= "ENDTRNS\n";
|
||||
|
||||
# Payments
|
||||
foreach ($inv->_payments as $payitem) {
|
||||
if (! $payitem->AMOUNT)
|
||||
continue;
|
||||
|
||||
$export .= "!TRNS\t";
|
||||
$export .= implode("\t",$payitem->keys())."\n";
|
||||
$export .= "TRNS\t";
|
||||
$export .= implode("\t",$payitem->vals())."\n";
|
||||
|
||||
$export .= sprintf("!SPL\t%s\t%s\t%s\t%s\t%s\t",'SPLID','TRANSTYPE','CLEAR','ACCNT','AMOUNT')."\n";
|
||||
$export .= sprintf("SPL\t%s\t%s\t%s\t%s\t%s\t",0,'PAYMENT','N','Accounts Receivable',$payitem->AMOUNT)."\n";
|
||||
$export .= "ENDTRNS\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $export;
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user