Fixes for export
This commit is contained in:
parent
f1f28cd746
commit
5697e7985b
@ -93,9 +93,8 @@ class Export_Quicken extends Export {
|
||||
->find();
|
||||
|
||||
if ($eo->loaded()) {
|
||||
$map_data = unserialize($eo->map_data);
|
||||
$qto->ACCNT = $map_data['account'];
|
||||
$qto->INVITEM = $map_data['item'];
|
||||
$qto->ACCNT = $eo->map_data['account'];
|
||||
$qto->INVITEM = $eo->map_data['item'];
|
||||
|
||||
} else {
|
||||
throw new Kohana_Exception('Missing product map data for :product (:id)',
|
||||
@ -135,6 +134,29 @@ class Export_Quicken extends Export {
|
||||
$qio->addInvoiceItem($qto);
|
||||
}
|
||||
|
||||
// Add credits as a other item
|
||||
$qto = new Quicken_InvoiceItem;
|
||||
$qto->ACCNT = 'Other Income';
|
||||
$qto->INVITEM = 'Product:Unknown';
|
||||
$qto->CLEAR = 'N';
|
||||
$qto->QNTY = 1;
|
||||
$qto->MEMO = 'Credit Item';
|
||||
|
||||
if ($pio->invoice->tax()) {
|
||||
$qto->TAXABLE = 'Y';
|
||||
# @todo, get this from OSB
|
||||
$qto->TAXCODE = 'GST';
|
||||
$qto->TAXRATE = sprintf('%3.2f%%','0.10');
|
||||
$tax = round($pio->invoice->credit_amt/11,2);
|
||||
$qto->TAXAMOUNT = sprintf('%3.2f',$tax);
|
||||
} else {
|
||||
$qto->TAXAMOUNT = 0;
|
||||
}
|
||||
|
||||
$qto->PRICE = sprintf('%3.2f',round(($pio->invoice->credit_amt-$tax)*-1,2));
|
||||
$qto->AMOUNT = sprintf('%3.2f',round(($pio->invoice->credit_amt-$tax),2));
|
||||
$qio->addInvoiceItem($qto);
|
||||
|
||||
$qo->addInvoice($qio);
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,19 @@ class Model_Invoice extends ORMOSB {
|
||||
return $format ? Currency::display($result) : Currency::round($result);
|
||||
}
|
||||
|
||||
public function credits() {
|
||||
return array($this);
|
||||
}
|
||||
|
||||
public function credits_total($format=FALSE) {
|
||||
$result = 0;
|
||||
|
||||
foreach ($this->credits() as $po)
|
||||
$result += $po->credit_amt;
|
||||
|
||||
return $format ? Currency::display($result) : Currency::round($result);
|
||||
}
|
||||
|
||||
public function discount($format=FALSE) {
|
||||
$result = 0;
|
||||
|
||||
|
@ -39,6 +39,10 @@
|
||||
<td>Payments Received to Date</td>
|
||||
<td class="bold-right"><?php echo $io->payments_total(TRUE); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Credits Applied to Date</td>
|
||||
<td class="bold-right"><?php echo $io->credits_total(TRUE); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Total Charges Due This Invoice</td>
|
||||
<td class="bold-right"><?php echo $io->due(TRUE); ?></td>
|
||||
|
Reference in New Issue
Block a user