Remove the "add" in addpayment. Action in API is hosted by the method
This commit is contained in:
parent
36f7f32205
commit
309e83a946
@ -794,7 +794,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ')
|
* @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ')
|
||||||
* @param string $chqbank {@from body} Issuer bank name (optional)
|
* @param string $chqbank {@from body} Issuer bank name (optional)
|
||||||
*
|
*
|
||||||
* @url POST {id}/addpayment
|
* @url POST {id}/payments
|
||||||
*
|
*
|
||||||
* @return int Payment ID
|
* @return int Payment ID
|
||||||
* @throws 400
|
* @throws 400
|
||||||
@ -818,29 +818,29 @@ class Invoices extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$request_data = (object) $payment_data;
|
$request_data = (object) $payment_data;
|
||||||
|
|
||||||
if (! empty($conf->banque->enabled)) {
|
if (! empty($conf->banque->enabled)) {
|
||||||
if(empty($accountid)) {
|
if(empty($accountid)) {
|
||||||
throw new RestException(400, 'Account ID is mandatory');
|
throw new RestException(400, 'Account ID is mandatory');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($paiementid)) {
|
if(empty($paiementid)) {
|
||||||
throw new RestException(400, 'Paiement ID or Paiement Code is mandatory');
|
throw new RestException(400, 'Paiement ID or Paiement Code is mandatory');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = $this->invoice->fetch($id);
|
$result = $this->invoice->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Invoice not found');
|
throw new RestException(404, 'Invoice not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate amount to pay
|
// Calculate amount to pay
|
||||||
$totalpaye = $this->invoice->getSommePaiement();
|
$totalpaye = $this->invoice->getSommePaiement();
|
||||||
$totalcreditnotes = $this->invoice->getSumCreditNotesUsed();
|
$totalcreditnotes = $this->invoice->getSumCreditNotesUsed();
|
||||||
$totaldeposits = $this->invoice->getSumDepositsUsed();
|
$totaldeposits = $this->invoice->getSumDepositsUsed();
|
||||||
$resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
|
$resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
// Clean parameters amount if payment is for a credit note
|
// Clean parameters amount if payment is for a credit note
|
||||||
if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) {
|
if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) {
|
||||||
@ -857,7 +857,7 @@ class Invoices extends DolibarrApi
|
|||||||
$multicurrency_amounts[$id] = $newvalue;
|
$multicurrency_amounts[$id] = $newvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Creation of payment line
|
// Creation of payment line
|
||||||
$paiement = new Paiement($this->db);
|
$paiement = new Paiement($this->db);
|
||||||
$paiement->datepaye = $datepaye;
|
$paiement->datepaye = $datepaye;
|
||||||
@ -874,10 +874,10 @@ class Invoices extends DolibarrApi
|
|||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
throw new RestException(400, 'Payment error : '.$paiement->error);
|
throw new RestException(400, 'Payment error : '.$paiement->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->banque->enabled)) {
|
if (! empty($conf->banque->enabled)) {
|
||||||
$label='(CustomerInvoicePayment)';
|
$label='(CustomerInvoicePayment)';
|
||||||
|
|
||||||
if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) {
|
if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) {
|
||||||
throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode);
|
throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user