Jump to content

Recommended Posts

Posted

New lines are added to invoice without tax when using $this->Invoices->edit() in my plugin. It started from version 3.4.4.

 

 public function getEvents() {
        return array(
            array(
                'event' => "Invoices.add",
                'callback' => array("this", "InvoicesAdd")
            )         
        );
    }
 

 

public function InvoicesAdd($event) {

 

            $params = $event->getParams();

 

            $vars['lines'][] = array(
                              'service_id' => 3281,
                              'description' => "Usage",
                               'qty' => '1',
                              'amount' => 2,
                              'tax' => 1
             );
 
            $this->Invoices->edit($params['invoice_id'], $vars);
 
           $test = $this->Invoices->get($params['invoice_id']);
           var_dump($test);
}
 
object(stdClass)#641 (25) {
  ["id"]=>
  string(4) "3281"
  ["id_format"]=>
  string(5) "{num}"
  ["id_value"]=>
  string(4) "3154"
  ["client_id"]=>
  string(2) "56"
  ["date_billed"]=>
  string(19) "2015-07-01 20:03:49"
  ["date_due"]=>
  string(19) "2015-07-01 20:03:49"
  ["date_closed"]=>
  NULL
  ["date_autodebit"]=>
  NULL
  ["status"]=>
  string(6) "active"
  ["subtotal"]=>
  string(7) "31.9500"
  ["total"]=>
  string(7) "35.8400"
  ["paid"]=>
  string(6) "0.0000"
  ["previous_due"]=>
  string(8) "487.7600"
  ["currency"]=>
  string(3) "CAD"
  ["note_public"]=>
  NULL
  ["note_private"]=>
  NULL
  ["id_code"]=>
  string(4) "3154"
  ["delivery_date_sent"]=>
  NULL
  ["due"]=>
  string(7) "35.8400"
  ["line_items"]=>
  array(2) {
    [0]=>
    object(stdClass)#647 (13) {
      ["id"]=>
      string(5) "28039"
      ["invoice_id"]=>
      string(4) "3281"
      ["service_id"]=>
      string(3) "362"
      ["description"]=>
      string(46) "World  (Jul 01, 2015 - Aug 01, 2015)"
      ["qty"]=>
      string(6) "1.0000"
      ["amount"]=>
      string(7) "29.9500"
      ["subtotal"]=>
      string(11) "29.95000000"
      ["taxes"]=>
      array(1) {
        [0]=>
        object(stdClass)#654 (11) {
          ["id"]=>
          string(2) "15"
          ["company_id"]=>
          string(1) "1"
          ["level"]=>
          string(1) "1"
          ["name"]=>
          string(3) "HST"
          ["amount"]=>
          string(7) "13.0000"
          ["type"]=>
          string(9) "exclusive"
          ["country"]=>
          string(2) "CA"
          ["state"]=>
          NULL
          ["status"]=>
          string(6) "active"
          ["cascade"]=>
          string(1) "0"
          ["tax_total"]=>
          float(3.89)
        }
      }
      ["taxes_applied"]=>
      array(1) {
        [0]=>
        array(4) {
          ["id"]=>
          string(2) "15"
          ["name"]=>
          string(3) "HST"
          ["percentage"]=>
          string(7) "13.0000"
          ["amount"]=>
          float(3.89)
        }
      }
      ["tax_subtotal"]=>
      int(0)
      ["tax_total"]=>
      float(3.89)
      ["total"]=>
      float(29.95)
      ["total_w_tax"]=>
      float(33.84)
    }
    [1]=>
    object(stdClass)#275 (13) {
      ["id"]=>
      string(5) "28040"
      ["invoice_id"]=>
      string(4) "3281"
      ["service_id"]=>
      string(3) "362"
      ["description"]=>
      string(46) "Usage"
      ["qty"]=>
      string(6) "1.0000"
      ["amount"]=>
      string(6) "2.0000"
      ["subtotal"]=>
      string(10) "2.00000000"
      ["taxes"]=>
      array(0) {
      }
      ["taxes_applied"]=>
      array(0) {
      }
      ["tax_subtotal"]=>
      int(0)
      ["tax_total"]=>
      int(0)
      ["total"]=>
      float(2)
      ["total_w_tax"]=>
      float(2)
    }
  }
  ["delivery"]=>
  array(1) {
    [0]=>
    object(stdClass)#271 (4) {
      ["id"]=>
      string(4) "5663"
      ["invoice_id"]=>
      string(4) "3281"
      ["method"]=>
      string(5) "email"
      ["date_sent"]=>
      NULL
    }
  }
  ["meta"]=>
  array(0) {
  }
  ["tax_subtotal"]=>
  int(0)
  ["tax_total"]=>
  float(3.89)
  ["taxes"]=>
  array(1) {
    [0]=>
    object(stdClass)#654 (11) {
      ["id"]=>
      string(2) "15"
      ["company_id"]=>
      string(1) "1"
      ["level"]=>
      string(1) "1"
      ["name"]=>
      string(3) "HST"
      ["amount"]=>
      string(7) "13.0000"
      ["type"]=>
      string(9) "exclusive"
      ["country"]=>
      string(2) "CA"
      ["state"]=>
      NULL
      ["status"]=>
      string(6) "active"
      ["cascade"]=>
      string(1) "0"
      ["tax_total"]=>
      float(3.89)
    }
  }
}
 
OS: Centos 6.6
Blesta: 3.5.0
PHP: 5.3.x
MySQL: 5.1.x
 
Posted

Considering this does not occur in the interface, I lean toward this being an issue with your environment or your plugin.

 

Taxes, even when line items are marked taxable, are only set as taxable if tax applies to the client the invoice belongs to and corresponding tax rules are available that apply as well.

Guest
This topic is now closed to further replies.
×
×
  • Create New...