Author: |
Camptocamp SA |
License: |
no license |
Branch: |
merge-branch-2534-12.0.0.0.1 |
Repository: |
camptocamp/connector-magento |
Dependencies: |
crm_claim_rma,
decimal_precision,
and
specific_fct |
Languages: |
PO File (77, 8.5%),
Python (709, 77.9%),
XML (64, 7.0%),
and
reStructuredText (60, 6.6%) |
<h1 class="title">Debonix Supplier Invoice EDI</h1>
<p>This module adds a scheduled action to connect to FTP and retrieve EDIFACT
files to import supplier invoices from the supplier SOGEDESCA
(Descours et Cabaud)</p>
<a name="workflow"></a>
<h2>Workflow</h2>
<p>The ir.cron is run once a day and do following actions :</p>
<ol class="arabic simple">
<li>Connect to FTP using server and credentials defined on the company (edifact_host, edifact_user, edifact_password)</li>
<li>Retrieve files from the FTP server in the folder defined by company.edifact_supplier_invoice_import_path</li>
<li>Parse files and do the following (according to the invoice_type) :<ol class="loweralpha">
<li>If the invoice type is a customer invoice<ol class="arabic">
<li>Find the related invoice</li>
<li>Delete existing invoice lines</li>
<li>Create lines according to imported edifact file</li>
<li>Validate the invoice</li>
</ol>
</li>
<li>If the invoice type is a customer refund<ol class="arabic">
<li>Create the refund according to imported edifact file</li>
</ol>
</li>
</ol>
</li>
<li>If something went wrong (see below possible <a class="reference internal" href="#errors-types">Errors types</a> below), create a crm.claim of type SOGEDESCA with errors messages as description and failed chunks as attachment.</li>
<li>Connect to FTP and do the following :<ol class="arabic">
<li>Create success file (merged chunks) in the folder defined by company.edifact_supplier_invoice_import_success_path</li>
<li>Create failed file (merged chunks) in the folder defined by company.edifact_supplier_invoice_import_error_path</li>
<li>Commit the Database transaction to persist the changes done</li>
<li>Delete processed edifact files.</li>
</ol>
</li>
</ol>
<a name="errors-types"></a>
<h2>Errors types</h2>
<p>The following exceptions and their possible reasons are defined by the module :</p>
<ul class="simple">
<li>EdifactPurchaseInvoiceParsingError :</li>
</ul>
<blockquote>
<ul class="simple">
<li>The processed edifact chunk is not formatted correctly</li>
</ul>
</blockquote>
<ul class="simple">
<li>EdifactPurchaseInvoiceNotFound :</li>
</ul>
<blockquote>
<ul class="simple">
<li>The purchase order defined in edifact cannot be found</li>
<li>The purchase order defined in edifact has no invoice</li>
<li>The purchase order defined in edifact has multiple invoices</li>
</ul>
</blockquote>
<ul class="simple">
<li>EdifactPurchaseInvoiceProductNotFound</li>
</ul>
<blockquote>
<ul class="simple">
<li>There is no products matching the product code defined in edifact</li>
<li>The product is found but does not appear on the found invoice</li>
</ul>
</blockquote>
<ul class="simple">
<li>EdifactPurchaseInvoiceTotalDifference</li>
</ul>
<blockquote>
<ul class="simple">
<li>The line total defined in edifact is different than the subtotal computed by OpenERP.</li>
</ul>
</blockquote>
<a name="manual-testing"></a>
<h2>Manual Testing</h2>
<p>As the module works with an ir.cron connecting to a FTP server, unittests are
quite limited. However, it's quite easy to set up a local FTP server using
Docker to test it manually.</p>
<p>Following courtesy of : <a class="reference external" href="https://hub.docker.com/r/stilliard/pure-ftpd/">Docker Pure-ftpd Server</a></p>
<ol class="arabic">
<li><p class="first">Launch server</p>
<pre>
<code>docker pull stilliard/pure-ftpd:hardened
docker run -d --name ftpd_server -p 21:21 -p 30000-30009:30000-30009 -e "PUBLICHOST=localhost" stilliard/pure-ftpd:hardened</code>
</pre>
</li>
<li><p class="first">Create user sogedesca_edi_test with access to /home/ftpusers/edi_supplier</p>
<pre>
<code>docker exec -it ftpd_server /bin/bash
pure-pw useradd sogedesca_edi_test -f /etc/pure-ftpd/passwd/pureftpd.passwd -m -u ftpuser -d /home/ftpusers/edi_supplier</code>
</pre>
</li>
<li><p class="first">Connect to your server</p>
<pre>
<code>ftp -p localhost 21</code>
</pre>
<p>Enter credentials defined above.</p>
</li>
<li><p class="first">Create folders</p>
<pre>
<code>mkdir edi_supplier
cd edi_supplier
mkdir archive
mkdir erreur</code>
</pre>
</li>
<li><p class="first">Upload edifact files and wait for the scheduled task to start.</p>
</li>
</ol>