toulouse-maelis: facturation (post-paiement) (#74790) #120
|
@ -74,3 +74,17 @@ ADD_DIRECT_DEBIT_ORDER_SCHEMA = {
|
|||
'additionalProperties': False,
|
||||
'unflatten': True,
|
||||
}
|
||||
|
||||
|
||||
PAYMENT_SCHEMA = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'transaction_date': {
|
||||
'type': 'string',
|
||||
},
|
||||
'transaction_id': {
|
||||
'type': 'string',
|
||||
},
|
||||
},
|
||||
'required': ['transaction_date', 'transaction_id'],
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
# Generated by Django 3.2.18 on 2023-04-06 15:06
|
||||
|
||||
import django.core.serializers.json
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('toulouse_maelis', '0006_auto_20230324_1730'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Invoice',
|
||||
fields=[
|
||||
(
|
||||
'id',
|
||||
models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||
),
|
||||
('regie_id', models.CharField(max_length=128)),
|
||||
('family_id', models.CharField(max_length=128)),
|
||||
('invoice_id', models.CharField(max_length=128)),
|
||||
(
|
||||
'maelis_data',
|
||||
models.JSONField(
|
||||
encoder=django.core.serializers.json.DjangoJSONEncoder, verbose_name='Data'
|
||||
),
|
||||
),
|
||||
(
|
||||
'lingo_data',
|
||||
models.JSONField(
|
||||
encoder=django.core.serializers.json.DjangoJSONEncoder, null=True, verbose_name='Data'
|
||||
),
|
||||
),
|
||||
('created', models.DateTimeField(auto_now_add=True, verbose_name='Created')),
|
||||
('updated', models.DateTimeField(auto_now=True, verbose_name='Updated')),
|
||||
('canceled', models.DateTimeField(null=True, verbose_name='Canceled')),
|
||||
('notified', models.DateTimeField(null=True, verbose_name='Notified')),
|
||||
(
|
||||
'resource',
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to='toulouse_maelis.toulousemaelis'
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'ordering': ('resource', 'regie_id', 'invoice_id'),
|
||||
'unique_together': {('resource', 'invoice_id')},
|
||||
},
|
||||
),
|
||||
]
|
|
@ -24,6 +24,7 @@ from dateutil import rrule
|
|||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db import models
|
||||
from django.db.models import JSONField
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.utils import dateformat
|
||||
from django.utils.dateparse import parse_date
|
||||
from django.utils.text import slugify
|
||||
|
@ -36,6 +37,7 @@ from passerelle.base.models import BaseResource, HTTPResource
|
|||
from passerelle.utils.api import endpoint
|
||||
from passerelle.utils.conversion import simplify
|
||||
from passerelle.utils.jsonresponse import APIError
|
||||
from passerelle.utils.soap import SOAPError
|
||||
from passerelle.utils.templates import render_to_string
|
||||
|
||||
from . import activity_schemas, family_schemas, invoice_schemas, schemas, utils
|
||||
|
@ -975,6 +977,11 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
and response['RL1']['birth']['dateBirth'].strftime('%Y-%m-%d') == post_data['dateBirth']
|
||||
):
|
||||
raise APIError("RL1 does not match '%s' family" % family_id)
|
||||
|
||||
# put invoices into cache
|
||||
for regie in self.get_referential('Regie'):
|
||||
self.get_invoices(family_id, regie['id'])
|
||||
|
||||
Link.objects.update_or_create(resource=self, name_id=NameID, defaults={'family_id': family_id})
|
||||
return {'data': 'ok'}
|
||||
|
||||
|
@ -3747,6 +3754,196 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
def read_regie_list(self, request):
|
||||
return {'data': self.get_referential('Regie')}
|
||||
|
||||
def get_invoices(self, family_id, regie_id):
|
||||
self.assert_key_in_referential('Regie', regie_id, 'regie_id parameter')
|
||||
try:
|
||||
result = self.call(
|
||||
'Invoice',
|
||||
'readInvoices',
|
||||
numDossier=family_id,
|
||||
codeRegie=regie_id,
|
||||
dateStart='1970-01-01',
|
||||
dateEnd=now().strftime(utils.json_date_format),
|
||||
)
|
||||
except RequestException:
|
||||
pass
|
||||
else:
|
||||
last_update = now()
|
||||
for item in result:
|
||||
self.invoice_set.update_or_create(
|
||||
resource_id=self.id,
|
||||
regie_id=regie_id,
|
||||
family_id=family_id,
|
||||
invoice_id=item['numInvoice'],
|
||||
defaults={
|
||||
'maelis_data': item,
|
||||
'updated': last_update,
|
||||
},
|
||||
)
|
||||
|
||||
invoices = []
|
||||
for item in self.invoice_set.filter(regie_id=regie_id, family_id=family_id):
|
||||
item = item.maelis_data
|
||||
invoice = {
|
||||
'id': '%s-%s' % (item['numFamily'], item['numInvoice']),
|
||||
'created': item['dateInvoice'][:10],
|
||||
'pay_limit_date': item['dateDeadline'][:10],
|
||||
'display_id': str(item['numInvoice']),
|
||||
'total_amount': item['amountInvoice'],
|
||||
'amount': str(float(item['amountInvoice']) - float(item['amountPaid'])),
|
||||
'amount_paid': item['amountPaid'],
|
||||
'label': item['libelleTTF'],
|
||||
'has_pdf': bool(item['pdfName']),
|
||||
'online_payment': True,
|
||||
'paid': item['amountInvoice'] == item['amountPaid'],
|
||||
'payment_date': None,
|
||||
'no_online_payment_reason': None,
|
||||
'reference_id': item['numInvoice'],
|
||||
'maelis_item': item,
|
||||
}
|
||||
if item['amountInvoice'] == item['amountPaid']:
|
||||
invoice.update({'amount': '0', 'pay_limit_date': '', 'online_payment': False})
|
||||
invoices.append(invoice)
|
||||
return invoices
|
||||
|
||||
@endpoint(
|
||||
display_category='Facture',
|
||||
name='regie',
|
||||
perm='can_access',
|
||||
pattern=r'^(?P<regie_id>[\w-]+)/invoices/?$',
|
||||
example_pattern='{regie_id}/invoices',
|
||||
description='Obtenir les factures à payer',
|
||||
parameters={
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'family_id': {'description': 'Numéro de DUI'},
|
||||
'regie_id': {'description': 'Identifiant de la régie', 'example_value': '102'},
|
||||
},
|
||||
)
|
||||
def invoices(self, request, regie_id, NameID=None, family_id=None):
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
invoices = [i for i in self.get_invoices(family_id, regie_id) if not i['paid']]
|
||||
return {'data': invoices}
|
||||
|
||||
@endpoint(
|
||||
display_category='Facture',
|
||||
name='regie',
|
||||
perm='can_access',
|
||||
pattern=r'^(?P<regie_id>\w+)/invoices/history/?$',
|
||||
example_pattern='{regie_id}/invoices/history',
|
||||
description='Obtenir les factures déjà payées',
|
||||
parameters={
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'family_id': {'description': 'Numéro de DUI'},
|
||||
'regie_id': {'description': 'Identifiant de la régie', 'example_value': '102'},
|
||||
},
|
||||
)
|
||||
def invoices_history(self, request, regie_id, NameID=None, family_id=None):
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
invoices = [i for i in self.get_invoices(family_id, regie_id) if i['paid']]
|
||||
return {'data': invoices}
|
||||
|
||||
def get_invoice(self, regie_id, invoice_id):
|
||||
real_invoice_id = invoice_id.split('-')[-1]
|
||||
family_id = invoice_id[: -(len(real_invoice_id) + 1)]
|
||||
for invoice in self.get_invoices(family_id, regie_id):
|
||||
if invoice['id'] == invoice_id:
|
||||
break
|
||||
else:
|
||||
raise APIError('Invoice not found')
|
||||
return invoice
|
||||
|
||||
@endpoint(
|
||||
display_category='Facture',
|
||||
name='regie',
|
||||
perm='can_access',
|
||||
pattern=r'^(?P<regie_id>\w+)/invoice/(?P<invoice_id>\d+-\d+)/?$',
|
||||
example_pattern='{regie_id}/invoice/{invoice_id}',
|
||||
description='Obtenir les détails d’une facture',
|
||||
parameters={
|
||||
'regie_id': {'description': 'Identifiant de la régie', 'example_value': '102'},
|
||||
'invoice_id': {'description': 'Identifiant de facture', 'example_value': 'IDFAM-42'},
|
||||
},
|
||||
)
|
||||
def invoice(self, request, regie_id, invoice_id, **kwargs):
|
||||
return {'data': self.get_invoice(regie_id, invoice_id)}
|
||||
|
||||
@endpoint(
|
||||
display_category='Facture',
|
||||
name='regie',
|
||||
perm='can_access',
|
||||
pattern=r'^(?P<regie_id>\w+)/invoice/(?P<invoice_id>\d+-\d+)/pay/?$',
|
||||
example_pattern='{regie_id}/invoice/{invoice_id}/pay',
|
||||
description='Notifier le paiement de la facture',
|
||||
parameters={
|
||||
'regie_id': {'description': 'Identifiant de la régie', 'example_value': '102'},
|
||||
'invoice_id': {'description': 'Identifiant de facture', 'example_value': 'IDFAM-42'},
|
||||
},
|
||||
post={
|
||||
'request_body': {
|
||||
'schema': {
|
||||
'application/json': invoice_schemas.PAYMENT_SCHEMA,
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
def pay_invoice(self, request, regie_id, invoice_id, post_data, **kwargs):
|
||||
invoice = self.get_invoice(regie_id, invoice_id)
|
||||
|
||||
self.call(
|
||||
'Invoice',
|
||||
'payInvoices',
|
||||
numDossier=invoice['maelis_item']['numFamily'],
|
||||
codeRegie=regie_id,
|
||||
amount=invoice['amount'],
|
||||
datePaiement=post_data['transaction_date'],
|
||||
refTransaction=post_data['transaction_id'],
|
||||
numInvoices=[invoice['display_id']],
|
||||
numPerson=invoice['maelis_item']['payer']['num'],
|
||||
)
|
||||
return {'data': True}
|
||||
|
||||
@endpoint(
|
||||
display_category='Facture',
|
||||
name='regie',
|
||||
perm='can_access',
|
||||
pattern=r'^(?P<regie_id>\w+)/invoice/(?P<invoice_id>\d+-\d+)/pdf/?$',
|
||||
example_pattern='{regie_id}/invoice/{invoice_id}/pdf',
|
||||
description='Obtenir une facture au format PDF',
|
||||
parameters={
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'family_id': {'description': 'Numéro de DUI'},
|
||||
'regie_id': {'description': 'Identifiant de la régie', 'example_value': '102'},
|
||||
'invoice_id': {'description': 'Identifiant de facture', 'example_value': 'IDFAM-42'},
|
||||
},
|
||||
)
|
||||
def invoice_pdf(self, request, regie_id, invoice_id, NameID=None, family_id=None):
|
||||
try:
|
||||
self.assert_key_in_referential('Regie', regie_id, 'regie_id parameter')
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
except APIError:
|
||||
raise Http404('Fichier PDF non trouvé')
|
||||
|
||||
real_invoice_id = invoice_id.split('-')[-1]
|
||||
if invoice_id[: -(len(real_invoice_id) + 1)] != family_id:
|
||||
raise Http404('Fichier PDF non trouvé')
|
||||
|
||||
try:
|
||||
result = self.call(
|
||||
'Invoice',
|
||||
'getInvoicePDF',
|
||||
getInvoicePDFRequestBean={
|
||||
'codeRegie': regie_id,
|
||||
'numInvoice': real_invoice_id,
|
||||
},
|
||||
)
|
||||
except SOAPError:
|
||||
raise Http404('Fichier PDF non trouvé')
|
||||
|
||||
response = HttpResponse(content_type='application/pdf')
|
||||
response['Content-Disposition'] = 'attachment; filename=%s.pdf' % invoice_id
|
||||
response.write(result)
|
||||
return response
|
||||
|
||||
|
||||
class Link(models.Model):
|
||||
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)
|
||||
|
@ -3780,3 +3977,25 @@ class Referential(models.Model):
|
|||
class Meta:
|
||||
ordering = ('resource', 'referential_name', 'item_text', 'item_id')
|
||||
unique_together = [['resource', 'referential_name', 'item_id']]
|
||||
|
||||
|
||||
class Invoice(models.Model):
|
||||
'''Family invoices list by regie'''
|
||||
|
||||
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)
|
||||
regie_id = models.CharField(blank=False, max_length=128)
|
||||
family_id = models.CharField(blank=False, max_length=128)
|
||||
invoice_id = models.CharField(blank=False, max_length=128)
|
||||
maelis_data = JSONField('Data', encoder=DjangoJSONEncoder)
|
||||
lingo_data = JSONField('Data', encoder=DjangoJSONEncoder, null=True)
|
||||
created = models.DateTimeField('Created', auto_now_add=True)
|
||||
updated = models.DateTimeField('Updated', auto_now=True)
|
||||
canceled = models.DateTimeField('Canceled', null=True)
|
||||
notified = models.DateTimeField('Notified', null=True)
|
||||
|
||||
def __repr__(self):
|
||||
return '<Invoice "%s/%s">' % (self.regie_id, self.invoice_id)
|
||||
|
||||
class Meta:
|
||||
ordering = ('resource', 'regie_id', 'invoice_id')
|
||||
unique_together = [['resource', 'invoice_id']]
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<xs:element name="addDirectDebitOrderResponse" type="tns:addDirectDebitOrderResponse"/>
|
||||
<xs:element name="getDirectDebitOrder" type="tns:getDirectDebitOrder"/>
|
||||
<xs:element name="getDirectDebitOrderResponse" type="tns:getDirectDebitOrderResponse"/>
|
||||
<xs:element name="getInvoiceAndPDF" type="tns:getInvoiceAndPDF"/>
|
||||
<xs:element name="getInvoiceAndPDFResponse" type="tns:getInvoiceAndPDFResponse"/>
|
||||
<xs:element name="getInvoicePDF" type="tns:getInvoicePDF"/>
|
||||
<xs:element name="getInvoicePDFResponse" type="tns:getInvoicePDFResponse"/>
|
||||
<xs:element name="isWSRunning" type="tns:isWSRunning"/>
|
||||
|
@ -131,6 +133,16 @@
|
|||
<xs:element maxOccurs="unbounded" minOccurs="0" name="getRegieList" type="ns1:regieBean"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="getInvoiceAndPDF">
|
||||
<xs:sequence>
|
||||
<xs:element name="getInvoiceRequestBean" type="ns1:getInvoiceRequestBean"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="getInvoiceAndPDFResponse">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" name="getInvoiceResponseBean" type="ns1:getInvoiceResponseBean"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:element name="MaelisAccountException" type="tns:MaelisAccountException"/>
|
||||
<xs:complexType name="MaelisAccountException">
|
||||
<xs:sequence>
|
||||
|
@ -245,6 +257,27 @@
|
|||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="getInvoiceRequestBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecRequestBean">
|
||||
<xs:sequence>
|
||||
<xs:element name="idInvoice" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="getInvoiceResponseBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecResultBean">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" name="invoicePdfFile" type="xs:base64Binary"/>
|
||||
<xs:element minOccurs="0" name="invoice" type="tns:invoiceBean"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
</xs:schema>
|
||||
</wsdl:types>
|
||||
<wsdl:message name="getDirectDebitOrder">
|
||||
|
@ -275,6 +308,10 @@
|
|||
<wsdl:part element="tns:getInvoicePDFResponse" name="parameters">
|
||||
</wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getInvoiceAndPDFResponse">
|
||||
<wsdl:part element="tns:getInvoiceAndPDFResponse" name="parameters">
|
||||
</wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="isWSRunningResponse">
|
||||
<wsdl:part element="tns:isWSRunningResponse" name="parameters">
|
||||
</wsdl:part>
|
||||
|
@ -307,6 +344,10 @@
|
|||
<wsdl:part element="tns:addDirectDebitOrderResponse" name="parameters">
|
||||
</wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getInvoiceAndPDF">
|
||||
<wsdl:part element="tns:getInvoiceAndPDF" name="parameters">
|
||||
</wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:portType name="InvoiceService">
|
||||
<wsdl:documentation>Attention : Il est nécessaire de paramétrer un code pour la régie qui doit être passé en paramètre lors de l'invocation de la méthode.</wsdl:documentation>
|
||||
<wsdl:operation name="payInvoices">
|
||||
|
@ -331,7 +372,7 @@
|
|||
Retourne le numéro du règlement
|
||||
|
||||
-----------------------------------
|
||||
Attention : Le numéro ou le nom/prénom de la personne doivent être fournis. Le montant du règlement doit être égale au solde des factures (pas de règlement partiel)</wsdl:documentation>
|
||||
Attention : Le numéro ou le nom/prénom de la personne doivent être fournis</wsdl:documentation>
|
||||
<wsdl:input message="tns:payInvoices" name="payInvoices">
|
||||
</wsdl:input>
|
||||
<wsdl:output message="tns:payInvoicesResponse" name="payInvoicesResponse">
|
||||
|
@ -433,6 +474,18 @@
|
|||
<wsdl:fault message="tns:MaelisAccountException" name="MaelisAccountException">
|
||||
</wsdl:fault>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getInvoiceAndPDF">
|
||||
<wsdl:documentation>Renvoie la facture indiquée avec son fichier PDF
|
||||
|
||||
-----------------------------------
|
||||
idInvoice : identifiant de la facture</wsdl:documentation>
|
||||
<wsdl:input message="tns:getInvoiceAndPDF" name="getInvoiceAndPDF">
|
||||
</wsdl:input>
|
||||
<wsdl:output message="tns:getInvoiceAndPDFResponse" name="getInvoiceAndPDFResponse">
|
||||
</wsdl:output>
|
||||
<wsdl:fault message="tns:MaelisAccountException" name="MaelisAccountException">
|
||||
</wsdl:fault>
|
||||
</wsdl:operation>
|
||||
</wsdl:portType>
|
||||
<wsdl:binding name="InvoiceServiceSoapBinding" type="tns:InvoiceService">
|
||||
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
|
@ -520,10 +573,22 @@
|
|||
<soap:fault name="MaelisAccountException" use="literal"/>
|
||||
</wsdl:fault>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getInvoiceAndPDF">
|
||||
<soap:operation soapAction="" style="document"/>
|
||||
<wsdl:input name="getInvoiceAndPDF">
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output name="getInvoiceAndPDFResponse">
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
<wsdl:fault name="MaelisAccountException">
|
||||
<soap:fault name="MaelisAccountException" use="literal"/>
|
||||
</wsdl:fault>
|
||||
</wsdl:operation>
|
||||
</wsdl:binding>
|
||||
<wsdl:service name="InvoiceService">
|
||||
<wsdl:port binding="tns:InvoiceServiceSoapBinding" name="InvoiceServiceImplPort">
|
||||
<soap:address location="https://demo-toulouse.sigec.fr/maelisws-toulouse-recette/services/InvoiceService"/>
|
||||
</wsdl:port>
|
||||
</wsdl:service>
|
||||
</wsdl:definitions>
|
||||
</wsdl:definitions>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,13 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<soap:Fault>
|
||||
<faultcode>soap:Server</faultcode>
|
||||
<faultstring>E535 : Fichier PDF de la facture inconnu (facture non encore générée ?)</faultstring>
|
||||
<detail>
|
||||
<ns1:MaelisAccountException xmlns:ns1="ws.maelis.sigec.com">
|
||||
<message xmlns:ns2="ws.maelis.sigec.com">E535 : Fichier PDF de la facture inconnu (facture non encore générée ?)</message>
|
||||
</ns1:MaelisAccountException>
|
||||
</detail>
|
||||
</soap:Fault>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,7 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:payInvoicesResponse xmlns:ns2="ws.maelis.sigec.com">
|
||||
<numReglement>4</numReglement>
|
||||
</ns2:payInvoicesResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,219 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:readInvoicesResponse xmlns:ns2="ws.maelis.sigec.com">
|
||||
<invoiceList>
|
||||
<numInvoice>8</numInvoice>
|
||||
<idInvoice>F10055591232</idInvoice>
|
||||
<libelleTTF>CLAE JANVIER 2023</libelleTTF>
|
||||
<regie>
|
||||
<code>102</code>
|
||||
<libelle>CANTINE / CLAE</libelle>
|
||||
</regie>
|
||||
<numFamily>322411</numFamily>
|
||||
<name>SIMPSON MARGE</name>
|
||||
<amountInvoice>952503.6</amountInvoice>
|
||||
<amountPaid>952503.6</amountPaid>
|
||||
<amountPaidTG>0</amountPaidTG>
|
||||
<dateInvoice>2023-02-24T00:00:00+01:00</dateInvoice>
|
||||
<dateDeadline>2023-03-24T00:00:00+01:00</dateDeadline>
|
||||
<payer>
|
||||
<num>261483</num>
|
||||
<lastname>SIMPSON</lastname>
|
||||
<firstname>MARGE</firstname>
|
||||
<civility>MME</civility>
|
||||
</payer>
|
||||
<lineInvoiceList>
|
||||
<numLine>1</numLine>
|
||||
<numPers>261485</numPers>
|
||||
<idActivity>A10049327692</idActivity>
|
||||
<idUnit>A10049327693</idUnit>
|
||||
<libelleLine>Calendrier CLAE SOIR 22/23</libelleLine>
|
||||
<name>SIMPSON BART</name>
|
||||
<dateStart>2023-01-02T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-02-28T00:00:00+01:00</dateEnd>
|
||||
<quantity>11.0</quantity>
|
||||
<unitPrice>22500.0</unitPrice>
|
||||
<amountLine>247500</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>2</numLine>
|
||||
<numPers>261488</numPers>
|
||||
<idActivity>A10049327692</idActivity>
|
||||
<idUnit>A10049327693</idUnit>
|
||||
<libelleLine>Calendrier CLAE SOIR 22/23</libelleLine>
|
||||
<name>SIMPSON LISA</name>
|
||||
<dateStart>2023-01-02T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-02-28T00:00:00+01:00</dateEnd>
|
||||
<quantity>6.0</quantity>
|
||||
<unitPrice>22500.0</unitPrice>
|
||||
<amountLine>135000</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>3</numLine>
|
||||
<numPers>261485</numPers>
|
||||
<idActivity>A10049327689</idActivity>
|
||||
<idUnit>A10049327690</idUnit>
|
||||
<libelleLine>Calendrier CLAE MATIN 22/23</libelleLine>
|
||||
<name>SIMPSON BART</name>
|
||||
<dateStart>2023-01-02T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-02-28T00:00:00+01:00</dateEnd>
|
||||
<quantity>6.0</quantity>
|
||||
<unitPrice>30000.0</unitPrice>
|
||||
<amountLine>180000</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>4</numLine>
|
||||
<numPers>261489</numPers>
|
||||
<idActivity>A10049327689</idActivity>
|
||||
<idUnit>A10049327690</idUnit>
|
||||
<libelleLine>Calendrier CLAE MATIN 22/23</libelleLine>
|
||||
<name>SIMPSON MAGGIE</name>
|
||||
<dateStart>2023-01-02T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-02-28T00:00:00+01:00</dateEnd>
|
||||
<quantity>8.0</quantity>
|
||||
<unitPrice>30000.0</unitPrice>
|
||||
<amountLine>240000</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>5</numLine>
|
||||
<numPers>261490</numPers>
|
||||
<idActivity>A10049327689</idActivity>
|
||||
<idUnit>A10049327690</idUnit>
|
||||
<libelleLine>Calendrier CLAE MATIN 22/23</libelleLine>
|
||||
<name>SIMPSON HUGO</name>
|
||||
<dateStart>2023-01-02T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-02-28T00:00:00+01:00</dateEnd>
|
||||
<quantity>5.0</quantity>
|
||||
<unitPrice>30000.0</unitPrice>
|
||||
<amountLine>150000</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>6</numLine>
|
||||
<numPers>261485</numPers>
|
||||
<idActivity>A10049327686</idActivity>
|
||||
<idUnit>A10049327687</idUnit>
|
||||
<libelleLine>Calendrier CLAE MIDI 22/23</libelleLine>
|
||||
<name>SIMPSON BART</name>
|
||||
<dateStart>2023-01-02T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-02-28T00:00:00+01:00</dateEnd>
|
||||
<quantity>6.0</quantity>
|
||||
<unitPrice>0.6</unitPrice>
|
||||
<amountLine>3.6</amountLine>
|
||||
</lineInvoiceList>
|
||||
</invoiceList>
|
||||
<invoiceList>
|
||||
<numInvoice>30</numInvoice>
|
||||
<idInvoice>F10055591806</idInvoice>
|
||||
<libelleTTF>TEST EO</libelleTTF>
|
||||
<regie>
|
||||
<code>102</code>
|
||||
<libelle>CANTINE / CLAE</libelle>
|
||||
</regie>
|
||||
<numFamily>322411</numFamily>
|
||||
<name>SIMPSON MARGE</name>
|
||||
<amountInvoice>162.3</amountInvoice>
|
||||
<amountPaid>0</amountPaid>
|
||||
<amountPaidTG>0</amountPaidTG>
|
||||
<dateInvoice>2023-03-01T00:00:00+01:00</dateInvoice>
|
||||
<dateDeadline>2023-04-30T00:00:00+02:00</dateDeadline>
|
||||
<payer>
|
||||
<num>261483</num>
|
||||
<lastname>SIMPSON</lastname>
|
||||
<firstname>MARGE</firstname>
|
||||
<civility>MME</civility>
|
||||
</payer>
|
||||
<lineInvoiceList>
|
||||
<numLine>1</numLine>
|
||||
<numPers>261488</numPers>
|
||||
<idActivity>A10049327692</idActivity>
|
||||
<idUnit>A10049327693</idUnit>
|
||||
<libelleLine>Calendrier CLAE SOIR 22/23</libelleLine>
|
||||
<name>SIMPSON LISA</name>
|
||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-03-31T00:00:00+02:00</dateEnd>
|
||||
<quantity>8.0</quantity>
|
||||
<unitPrice>2.25</unitPrice>
|
||||
<amountLine>18</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>2</numLine>
|
||||
<numPers>261485</numPers>
|
||||
<idActivity>A10049327682</idActivity>
|
||||
<idUnit>A10049327683</idUnit>
|
||||
<libelleLine>Calendrier RESTAURATION SCOLAIRE 22/23</libelleLine>
|
||||
<name>SIMPSON BART</name>
|
||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-03-31T00:00:00+02:00</dateEnd>
|
||||
<quantity>18.0</quantity>
|
||||
<unitPrice>0.0</unitPrice>
|
||||
<amountLine>0</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>3</numLine>
|
||||
<numPers>261485</numPers>
|
||||
<idActivity>A10049327692</idActivity>
|
||||
<idUnit>A10049327693</idUnit>
|
||||
<libelleLine>Calendrier CLAE SOIR 22/23</libelleLine>
|
||||
<name>SIMPSON BART</name>
|
||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-03-31T00:00:00+02:00</dateEnd>
|
||||
<quantity>18.0</quantity>
|
||||
<unitPrice>2.25</unitPrice>
|
||||
<amountLine>40.5</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>4</numLine>
|
||||
<numPers>261485</numPers>
|
||||
<idActivity>A10049327689</idActivity>
|
||||
<idUnit>A10049327690</idUnit>
|
||||
<libelleLine>Calendrier CLAE MATIN 22/23</libelleLine>
|
||||
<name>SIMPSON BART</name>
|
||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-03-31T00:00:00+02:00</dateEnd>
|
||||
<quantity>10.0</quantity>
|
||||
<unitPrice>3.0</unitPrice>
|
||||
<amountLine>30</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>5</numLine>
|
||||
<numPers>261489</numPers>
|
||||
<idActivity>A10049327689</idActivity>
|
||||
<idUnit>A10049327690</idUnit>
|
||||
<libelleLine>Calendrier CLAE MATIN 22/23</libelleLine>
|
||||
<name>SIMPSON MAGGIE</name>
|
||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-03-31T00:00:00+02:00</dateEnd>
|
||||
<quantity>13.0</quantity>
|
||||
<unitPrice>3.0</unitPrice>
|
||||
<amountLine>39</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>6</numLine>
|
||||
<numPers>261490</numPers>
|
||||
<idActivity>A10049327689</idActivity>
|
||||
<idUnit>A10049327690</idUnit>
|
||||
<libelleLine>Calendrier CLAE MATIN 22/23</libelleLine>
|
||||
<name>SIMPSON HUGO</name>
|
||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-03-31T00:00:00+02:00</dateEnd>
|
||||
<quantity>10.0</quantity>
|
||||
<unitPrice>3.0</unitPrice>
|
||||
<amountLine>30</amountLine>
|
||||
</lineInvoiceList>
|
||||
<lineInvoiceList>
|
||||
<numLine>7</numLine>
|
||||
<numPers>261485</numPers>
|
||||
<idActivity>A10049327686</idActivity>
|
||||
<idUnit>A10049327687</idUnit>
|
||||
<libelleLine>Calendrier CLAE MIDI 22/23</libelleLine>
|
||||
<name>SIMPSON BART</name>
|
||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||
<dateEnd>2023-03-31T00:00:00+02:00</dateEnd>
|
||||
<quantity>8.0</quantity>
|
||||
<unitPrice>0.6</unitPrice>
|
||||
<amountLine>4.8</amountLine>
|
||||
</lineInvoiceList>
|
||||
</invoiceList>
|
||||
</ns2:readInvoicesResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,5 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:readInvoicesResponse xmlns:ns2="ws.maelis.sigec.com"/>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -528,6 +528,9 @@ def test_link(family_service, con, app):
|
|||
url = get_endpoint('link')
|
||||
assert Link.objects.count() == 0
|
||||
|
||||
# skip caching invoice
|
||||
con.referential.filter(referential_name='Regie').delete()
|
||||
|
||||
params = {
|
||||
'family_id': '1312',
|
||||
'firstname': 'Jhon',
|
||||
|
@ -546,6 +549,34 @@ def test_link(family_service, con, app):
|
|||
assert resp.json['err_desc'] == "RL1 does not match '1312' family"
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_link_caching_invoices(mocked_post, mocked_get, con, app):
|
||||
mocked_get.side_effect = [FAMILY_SERVICE_WSDL, INVOICE_SERVICE_WSDL]
|
||||
mocked_post.side_effect = [
|
||||
FakedResponse(content=get_xml_file('R_read_family.xml'), status_code=200),
|
||||
FakedResponse(content=get_xml_file('R_read_invoices.xml'), status_code=200),
|
||||
] + [
|
||||
FakedResponse(content=get_xml_file('R_read_invoices_empty.xml'), status_code=200),
|
||||
] * 8
|
||||
url = get_endpoint('link')
|
||||
|
||||
assert con.invoice_set.count() == 0
|
||||
assert Link.objects.count() == 0
|
||||
params = {
|
||||
'family_id': '1312',
|
||||
'firstname': 'Jhon',
|
||||
'lastname': 'Doe',
|
||||
'dateBirth': '1938-07-26',
|
||||
}
|
||||
resp = app.post_json(url + '?NameID=local', params=params)
|
||||
assert len(mocked_post.mock_calls) == 10
|
||||
assert Link.objects.count() == 1
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == 'ok'
|
||||
assert con.invoice_set.count() == 2
|
||||
|
||||
|
||||
def test_link_additional_properties_error(con, app):
|
||||
url = get_endpoint('link')
|
||||
params = {
|
||||
|
@ -8630,3 +8661,282 @@ def test_create_nursery_demand_wrong_referential_key_error(con, app):
|
|||
resp.json['err_desc']
|
||||
== "family_indicators/0/code key value 'APE_ALLO' do not belong to APE 'FAM' indicators"
|
||||
)
|
||||
|
||||
|
||||
def test_invoices(invoice_service, con, app):
|
||||
def request_check(request):
|
||||
assert request.numDossier == 1312
|
||||
assert request.codeRegie == 104
|
||||
assert request.dateStart == datetime.datetime(1970, 1, 1, 0, 0)
|
||||
|
||||
invoice_service.add_soap_response(
|
||||
'readInvoices', get_xml_file('R_read_invoices.xml'), request_check=request_check
|
||||
)
|
||||
url = get_endpoint('regie/104/invoices')
|
||||
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 0
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
|
||||
resp = app.get(url + '?NameID=local')
|
||||
assert resp.json['err'] == 0
|
||||
assert len(resp.json['data'])
|
||||
for invoice in resp.json['data']:
|
||||
assert invoice['display_id']
|
||||
assert invoice['label']
|
||||
assert invoice['total_amount']
|
||||
assert not invoice['paid']
|
||||
data = resp.json['data'][0]
|
||||
del data['maelis_item']
|
||||
assert data == {
|
||||
'id': '322411-30',
|
||||
'created': '2023-03-01',
|
||||
'pay_limit_date': '2023-04-30',
|
||||
'display_id': '30',
|
||||
'total_amount': '162.3',
|
||||
'amount': '162.3',
|
||||
'amount_paid': '0',
|
||||
'label': 'TEST EO',
|
||||
'has_pdf': False,
|
||||
'online_payment': True,
|
||||
'paid': False,
|
||||
'payment_date': None,
|
||||
'no_online_payment_reason': None,
|
||||
'reference_id': '30',
|
||||
}
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
def test_invoices_cache(mocked_get, con, app):
|
||||
mocked_get.return_value = INVOICE_SERVICE_WSDL
|
||||
url = get_endpoint('regie/104/invoices')
|
||||
|
||||
with mock.patch('passerelle.utils.Request.post') as mocked_post:
|
||||
mocked_post.side_effect = ReadTimeout('timeout')
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == []
|
||||
|
||||
with mock.patch('passerelle.utils.Request.post') as mocked_post:
|
||||
mocked_post.return_value = FakedResponse(content=get_xml_file('R_read_invoices.xml'), status_code=200)
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 0
|
||||
assert len(resp.json['data'])
|
||||
for invoice in resp.json['data']:
|
||||
assert invoice['display_id']
|
||||
assert invoice['label']
|
||||
assert invoice['total_amount']
|
||||
assert not invoice['paid']
|
||||
|
||||
with mock.patch('passerelle.utils.Request.post') as mocked_post:
|
||||
mocked_post.side_effect = ReadTimeout('timeout')
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 0
|
||||
assert len(resp.json['data'])
|
||||
|
||||
|
||||
def test_invoices_not_linked_error(con, app):
|
||||
url = get_endpoint('regie/104/invoices')
|
||||
resp = app.get(url + '?NameID=local')
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
def test_invoices_wrong_referential_key_error(con, app):
|
||||
url = get_endpoint('regie/plop/invoices')
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 1
|
||||
assert (
|
||||
resp.json['err_desc']
|
||||
== "regie_id parameter key value 'plop' do not belong to 'Regie' required referential"
|
||||
)
|
||||
|
||||
|
||||
def test_invoices_history(invoice_service, con, app):
|
||||
def request_check(request):
|
||||
assert request.numDossier == 1312
|
||||
assert request.codeRegie == 104
|
||||
assert request.dateStart == datetime.datetime(1970, 1, 1, 0, 0)
|
||||
|
||||
invoice_service.add_soap_response(
|
||||
'readInvoices', get_xml_file('R_read_invoices.xml'), request_check=request_check
|
||||
)
|
||||
url = get_endpoint('regie/104/invoices/history')
|
||||
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 0
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
|
||||
resp = app.get(url + '?NameID=local')
|
||||
assert resp.json['err'] == 0
|
||||
for invoice in resp.json['data']:
|
||||
assert invoice['display_id']
|
||||
assert invoice['label']
|
||||
assert invoice['total_amount']
|
||||
assert invoice['paid']
|
||||
data = resp.json['data'][0]
|
||||
del data['maelis_item']
|
||||
assert data == {
|
||||
'id': '322411-8',
|
||||
'created': '2023-02-24',
|
||||
'pay_limit_date': '',
|
||||
'display_id': '8',
|
||||
'total_amount': '952503.6',
|
||||
'amount': '0',
|
||||
'amount_paid': '952503.6',
|
||||
'label': 'CLAE JANVIER 2023',
|
||||
'has_pdf': False,
|
||||
'online_payment': False,
|
||||
'paid': True,
|
||||
'payment_date': None,
|
||||
'no_online_payment_reason': None,
|
||||
'reference_id': '8',
|
||||
}
|
||||
|
||||
|
||||
def test_invoices_history_not_linked_error(con, app):
|
||||
url = get_endpoint('regie/104/invoices/history')
|
||||
resp = app.get(url + '?NameID=local')
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
def test_invoices_history_wrong_referential_key_error(con, app):
|
||||
url = get_endpoint('regie/plop/invoices/history')
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 1
|
||||
assert (
|
||||
resp.json['err_desc']
|
||||
== "regie_id parameter key value 'plop' do not belong to 'Regie' required referential"
|
||||
)
|
||||
|
||||
|
||||
def test_invoice(invoice_service, con, app):
|
||||
def request_check(request):
|
||||
assert request.numDossier == 322411
|
||||
assert request.codeRegie == 104
|
||||
assert request.dateStart == datetime.datetime(1970, 1, 1, 0, 0)
|
||||
|
||||
invoice_service.add_soap_response(
|
||||
'readInvoices', get_xml_file('R_read_invoices.xml'), request_check=request_check
|
||||
)
|
||||
url = get_endpoint('regie/104/invoice/322411-8')
|
||||
|
||||
resp = app.get(url + '?NameID=ignored')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data']['display_id'] == '8'
|
||||
assert resp.json['data']['label'] == 'CLAE JANVIER 2023'
|
||||
|
||||
|
||||
def test_invoice_wrong_referential_key_error(con, app):
|
||||
url = get_endpoint('regie/plop/invoice/322411-8')
|
||||
resp = app.get(url)
|
||||
assert resp.json['err'] == 1
|
||||
assert (
|
||||
resp.json['err_desc']
|
||||
== "regie_id parameter key value 'plop' do not belong to 'Regie' required referential"
|
||||
)
|
||||
|
||||
|
||||
def test_invoice_not_found_invoice(invoice_service, con, app):
|
||||
invoice_service.add_soap_response('readInvoices', get_xml_file('R_read_invoices.xml'))
|
||||
url = get_endpoint('regie/104/invoice/1-2')
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'Invoice not found'
|
||||
|
||||
|
||||
def test_pay_invoice(invoice_service, con, app):
|
||||
def request_check(request):
|
||||
assert dict(serialize_object(request)) == {
|
||||
'numDossier': 322411,
|
||||
'numPerson': 261483,
|
||||
'lastName': None,
|
||||
'firstName': None,
|
||||
'codeRegie': 104,
|
||||
'amount': 0.0,
|
||||
'datePaiement': datetime.datetime(2023, 3, 3, 18, 38),
|
||||
'refTransaction': 'xxx',
|
||||
'numInvoices': [8],
|
||||
}
|
||||
|
||||
invoice_service.add_soap_response('readInvoices', get_xml_file('R_read_invoices.xml'))
|
||||
invoice_service.add_soap_response(
|
||||
'payInvoices', get_xml_file('R_pay_invoices.xml'), request_check=request_check
|
||||
)
|
||||
url = get_endpoint('regie/104/invoice/322411-8/pay/')
|
||||
data = {
|
||||
'transaction_date': '2023-03-03T18:38:00',
|
||||
'transaction_id': 'xxx',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=ignored', params=data)
|
||||
assert resp.json['err'] == 0
|
||||
|
||||
|
||||
def test_pay_invoice_wrong_referential_key_error(con, app):
|
||||
url = get_endpoint('regie/plop/invoice/322411-8/pay/')
|
||||
data = {
|
||||
'transaction_date': '2023-03-03T18:38:00',
|
||||
'transaction_id': 'xxx',
|
||||
}
|
||||
resp = app.post_json(url, params=data)
|
||||
assert resp.json['err'] == 1
|
||||
assert (
|
||||
resp.json['err_desc']
|
||||
== "regie_id parameter key value 'plop' do not belong to 'Regie' required referential"
|
||||
)
|
||||
|
||||
|
||||
def test_invoice_pdf(invoice_service, con, app):
|
||||
def request_check(request):
|
||||
assert request.codeRegie == 104
|
||||
assert request.numInvoice == 8
|
||||
|
||||
invoice_service.add_soap_response(
|
||||
'getInvoicePDF', get_xml_file('R_get_invoice_pdf.xml'), request_check=request_check
|
||||
)
|
||||
url = get_endpoint('regie/104/invoice/1312-8/pdf')
|
||||
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
|
||||
resp = app.get(url + '?NameID=local')
|
||||
assert 'Content-Type' in resp.headers
|
||||
assert 'Content-Disposition' in resp.headers
|
||||
assert resp.headers['Content-Type'] == 'application/pdf'
|
||||
assert resp.headers['Content-Disposition'] == 'attachment; filename=1312-8.pdf'
|
||||
assert resp.body[:5] == b'%PDF-'
|
||||
|
||||
|
||||
def test_invoice_pdf_not_linked_error(con, app):
|
||||
url = get_endpoint('regie/104/invoice/1312-8/pdf')
|
||||
resp = app.get(url, status=404)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_class'] == 'django.http.response.Http404'
|
||||
assert resp.json['err_desc'] == 'Fichier PDF non trouvé'
|
||||
|
||||
|
||||
def test_invoice_pdf_wrong_referential_key_error(con, app):
|
||||
url = get_endpoint('regie/plop/invoice/1312-8/pdf')
|
||||
resp = app.get(url + '?family_id=1312', status=404)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_class'] == 'django.http.response.Http404'
|
||||
assert resp.json['err_desc'] == 'Fichier PDF non trouvé'
|
||||
|
||||
|
||||
def test_invoice_pdf_wrong_family_id_error(con, app):
|
||||
url = get_endpoint('regie/104/invoice/000-8/pdf')
|
||||
resp = app.get(url + '?family_id=1312', status=404)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_class'] == 'django.http.response.Http404'
|
||||
assert resp.json['err_desc'] == 'Fichier PDF non trouvé'
|
||||
|
||||
|
||||
def test_invoice_pdf_error(invoice_service, con, app):
|
||||
invoice_service.add_soap_response('getInvoicePDF', get_xml_file('R_get_invoice_pdf_error.xml'))
|
||||
url = get_endpoint('regie/104/invoice/1312-8/pdf/')
|
||||
resp = app.get(url + '?family_id=1312', status=404)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_class'] == 'django.http.response.Http404'
|
||||
assert resp.json['err_desc'] == 'Fichier PDF non trouvé'
|
||||
|
|
Loading…
Reference in New Issue