Missing Api for standing proposal/orders/invoices

This commit is contained in:
Laurent Destailleur 2018-02-01 02:29:41 +01:00
parent 74a34acf77
commit f6f57aa938
2 changed files with 136 additions and 3 deletions

View File

@ -551,6 +551,139 @@ class Thirdparties extends DolibarrApi
}
/**
* Get outstanding proposals of thirdparty
*
* @param int $id ID of the thirdparty
* @param string $mode 'customer' or 'supplier'
*
* @url GET {id}/outstandingproposals
*
* @return array List of outstandings proposals of thirdparty
*
* @throws 400
* @throws 401
* @throws 404
*/
function getOutStandingProposals($id, $mode='customer')
{
$obj_ret = array();
if(! DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Thirdparty ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->company->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Thirdparty not found');
}
$result = $this->company->getOutstandingProposals($mode);
unset($result['total_ht']);
unset($result['total_ttc']);
return $result;
}
/**
* Get outstanding orders of thirdparty
*
* @param int $id ID of the thirdparty
* @param string $mode 'customer' or 'supplier'
*
* @url GET {id}/outstandingorders
*
* @return array List of outstandings orders of thirdparty
*
* @throws 400
* @throws 401
* @throws 404
*/
function getOutStandingOrder($id, $mode='customer')
{
$obj_ret = array();
if(! DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Thirdparty ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->company->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Thirdparty not found');
}
$result = $this->company->getOutstandingOrders($mode);
unset($result['total_ht']);
unset($result['total_ttc']);
return $result;
}
/**
* Get outstanding invoices of thirdparty
*
* @param int $id ID of the thirdparty
* @param string $mode 'customer' or 'supplier'
*
* @url GET {id}/outstandinginvoices
*
* @return array List of outstandings invoices of thirdparty
*
* @throws 400
* @throws 401
* @throws 404
*/
function getOutStandingInvoices($id, $mode='customer')
{
$obj_ret = array();
if(! DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Thirdparty ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->company->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Thirdparty not found');
}
$result = $this->company->getOutstandingBills($mode);
unset($result['total_ht']);
unset($result['total_ttc']);
return $result;
}
/**
* Get fixed amount discount of a thirdparty (all sources: deposit, credit note, commercial offers...)
*

View File

@ -3466,7 +3466,7 @@ class Societe extends CommonObject
$outstandingOpened+=$obj->total_ttc;
}
}
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
}
else
return array();
@ -3506,7 +3506,7 @@ class Societe extends CommonObject
$outstandingOpened+=$obj->total_ttc;
}
}
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
}
else
return array();
@ -3577,7 +3577,7 @@ class Societe extends CommonObject
$outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits;
}
}
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
}
else
{