Refactored invoice draft handling to improve error checks, added support for optional fetch skipping, and enhanced currency management. Expanded filtering capabilities with date range and attribute-based filters. Adjusted Nginx config to increase FastCGI read timeout for long-running processes.
113 lines
3.8 KiB
PHP
113 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace classes;
|
|
require_once WD . '/modules/economic/economic_c.php';
|
|
require_once WD . '/modules/economic/endpoints/economic_orders_endpoint.php';
|
|
require_once WD . '/modules/economic/endpoints/economic_invoices_endpoint.php';
|
|
require_once WD . '/modules/economic/endpoints/economic_departments_endpoint.php';
|
|
require_once WD . '/modules/economic/endpoints/economic_layouts_endpoint.php';
|
|
require_once WD . '/modules/economic/endpoints/economic_customers_endpoint.php';
|
|
require_once WD . '/modules/economic/endpoints/economic_products_endpoint.php';
|
|
require_once WD . '/modules/economic/economic_helpers.php';
|
|
|
|
|
|
use economic_c;
|
|
use economic_helpers;
|
|
use endpoints\economic_customers_endpoint;
|
|
use endpoints\economic_departments_endpoint;
|
|
use endpoints\economic_invoices_endpoint;
|
|
use endpoints\economic_layouts_endpoint;
|
|
use endpoints\economic_orders_endpoint;
|
|
use endpoints\economic_products_endpoint;
|
|
use helpers\economic_customer;
|
|
use helpers\economic_invoice_draft;
|
|
use helpers\economic_tasks;
|
|
use interfaces\economic_i;
|
|
|
|
class economic implements economic_i
|
|
{
|
|
/**
|
|
* Configuration of the economic module
|
|
* @var economic_c
|
|
*/
|
|
public economic_c $config;
|
|
/**
|
|
* Any endpoints reached by the /orders endpoint
|
|
* @var economic_orders_endpoint
|
|
*/
|
|
public economic_orders_endpoint $orders;
|
|
/**
|
|
* Any endpoints reached by the /invoices endpoint
|
|
* @var economic_invoices_endpoint
|
|
*/
|
|
public economic_invoices_endpoint $invoices;
|
|
/**
|
|
* Any endpoints reached by the /departments endpoint
|
|
* @var economic_departments_endpoint
|
|
*/
|
|
public economic_departments_endpoint $departments;
|
|
/**
|
|
* Any endpoints reached by the /layouts endpoint
|
|
* @var economic_layouts_endpoint
|
|
*/
|
|
public economic_layouts_endpoint $layouts;
|
|
/**
|
|
* Any endpoints reached by the /customers endpoint
|
|
* @var economic_customers_endpoint
|
|
*/
|
|
public economic_customers_endpoint $customers;
|
|
/**
|
|
* Any endpoints reached by the /products endpoint
|
|
* @var economic_products_endpoint
|
|
*/
|
|
public economic_products_endpoint $products;
|
|
/**
|
|
* Helper classes
|
|
* @var economic_helpers
|
|
*/
|
|
protected economic_helpers $helpers;
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
$this->config = new economic_c();
|
|
$this->orders = new economic_orders_endpoint();
|
|
$this->invoices = new economic_invoices_endpoint();
|
|
$this->departments = new economic_departments_endpoint();
|
|
$this->layouts = new economic_layouts_endpoint();
|
|
$this->customers = new economic_customers_endpoint();
|
|
$this->products = new economic_products_endpoint();
|
|
$this->helpers = new economic_helpers();
|
|
}
|
|
|
|
/**
|
|
* Get a customer by their customer number
|
|
* @param int $customer_number The Economic customer number
|
|
* @return economic_customer
|
|
*/
|
|
public function getCustomer(int $customer_number): economic_customer
|
|
{
|
|
return new $this->helpers->economic_customer($customer_number);
|
|
}
|
|
|
|
/**
|
|
* Get a invoiceDraft (Helper) from the Economic system
|
|
* @param int $draft_invoice_number The Economic draft invoice number
|
|
* @param string $currency The conversion rate to use (default: DKK)
|
|
* @param bool $skip_fetch Skip fetching the invoice draft from the Economic system (default: false)
|
|
* @return economic_invoice_draft
|
|
*/
|
|
public function getInvoiceDraft(int $draft_invoice_number, string $currency = 'DKK', bool $skip_fetch = false): economic_invoice_draft
|
|
{
|
|
return new $this->helpers->economic_invoice_draft($draft_invoice_number, $currency, $skip_fetch);
|
|
}
|
|
|
|
/**
|
|
* Get the tasks helper
|
|
* @return economic_tasks
|
|
*/
|
|
public function getTasks(): economic_tasks
|
|
{
|
|
return new $this->helpers->economic_tasks();
|
|
}
|
|
} |