Skip to content

Commit

Permalink
Merge PR #75 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
github-grap-bot committed Nov 18, 2024
2 parents 733cf1e + cb31cce commit ca07d8b
Showing 9 changed files with 140 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@ keywords:
- "Montant HT +TVA"

fields:
version:
parser: static
value: 1
vat:
parser: static
value: "FR91442060810"
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ keywords:
# - 44206081000029
- "FR91442060810"
- "Montant HT +Tx TVA"
- "Date échéance"

fields:
version:
69 changes: 69 additions & 0 deletions grap_account_invoice_invoice2data_templates/templates/saldac_3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
issuer: Saldac

keywords:
# Note: Il semblerait qu'il y ait plusieurs établissements secondaire
# - 44206081000011
# - 44206081000029
- "FR91442060810"
- "Montant HT +Tx TVA"
- "Conditions de règlement"

fields:
version:
parser: static
value: 3
vat:
parser: static
value: "FR91442060810"
amount:
parser: regex
type: float
regex: Total TTC\s+(\d+\.\d+)
amount_untaxed:
parser: regex
type: float
regex: Total HT\s+(\d+\.\d+)
invoice_number:
parser: regex
regex: Facture N°.*\s+(FA[\w+|\/]+)
date:
parser: regex
type: date
regex: Facture N°.*\s+FA[\w+|\/]+ +(\d{2}\/\d{2}\/\d{2})
date_due:
parser: regex
type: date
regex: Conditions de.*(\d{2}\/\d{2}\/\d{4})
vat_code_055:
parser: static
value: "5.5"
vat_code_200:
parser: static
value: "20.0"
lines:
parser: lines
start: Réf.*TVA
end: Code +Base
# Note: Dans 'P.U net HT', il y a le prix brut. Tout va bien
line: ^ *(?P<product_code>\w+) *(?P<product_name>.*) +(?P<quantity>\d+) +(?P<price_unit>\d+\.\d+) +((?P<discount>\d+(\.\d+)?)%)? +(?P<price_subtotal>\d+\.\d+) +(?P<vat_code>\d+\.\d+)$
types:
quantity: float
price_unit: float
discount: float
price_subtotal: float

options:
currency: EUR
date_formats:
- '%d/%m/%Y'
- '%d/%m/%y'
decimal_separator: '.'
replace:
# Standardize the decimal separator. ('1,24' -> '1.24')
- [',', '.']
# Remove the thousands separator. ('1 234.56' -> '1234.56')
- ['(\d+) (\d{3}\.\d{2})', '\g<1>\g<2>']

# Some product are on two lines
- [' *(.*)\n\s+(\w+) *(\d+\ *\d+\.\d+\ *\d+\.\d+ *2)', '\g<2> \g<1> \g<3>']
- ['\s+\*spp', ' ']
Original file line number Diff line number Diff line change
@@ -43,7 +43,9 @@
from . import test_senfas
from . import test_supersec
from . import test_route_des_comptoirs
from . import test_saldac, test_saldac_2
from . import test_saldac_1
from . import test_saldac_2
from . import test_saldac_3
from . import test_t_air_de_famille
from . import test_thera_viva
from . import test_union_des_fruitieres_bio_comtoises

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ def test_saldac_01(self):
line_qty=5,
expected_values={
"issuer": "Saldac",
"version": 1,
"date": datetime(day=7, month=12, year=2022),
"date_due": datetime(day=6, month=1, year=2023),
"invoice_number": "FA22/4381",
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ def test_saldac_2_01(self):
line_qty=8,
expected_values={
"issuer": "Saldac",
"version": 2,
"date": datetime(day=15, month=7, year=2024),
"date_due": datetime(day=22, month=7, year=2024),
"invoice_number": "FA243352",
60 changes: 60 additions & 0 deletions grap_account_invoice_invoice2data_templates/tests/test_saldac_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import datetime

from .test_module import TestModule


class TestSaldac(TestModule):
def test_saldac_3_01(self):
self._test_supplier_template(
"saldac__2024-08-20__LUC__FA243718.pdf",
line_qty=4,
expected_values={
"issuer": "Saldac",
"version": 3,
"date": datetime(day=20, month=8, year=2024),
"date_due": datetime(day=27, month=8, year=2024),
"invoice_number": "FA243718",
"amount_untaxed": 437.32,
"amount": 461.37,
},
expected_lines=[
{
"product_code": "CAFEM1KG",
"product_name": "Café moulu bio. El Palomar - Pérou 1 kg. *SPP",
"vat_code": "5.5",
"quantity": 18.0,
"price_unit": 13.75,
"discount": 2.0,
"price_subtotal": 242.55,
}
],
)

def test_saldac_3_02(self):
self._test_supplier_template(
"saldac__2024-09-24__LUC_FA244308.pdf",
line_qty=8,
expected_values={
"issuer": "Saldac",
"version": 3,
"date": datetime(day=24, month=9, year=2024),
"date_due": datetime(day=1, month=10, year=2024),
"invoice_number": "FA244308",
"amount_untaxed": 909.17,
"amount": 959.17,
},
expected_lines=[
{
"product_code": "NOIXAMA2KG",
"product_name": "Noix Amazonie grillée bio. Pérou. sac de 2 kg",
"vat_code": "5.5",
"quantity": 1.0,
"price_unit": 45.2,
"discount": 2.0,
"price_subtotal": 44.3,
}
],
)

0 comments on commit ca07d8b

Please sign in to comment.