Esempio n. 1
0
 public function getHandle($no)
 {
     if (is_object($no) and isset($no->Id)) {
         return $no;
     }
     return $this->client->Unit_FindByNumber(array('number' => $no))->Unit_FindByNumberResult;
 }
Esempio n. 2
0
 /**
  * Get all Products of a
  * specific Product Group
  * @param  integer $no
  * @return array
  */
 public function products($no)
 {
     $handle = $this->getHandle($no);
     $productHandles = $this->client->ProductGroup_GetProducts(array('productGroupHandle' => $handle))->ProductGroup_GetProductsResult->ProductHandle;
     $product = new Product($this->client_raw);
     return $product->getArrayFromHandles($productHandles);
 }
 /**
  * Set Quotation Line product
  * by product number
  * @param  mixed $QuotationLineHandle
  * @param  integer $product
  * @return boolean
  */
 public function product($QuotationLineHandle, $product)
 {
     $products = new Product($this->client_raw);
     $productHandle = $products->getHandle($product);
     $this->client->QuotationLine_SetProduct(array('quotationLineHandle' => $QuotationLineHandle, 'valueHandle' => $productHandle));
     return true;
 }
Esempio n. 4
0
 /**
  * Set Quotation Line unit
  * by unit number
  * @param  mixed $QuotationLineHandle [description]
  * @param  integer $unit
  * @return boolean
  */
 public function unit($invoiceLineHandle, $unit)
 {
     $units = new Unit($this->client_raw);
     $unitHandle = $units->getHandle($unit);
     $this->client->CurrentInvoiceLine_SetUnit(array('currentInvoiceLineHandle' => $invoiceLineHandle, 'valueHandle' => $unitHandle));
     return true;
 }
Esempio n. 5
0
 /**
  * Set Quotation Line unit
  * by unit number
  * @param  mixed $orderLineHandle [description]
  * @param  integer $unit
  * @return boolean
  */
 public function unit($orderLineHandle, $unit)
 {
     $units = new Unit($this->client_raw);
     $unitHandle = $units->getHandle($unit);
     $this->client->OrderLine_SetUnit(array('orderLineHandle' => $orderLineHandle, 'valueHandle' => $unitHandle));
     return true;
 }
Esempio n. 6
0
 /**
  * Update debtor
  * @param  array  $data
  * @return boolean
  */
 public function update($data)
 {
     $debitorHandle = ['Number' => $data['number']];
     $groupHandle = ['Number' => $data['group_number']];
     $currencyHandle = ['Code' => $data['currency_code']];
     $termHandle = ['Name' => $data['payment_term_name']];
     $templateHandle = ['Name' => $data['template_name']];
     $contactHandle = ['externalId' => $data['externalId']];
     $data = ['data' => (object) ['Handle' => $debitorHandle, 'Number' => $data['number'], 'VatZone' => $vat_zone, 'IsAccessible' => true, 'Name' => $params['company'], 'Email' => $params['email'], 'Address' => $params['address'], 'PostalCode' => $params['postalcode'], 'City' => $params['city'], 'VatNumber' => $params['vat'], 'Country' => $params['country'], 'DebtorGroupHandle' => $groupHandle, 'CurrencyHandle' => $currencyHandle, 'TermOfPaymentHandle' => $termHandle, 'LayoutHandle' => $templatecollectionHandle, 'AttentionHandle' => $contact_handle]];
     try {
         $updatedDebitorHandle = $this->client->Debtor_UpdateFromData($data)->Debtor_UpdateFromDataResult;
     } catch (\Exception $e) {
         throw new Exception('Could not update Debitor');
     }
     if (isset($contact_handle->Id)) {
         $contactData = ['data' => ['Handle' => $contact_handle, 'Id' => $contact_handle->Id, 'ExternalId' => $params['external'], 'DebtorHandle' => $updatedDebitorHandle, 'Name' => $params['name'], 'Number' => $params['external'], 'Email' => $params['email'], 'IsToReceiveEmailCopyOfOrder' => false, 'IsToReceiveEmailCopyOfInvoice' => false]];
         try {
             $contact = $this->client->DebtorContact_UpdateFromData($contactData)->DebtorContact_UpdateFromDataResult;
         } catch (\Exception $e) {
             throw new Exception('Could not update Debitor Contact information');
         }
     }
     if (!empty($params['debitor_ean'])) {
         $debtorEan = ['debtorHandle' => $debitor, 'valueHandle' => $params['debitor_ean']];
         $this->client->Debtor_SetEan($debtorEan);
     }
     return true;
 }
Esempio n. 7
0
 /**
  * Create a new Debtor Group
  * @param  string  $name
  * @param  integer $account
  * @return object
  */
 public function create($name, $account)
 {
     $all = $this->all();
     $number = end($all)->Number + 1;
     $accounts = new Account($this->client_raw);
     $accountHandle = $accounts->getHandle($account);
     $groupHandle = $this->client->DebtorGroup_Create(array("number" => $number, "name" => $name, "accountHandle" => $accountHandle))->DebtorGroup_CreateResult;
     return $this->get($number);
 }
Esempio n. 8
0
 /**
  * Delete order
  * @param  mixed $no
  * @return boolean
  */
 public function delete($no)
 {
     $handle = $this->getHandle($no);
     try {
         $this->client->Order_Delete(array('OrderHandle' => $handle));
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Esempio n. 9
0
 /**
  * Delete a Contact by ID
  * @param  integer $id
  * @return boolean
  */
 public function delete($id)
 {
     $data = $this->findById($id);
     $this->client->DebtorContact_Delete(array("debtorContactHandle" => $data->Handle));
     return true;
 }
Esempio n. 10
0
 /**
  * Get the price of a product by currency code
  * @param  string $number
  * @param  string $code
  * @return string
  */
 public function getPriceByCurrency($number, $code)
 {
     return $this->client->ProductPrice_GetPrice(array('productPriceHandle' => array('Id1' => $number, 'Id2' => $code)))->ProductPrice_GetPriceResult;
 }
Esempio n. 11
0
 /**
  * Returns the price for the product in the PriceGroup
  * If no special price is found then the sales price is returned instead
  * @param  integer $groupNo
  * @param  string   $productNo
  * @return float
  */
 public function getPrice($groupNo, $productNo)
 {
     return $this->client->PriceGroup_GetPrice(array('priceGroupHandle' => array('Number' => $groupNo), 'productHandle' => array('Number' => $productNo)))->PriceGroup_GetPriceResult;
 }
Esempio n. 12
0
 /**
  * Get Debtor Groups from handles
  * @param  object $handels
  * @return object
  */
 public function getArrayFromHandles($handles)
 {
     return $this->client->Account_GetDataArray(array('entityHandles' => $handles))->Account_GetDataArrayResult->AccountData;
 }
Esempio n. 13
0
 /**
  * Book a current Invoice
  * @param  mixed $invoiceNumber
  * @return object
  */
 public function book($invoiceNumber)
 {
     $handle = $this->getHandle($invoiceNumber);
     $number = $this->client->CurrentInvoice_Book(array('currentInvoiceHandle' => $handle))->CurrentInvoice_BookResult;
     return $number;
 }