e-invoice : display errors if cannot be created
This commit is contained in:
parent
73f1fc930a
commit
244249132f
6 changed files with 128 additions and 56 deletions
|
|
@ -69,6 +69,7 @@ BODY {
|
|||
--font-button:'roboto light';
|
||||
--font-super:'roboto regular';
|
||||
--font-title:'Montserrat Regular';
|
||||
--bg-inner-box:#DCE1EF;
|
||||
}
|
||||
input{
|
||||
font-family: 'OpenSansRegular';
|
||||
|
|
@ -1252,7 +1253,7 @@ box-shadow: 10px 10px 5px #888;
|
|||
*******************************************************************************/
|
||||
|
||||
div.inner_box {
|
||||
background-color: #DCE1EF;
|
||||
background-color: var(--bg-inner-box);
|
||||
font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
|
||||
font-family: 'OpenSansRegular';
|
||||
/*! font-family: 'var(--font-button)'; */
|
||||
|
|
@ -1271,7 +1272,7 @@ div.inner_box {
|
|||
left:0px ;
|
||||
}
|
||||
div.inner_box2 {
|
||||
background-color: #DCE1EF;
|
||||
background-color: var(--bg-inner-box);
|
||||
font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
|
||||
font-family: 'OpenSansRegular';
|
||||
/*! font-family: 'var(--font-button)'; */
|
||||
|
|
@ -2349,7 +2350,7 @@ table.vert_mtitle {
|
|||
|
||||
}
|
||||
table.vert_mtitle td.first {
|
||||
background-color: #DCE1EF;
|
||||
background-color: var(--bg-inner-box);
|
||||
}
|
||||
table.vert_mtitle td {
|
||||
border : 1px solid #99B1DF;
|
||||
|
|
@ -2567,7 +2568,7 @@ td.box {
|
|||
|
||||
.smoke {
|
||||
text-align: center;
|
||||
background-color: #DCE1EF;
|
||||
background-color: var(--bg-inner-box);
|
||||
margin:0px;
|
||||
overflow:hidden;
|
||||
z-index:3;
|
||||
|
|
@ -4072,4 +4073,20 @@ h2.h-section {
|
|||
margin-bottom: 0.5rem;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/**
|
||||
electronc invoice errors in SALE
|
||||
*/
|
||||
#invoice_error_popover {
|
||||
background-color: var(--bg-inner-box);
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
padding: 1rem;
|
||||
left: 10%;
|
||||
border:1px solid navy;
|
||||
}
|
||||
/**
|
||||
* Button error
|
||||
*/
|
||||
.bt-error {
|
||||
color:var(--color-red);
|
||||
}
|
||||
|
|
@ -517,7 +517,6 @@ class InvoiceUBL21 extends XMLInvoice {
|
|||
@code
|
||||
<cac:AdditionalDocumentReference>
|
||||
<cbc:ID>P01</cbc:ID>
|
||||
<cbc:DocumentType>InvoicePDF</cbc:DocumentType>
|
||||
<cbc:DocumentDescription>Facture PDF</cbc:DocumentDescription>
|
||||
<cac:Attachment>
|
||||
<cbc:EmbeddedDocumentBinaryObject
|
||||
|
|
@ -528,7 +527,6 @@ class InvoiceUBL21 extends XMLInvoice {
|
|||
<!-- OU -->
|
||||
<cac:AdditionalDocumentReference>
|
||||
<cbc:ID>REF_ODT_001</cbc:ID>
|
||||
<cbc:DocumentType>OpenDocument</cbc:DocumentType>
|
||||
<cbc:DocumentDescription>Fichier OpenDocument</cbc:DocumentDescription>
|
||||
<cac:Attachment>
|
||||
<cbc:EmbeddedDocumentBinaryObject
|
||||
|
|
@ -566,9 +564,6 @@ class InvoiceUBL21 extends XMLInvoice {
|
|||
$attachment->appendChild($embeddedDocument);
|
||||
|
||||
$result->appendChild($id);
|
||||
// ERROR FOR BELGIUM !
|
||||
// $documentType=$this->createElement("cbc:DocumentType",'application/pdf');
|
||||
// $result->appendChild($documentType);
|
||||
$result->appendChild($document_description);
|
||||
$result->appendChild($attachment);
|
||||
|
||||
|
|
@ -594,9 +589,11 @@ class InvoiceUBL21 extends XMLInvoice {
|
|||
|
||||
$root->appendChild($this->createElement('cbc:ID',$this->data['id']));
|
||||
$root->appendChild($this->createElement('cbc:IssueDate',$this->data['issue_date']));
|
||||
if ($this->data ['due_date'] != '') {
|
||||
$root->appendChild($this->createElement('cbc:DueDate',$this->data['due_date']));
|
||||
if ($this->data ['due_date'] == '')
|
||||
{
|
||||
$this->data ['due_date']=$this->data['issue_date'];
|
||||
}
|
||||
$root->appendChild($this->createElement('cbc:DueDate',$this->data['due_date']));
|
||||
$root->appendChild($this->createElement('cbc:InvoiceTypeCode',380));
|
||||
$root->appendChild($this->createElement('cbc:DocumentCurrencyCode',$this->data['currency']));
|
||||
$root->appendChild($this->createElement('cbc:BuyerReference',"NOALYSS"));
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ namespace Noalyss\XMLDocument;
|
|||
)
|
||||
|
||||
[currency] => 0
|
||||
[info] => Array
|
||||
[order] = order reference
|
||||
[comment] = comment added to the invoice
|
||||
[operation] => Array
|
||||
(
|
||||
[0] => Array
|
||||
|
|
@ -208,7 +211,24 @@ abstract class XMLInvoice extends \DOMDocument
|
|||
|
||||
$result['operation'][$i]['vat_reversed']=$operation->det->array[$i]['qs_vat_sided'];
|
||||
}
|
||||
// retrieve currency
|
||||
//------------------------------------------------
|
||||
// retrieve order and comment
|
||||
//------------------------------------------------
|
||||
$a_row=$this->cn->get_array("select id_type,ji_value from jrn_info where jr_id=$1"
|
||||
,[$jr_id]);
|
||||
$nb_row = count($a_row);
|
||||
$result['info']=[];
|
||||
for($i=0;$i<$nb_row;$i++) {
|
||||
switch ($a_row[$i]['id_type']) {
|
||||
case 'BON_COMMANDE':
|
||||
$result['info']['order']=$a_row[$i]['ji_value'];
|
||||
break;
|
||||
case 'OTHER':
|
||||
$result['info']['comment']=$a_row[$i]['ji_value'];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -944,7 +944,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
|
|||
$r.='</tr>';
|
||||
|
||||
$r.='<tr>';
|
||||
$r.='<td> ' . _('Client') . '</td><td> ' . hb($e_client . ':' . $client_name) . '</td>';
|
||||
$r.='<td> ' . _('Client') . '</td><td> ' . HtmlInput::card_detail($e_client).":".hb( $client_name) . '</td>';
|
||||
$r.='</tr>';
|
||||
$r.='</table>';
|
||||
$r.='<pre>'._('Note').' '.h($p_array['jrn_note_input']).'</pre>';
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ if ( isset ($_POST['view_invoice'] ) )
|
|||
$xmldocument= \Noalyss\XMLDocument\XMLInvoice::build_xmlinvoice($cn);
|
||||
$array=[];
|
||||
$array['supplier']=$xmldocument->fill_supplier();
|
||||
echo "customer ",$http->post("e_client");
|
||||
$customer=Fiche::from_qcode($cn,trim($http->post("e_client")));
|
||||
|
||||
$array['customer']=$xmldocument->fill_customer($customer->id);
|
||||
|
|
@ -169,22 +168,32 @@ if ( isset($_POST['record']) )
|
|||
$receipt= HtmlInput::show_receipt_document($Ledger->jr_id
|
||||
,h($file));
|
||||
$acc_document=new Acc_Document($cn,$Ledger->jr_id);
|
||||
//-----------------------------------------------------------------
|
||||
//-------------------------------------------------------
|
||||
// Generate a XLM invoice
|
||||
// if a document has been created create the XML file
|
||||
//-----------------------------------------------------------------
|
||||
//-------------------------------------------------------
|
||||
///@var $flag_invoice (int) error for invoice generating.
|
||||
/// 0 = nothing
|
||||
/// 1 = cannot create e-invoice
|
||||
/// 2 = create e-invoice requested
|
||||
|
||||
$flag_invoice=0;
|
||||
if ($g_parameter->MY_INVOICE_FORMAT != 'BASIC' && ! empty($acc_document->d_filename ))
|
||||
{
|
||||
|
||||
$flag_invoice=2;
|
||||
$xmldocument= \Noalyss\XMLDocument\XMLInvoice::build_xmlinvoice($cn);
|
||||
$xmldocument->build_data($Ledger->jr_id);
|
||||
$code_error = $xmldocument->verify() ;
|
||||
if ( ! empty( $code_error ) ) {
|
||||
echo "Impossible de générer facture : code error ";
|
||||
\Noalyss\Dbg::echo_var(1, '$code_error is ');
|
||||
\Noalyss\Dbg::echo_var(1, $code_error);
|
||||
// echo $xmldocument->get_message_error($code_error);
|
||||
$xmldocument->display_error();
|
||||
$flag_invoice=1;
|
||||
}
|
||||
}
|
||||
//----------------------7--------------------------
|
||||
// flag_invoice == 2 , generate an e-invoice
|
||||
//------------------------------------------------
|
||||
if ( $flag_invoice == 2 )
|
||||
{
|
||||
$pdf_filename=$acc_document->transform2pdf();
|
||||
|
||||
// save PDF In db
|
||||
|
|
@ -213,6 +222,7 @@ if ( isset($_POST['record']) )
|
|||
$receipt= HtmlInput::show_receipt_document($Ledger->jr_id,$acc_document->d_filename);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,8 +245,11 @@ if ( isset($_POST['record']) )
|
|||
}
|
||||
|
||||
/* Show button */
|
||||
echo '<h1> Enregistrement </h1>';
|
||||
|
||||
echo '<h1>'._("Enregistré").'</h1>';
|
||||
if ($flag_invoice == 1) {
|
||||
echo_warning(_("Impossible de générer facture électronique") );
|
||||
$xmldocument->display_error();
|
||||
}
|
||||
echo $Ledger->confirm($_POST,true);
|
||||
/* Show link for Invoice */
|
||||
if ($receipt != "")
|
||||
|
|
|
|||
|
|
@ -25,75 +25,100 @@
|
|||
* @brief display errors for generating e-invoices, called from
|
||||
* invoiceUBL21-display-error.php
|
||||
*/
|
||||
//var @a_error (array) contains error
|
||||
///@var $a_vat_error (array) contains error for VAT
|
||||
$a_vat_error=$this->check_VAT();
|
||||
|
||||
if ( count($a_error) == 0) return;
|
||||
///@var $total_error (int) total of errors found in e-invoice
|
||||
$total_error=count ($a_error['general'])
|
||||
+ count($a_error['operation'])
|
||||
+ count($a_error['customer'])
|
||||
+ count($a_error['company'])
|
||||
+count($a_vat_error);
|
||||
|
||||
if ( $total_error == 0 ) :
|
||||
return;
|
||||
endif;
|
||||
$error_message=new \Noalyss\XMLDocument\Error_Message($a_error);
|
||||
var_dump($a_error);
|
||||
?>
|
||||
<div class="notice" >
|
||||
<h3><?=_("Société")?></h3>
|
||||
<p class="text-muted">
|
||||
<?=_("A corriger dans COMPANY")?>
|
||||
</p>
|
||||
<button onclick="$('invoice_error_popover').show();return false" class="button bt-error "><i class="icon-attention"></i> <?=_("Erreurs Facture électronique {$total_error}")?></button>
|
||||
<div style="display:none" id="invoice_error_popover">
|
||||
<?php
|
||||
echo HtmlInput::title_box(_("Erreurs"), "invoice_error_popover","hide");
|
||||
//----------------------------------------------------------------------------
|
||||
// company
|
||||
//----------------------------------------------------------------------------
|
||||
$nb_error=count($a_error['company']);
|
||||
for ($i=0;$i<$nb_error;$i++):
|
||||
?>
|
||||
<div class="notice-item">
|
||||
|
||||
<?php if ($i == 0 ):?>
|
||||
<h3><?=_("Société")?></h3>
|
||||
<p class="text-muted">
|
||||
<?=_("A corriger dans COMPANY")?>
|
||||
</p>
|
||||
<ol>
|
||||
<?php endif;?>
|
||||
<li class="notice-item">
|
||||
<?=$error_message->get_message_error(code:$a_error['company'][$i],type:'company')?>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
endfor;
|
||||
if ( $nb_error!=0) print '</ol>';
|
||||
?>
|
||||
<h3><?=_("Client")?></h3>
|
||||
<p class="text-muted">
|
||||
<?=_("A corriger dans la fiche")?>
|
||||
</p>
|
||||
<?php
|
||||
<?php
|
||||
//----------------------------------------------------------------------------
|
||||
// Customer
|
||||
//----------------------------------------------------------------------------
|
||||
$nb_error=count($a_error['customer']);
|
||||
for ($i=0;$i<$nb_error;$i++):
|
||||
?>
|
||||
<div class="notice-item">
|
||||
<?php if ($i == 0) :?>
|
||||
<h3><?=_("Client")?></h3>
|
||||
<p class="text-muted">
|
||||
<?=_("A corriger dans la fiche")?>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
$card=new \Fiche ($this->cn,$this->data['customer']['card_id']);
|
||||
echo \HtmlInput::card_detail($card->get_attribute(ATTR_DEF_QUICKCODE)
|
||||
,$card->get_attribute(ATTR_DEF_NAME));
|
||||
?>
|
||||
</p>
|
||||
<ol>
|
||||
<?php endif;?>
|
||||
|
||||
<li class="notice-item">
|
||||
<?=$error_message->get_message_error(code:$a_error['customer'][$i],type:'customer')?>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
endfor;
|
||||
if ( $nb_error!=0) print '</ol>';
|
||||
?>
|
||||
<h3><?=_("Opération")?></h3>
|
||||
<p class="text-muted">
|
||||
<?=_("A corriger dans l'opération")?>
|
||||
</p>
|
||||
<?php
|
||||
if ( ! isset($this->data['due_date']) || $this->data['due_date']==""):
|
||||
?>
|
||||
<div class="notice-item">
|
||||
<?=_("Date échéance nécessaire")?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
endif;
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
// Item VAT
|
||||
//----------------------------------------------------------------------------
|
||||
$a_vat_error=$this->check_VAT();
|
||||
$nb_error=count($a_vat_error);
|
||||
for ($i=0;$i<$nb_error;$i++):
|
||||
?>
|
||||
<div class="notice-item">
|
||||
<?php if ($i == 0) :?>
|
||||
<h3><?=_("TVA")?></h3>
|
||||
<p class="text-muted">
|
||||
<?=_("A corriger dans la configuration TVA (C0TVA)")?>
|
||||
</p>
|
||||
<ol>
|
||||
<?php endif;?>
|
||||
<li class="notice-item">
|
||||
<?=$a_vat_error[$i]?>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
endfor;
|
||||
if ( $nb_error!=0) print '</ol>';
|
||||
?>
|
||||
<button onclick="$('invoice_error_popover').hide();return false" class="button"><?=_("Fermer")?></button>
|
||||
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue