Skip to content

Commit 6c44bee

Browse files
authored
3.4.0
2 parents 490fbb7 + 3d027a2 commit 6c44bee

6 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/backend/controllers/accounts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def create_supplier(data):
387387
if 'vat_number' in data or 'duns' in data:
388388
if data['vat_number']:
389389
supplier = accounts.get_suppliers({'where': ['vat_number = %s'], 'data': [data['vat_number']]})
390-
if not supplier and data['duns']:
390+
if not supplier and 'duns' in data and data['duns']:
391391
supplier = accounts.get_suppliers({'where': ['duns = %s'], 'data': [data['duns']]})
392392

393393
if not supplier:

src/backend/rest/accounts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def suppliers_list():
3737
check, message = rest_validator(request.args, [
3838
{'id': 'order', 'type': str, 'mandatory': False},
3939
{'id': 'limit', 'type': int, 'mandatory': False},
40-
{'id': 'offset', 'type': int, 'mandatory': False}
40+
{'id': 'offset', 'type': int, 'mandatory': False},
41+
{'id': 'search', 'type': str, 'mandatory': False}
4142
])
4243
if not check:
4344
return make_response({

src/backend/tests/rest/test_accounts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def test_successful_delete_supplier(self):
280280

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

285285
def test_successful_delete_supplier_positions(self):
286286
supplier = self.create_supplier()

src/backend/tests/rest/test_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_successful_reset_password(self):
113113
payload = {
114114
'exp': datetime.now(timezone.utc) + timedelta(minutes=3600),
115115
'iat': datetime.now(timezone.utc),
116-
'sub': user.json['id']
116+
'sub': str(user.json['id'])
117117
}
118118
reset_token = jwt.encode(payload, app.config['SECRET_KEY'].replace("\n", ""), algorithm='HS512')
119119
self.database.execute('UPDATE users SET reset_token = %s WHERE id = %s', (reset_token, user.json['id']))

src/backend/tests/rest/test_verifier.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def setUp(self):
3232
self.database = get_db()
3333
self.app = app.test_client()
3434
self.token = get_token('admin')
35+
warnings.filterwarnings('ignore', category=UserWarning)
3536
warnings.filterwarnings('ignore', category=ResourceWarning)
3637

3738
def create_supplier(self):
@@ -87,15 +88,16 @@ def test_successful_upload_file(self):
8788

8889
self.database.execute("SELECT * FROM documents")
8990
document = self.database.fetchall()
91+
9092
self.assertEqual(supplier.json['id'], document[0]['supplier_id'])
9193
self.assertEqual(408.50, float(document[0]['datas']['total_vat']))
9294
self.assertEqual(2042.5, float(document[0]['datas']['total_ht']))
9395
self.assertEqual(408.50, float(document[0]['datas']['vat_amount']))
9496
self.assertEqual(2451.0, float(document[0]['datas']['total_ttc']))
95-
self.assertEqual("15/12/2016", document[0]['datas']['document_date'])
97+
self.assertEqual("2016-12-15", document[0]['datas']['document_date'])
9698
self.assertEqual("INV-001510", document[0]['datas']['invoice_number'])
9799
self.assertEqual(2042.5, float(document[0]['datas']['no_rate_amount']))
98-
self.assertEqual("14/01/2017", document[0]['datas']['document_due_date'])
100+
self.assertEqual("2017-01-14", document[0]['datas']['document_due_date'])
99101
self.assertEqual("AM161941219-1607", document[0]['datas']['quotation_number'])
100102
self.assertEqual(200, document_res.status_code)
101103

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

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

350354
def test_successful_export_facturx(self):
351355
self.create_supplier()
@@ -357,15 +361,15 @@ def test_successful_export_facturx(self):
357361
response = self.app.post(f'/{CUSTOM_ID}/ws/verifier/documents/' + str(document[0]['id']) + '/export_facturx',
358362
json={'args': output[0]},
359363
headers={"Content-Type": "application/json", 'Authorization': 'Bearer ' + self.token})
360-
364+
filename = response.json
361365
is_facturx = False
362-
with open(f'/var/share/{CUSTOM_ID}/export/verifier/INV-001510_F_15-12-2016_FR04493811251.pdf', 'rb') as f:
366+
with open(f'{filename}', 'rb') as f:
363367
_, _xml_content = facturx.get_facturx_xml_from_pdf(f.read())
364368
if _ is not None:
365369
is_facturx = True
366370

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

371375
def tearDown(self) -> None:

src/backend/verifier_exports.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ def export_facturx(data, log, regex, document_info):
257257
issue_date_parent = Et.SubElement(facturx_document, 'ram:IssueDateTime')
258258
issue_date = Et.SubElement(issue_date_parent, 'udt:DateTimeString', {'format': '102'})
259259
if document_info['datas']['document_due_date']:
260-
issue_date.text = datetime.datetime.strptime(document_info['datas']['document_due_date'],
261-
regex['format_date']).strftime('%Y%m%d')
260+
issue_date.text = datetime.datetime.strptime(document_info['datas']['document_due_date'], '%Y-%m-%d').strftime('%Y%m%d')
262261
else:
263262
issue_date.text = '19700101'
264263

0 commit comments

Comments
 (0)