Skip to content

Commit

Permalink
3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan30 authored Feb 3, 2025
2 parents 490fbb7 + 3d027a2 commit 6c44bee
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/backend/controllers/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def create_supplier(data):
if 'vat_number' in data or 'duns' in data:
if data['vat_number']:
supplier = accounts.get_suppliers({'where': ['vat_number = %s'], 'data': [data['vat_number']]})
if not supplier and data['duns']:
if not supplier and 'duns' in data and data['duns']:
supplier = accounts.get_suppliers({'where': ['duns = %s'], 'data': [data['duns']]})

if not supplier:
Expand Down
3 changes: 2 additions & 1 deletion src/backend/rest/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def suppliers_list():
check, message = rest_validator(request.args, [
{'id': 'order', 'type': str, 'mandatory': False},
{'id': 'limit', 'type': int, 'mandatory': False},
{'id': 'offset', 'type': int, 'mandatory': False}
{'id': 'offset', 'type': int, 'mandatory': False},
{'id': 'search', 'type': str, 'mandatory': False}
])
if not check:
return make_response({
Expand Down
2 changes: 1 addition & 1 deletion src/backend/tests/rest/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def test_successful_delete_supplier(self):

self.database.execute("SELECT status FROM accounts_supplier WHERE id = " + str(supplier.json['id']))
new_supplier = self.database.fetchall()
self.assertEqual("DEL", new_supplier[0]['status'])
self.assertEqual(0, len(new_supplier))

def test_successful_delete_supplier_positions(self):
supplier = self.create_supplier()
Expand Down
2 changes: 1 addition & 1 deletion src/backend/tests/rest/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_successful_reset_password(self):
payload = {
'exp': datetime.now(timezone.utc) + timedelta(minutes=3600),
'iat': datetime.now(timezone.utc),
'sub': user.json['id']
'sub': str(user.json['id'])
}
reset_token = jwt.encode(payload, app.config['SECRET_KEY'].replace("\n", ""), algorithm='HS512')
self.database.execute('UPDATE users SET reset_token = %s WHERE id = %s', (reset_token, user.json['id']))
Expand Down
18 changes: 11 additions & 7 deletions src/backend/tests/rest/test_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def setUp(self):
self.database = get_db()
self.app = app.test_client()
self.token = get_token('admin')
warnings.filterwarnings('ignore', category=UserWarning)
warnings.filterwarnings('ignore', category=ResourceWarning)

def create_supplier(self):
Expand Down Expand Up @@ -87,15 +88,16 @@ def test_successful_upload_file(self):

self.database.execute("SELECT * FROM documents")
document = self.database.fetchall()

self.assertEqual(supplier.json['id'], document[0]['supplier_id'])
self.assertEqual(408.50, float(document[0]['datas']['total_vat']))
self.assertEqual(2042.5, float(document[0]['datas']['total_ht']))
self.assertEqual(408.50, float(document[0]['datas']['vat_amount']))
self.assertEqual(2451.0, float(document[0]['datas']['total_ttc']))
self.assertEqual("15/12/2016", document[0]['datas']['document_date'])
self.assertEqual("2016-12-15", document[0]['datas']['document_date'])
self.assertEqual("INV-001510", document[0]['datas']['invoice_number'])
self.assertEqual(2042.5, float(document[0]['datas']['no_rate_amount']))
self.assertEqual("14/01/2017", document[0]['datas']['document_due_date'])
self.assertEqual("2017-01-14", document[0]['datas']['document_due_date'])
self.assertEqual("AM161941219-1607", document[0]['datas']['quotation_number'])
self.assertEqual(200, document_res.status_code)

Expand Down Expand Up @@ -332,7 +334,8 @@ def test_successful_export_xml(self):
json={'args': output[0]},
headers={"Content-Type": "application/json", 'Authorization': 'Bearer ' + self.token})
self.assertEqual(200, response.status_code)
self.assertTrue(os.path.isfile(f'/var/share/{CUSTOM_ID}/export/verifier/INV-001510_F_15-12-2016_FR04493811251.xml'))
filename = response.json
self.assertTrue(os.path.isfile(f'{filename}'))

def test_successful_export_pdf(self):
self.create_supplier()
Expand All @@ -345,7 +348,8 @@ def test_successful_export_pdf(self):
json={'args': output[0]},
headers={"Content-Type": "application/json", 'Authorization': 'Bearer ' + self.token})
self.assertEqual(200, response.status_code)
self.assertTrue(os.path.isfile(f'/var/share/{CUSTOM_ID}/export/verifier/INV-001510_F_15-12-2016_FR04493811251.pdf'))
filename = response.json
self.assertTrue(os.path.isfile(f'{filename}'))

def test_successful_export_facturx(self):
self.create_supplier()
Expand All @@ -357,15 +361,15 @@ def test_successful_export_facturx(self):
response = self.app.post(f'/{CUSTOM_ID}/ws/verifier/documents/' + str(document[0]['id']) + '/export_facturx',
json={'args': output[0]},
headers={"Content-Type": "application/json", 'Authorization': 'Bearer ' + self.token})

filename = response.json
is_facturx = False
with open(f'/var/share/{CUSTOM_ID}/export/verifier/INV-001510_F_15-12-2016_FR04493811251.pdf', 'rb') as f:
with open(f'{filename}', 'rb') as f:
_, _xml_content = facturx.get_facturx_xml_from_pdf(f.read())
if _ is not None:
is_facturx = True

self.assertEqual(200, response.status_code)
self.assertTrue(os.path.isfile(f'/var/share/{CUSTOM_ID}/export/verifier/INV-001510_F_15-12-2016_FR04493811251.pdf'))
self.assertTrue(os.path.isfile(f'{filename}'))
self.assertTrue(is_facturx)

def tearDown(self) -> None:
Expand Down
3 changes: 1 addition & 2 deletions src/backend/verifier_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ def export_facturx(data, log, regex, document_info):
issue_date_parent = Et.SubElement(facturx_document, 'ram:IssueDateTime')
issue_date = Et.SubElement(issue_date_parent, 'udt:DateTimeString', {'format': '102'})
if document_info['datas']['document_due_date']:
issue_date.text = datetime.datetime.strptime(document_info['datas']['document_due_date'],
regex['format_date']).strftime('%Y%m%d')
issue_date.text = datetime.datetime.strptime(document_info['datas']['document_due_date'], '%Y-%m-%d').strftime('%Y%m%d')
else:
issue_date.text = '19700101'

Expand Down

0 comments on commit 6c44bee

Please sign in to comment.