Example #1
0
<?php

include_once '../../lib/phpWeFact/WeFact_Api.php';
include_once '../../lib/phpWeFact/WeFact_Model.php';
include_once '../../lib/phpWeFact/WeFact_Invoice.php';
include_once '../../lib/phpWeFact/WeFact_InvoiceLine.php';
$invoice = new WeFact_Invoice();
$invoiceLine = new WeFact_InvoiceLine();
$invoiceLine2 = new WeFact_InvoiceLine();
$invoiceLine->setNumber('3')->setDescription('An awesome product!')->setProductCode('P0001');
$invoiceLine2->setNumber('5')->setDescription('Another awesome product!')->setPriceExcl(10.95)->setPeriodicType('period')->setPeriods(3)->setPeriodic('d');
$invoice->setDebtorCode('DB0003')->addInvoiceLine($invoiceLine)->addInvoiceLine($invoiceLine2);
$result = $invoice->save();
var_dump($result);
Example #2
0
<?php

include_once '../../lib/phpWeFact/WeFact_Api.php';
include_once '../../lib/phpWeFact/WeFact_Model.php';
include_once '../../lib/phpWeFact/WeFact_Invoice.php';
include_once '../../lib/phpWeFact/WeFact_InvoiceLine.php';
$invoice = WeFact_Invoice::getByCode("F0001");
$invoiceLine = new WeFact_InvoiceLine();
$invoiceLine->setNumber('1')->setDescription('A way more awesome product!')->setPriceExcl('50.13')->setTaxPercentage('21');
$result = $invoice->insertInvoiceLine($invoiceLine);
var_dump($result);
Example #3
0
 /**
  * Deletes an invoice line from an EXISTING invoice
  *
  * @param  WeFact_InvoiceLine $invoiceLine
  * @throws Exception
  * @return array
  */
 public function removeInvoiceLine(WeFact_InvoiceLine $invoiceLine)
 {
     if ($this->getInvoiceCode() == '') {
         throw new \InvalidArgumentException(sprintf('InvoiceCode must be defined!'));
     }
     if ($invoiceLine->getIdentifier() == '') {
         throw new \InvalidArgumentException(sprintf('InvoiceLine Identifier must be defined!'));
     }
     $parameters = array('InvoiceCode' => $this->getInvoiceCode(), 'InvoiceLines' => array('Identifier' => $invoiceLine->getIdentifier()));
     $response = $this->sendRequest('invoiceline', 'delete', $parameters);
     if (!isset($response['status']) || $response['status'] == 'error') {
         throw new Exception('Unable to add InvoiceLine: ' . print_r($response['errors'], true));
     }
     $this->deleteInvoiceLine($invoiceLine);
     return $response;
 }