Improvements to taxing
This commit is contained in:
@@ -104,20 +104,22 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin {
|
||||
// We assume fees are added to $po->items() which are invoices.
|
||||
if (preg_match('/^0:/',$cno->data['item_number'.$c])) {
|
||||
$i = $j = 0;
|
||||
foreach ($po->items() as $pio) {
|
||||
foreach ($po->subitems() as $pio) {
|
||||
$io = ORM::factory('Invoice',$pio->invoice_id);
|
||||
// @todo Need to do tax.
|
||||
$iio = $io->add_item();
|
||||
|
||||
$iio = ORM::factory('Invoice_Item');
|
||||
$iio->quantity = 1;
|
||||
$iio->module_id = $cno->mid()->id;
|
||||
$iio->item_type = 125; // Payment Fee
|
||||
$iio->price_base = (++$j==count($amts)) ? $cno->data['mc_gross_'.$c]-$i : Currency::round($pio->alloc_amt/array_sum($amts)*$cno->data['mc_gross_'.$c]);
|
||||
$iio->date_start = $iio->date_stop = time();
|
||||
|
||||
$io->subitem_add($iio,$io->account->country,TRUE);
|
||||
|
||||
// @todo Validate Save
|
||||
$io->save();
|
||||
|
||||
$pio->alloc_amt = ($pio->alloc_amt+$iio->price_base > $pio->invoice->total()) ? $pio->alloc_amt : $pio->alloc_amt+$iio->price_base;
|
||||
$pio->alloc_amt = ($pio->alloc_amt+$iio->total() > $pio->invoice->total()) ? $pio->alloc_amt : $pio->alloc_amt+$iio->total();
|
||||
$i += $iio->price_base;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user