pyslog 0.1.0.dev6__tar.gz → 0.1.0.dev8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/PKG-INFO +1 -1
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/pyproject.toml +1 -1
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/generator.py +79 -49
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/__init__.py +2 -1
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/_xml.py +8 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/invoice.py +9 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/README.md +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/__init__.py +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/__init__.py +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/__init__.py +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/business_process_type.py +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/item_identification_scheme.py +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/vat_category_code.py +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/vat_point_date_code.py +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/schemas/eSLOG20_INVOIC_v200.xsd +0 -0
- {pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/validator.py +0 -0
|
@@ -4,7 +4,10 @@ from pyslog.eslog2.models import (
|
|
|
4
4
|
)
|
|
5
5
|
from pyslog.eslog2.models._xml import *
|
|
6
6
|
|
|
7
|
-
def generate_eslog_invoice(
|
|
7
|
+
def generate_eslog_invoice(
|
|
8
|
+
invoice: Invoice,
|
|
9
|
+
pretty_print: bool = False,
|
|
10
|
+
) -> str:
|
|
8
11
|
eslog_buyer = ESLOG_G_SG2(
|
|
9
12
|
S_NAD=ESLOG_S_NAD(
|
|
10
13
|
D_3035="BY",
|
|
@@ -91,7 +94,11 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
91
94
|
)
|
|
92
95
|
),
|
|
93
96
|
],
|
|
94
|
-
G_SG5=[
|
|
97
|
+
G_SG5=[]
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
if invoice.seller.contact_person_name:
|
|
101
|
+
eslog_seller.G_SG5 = [
|
|
95
102
|
ESLOG_G_SG5(
|
|
96
103
|
S_CTA=ESLOG_S_CTA(
|
|
97
104
|
D_3139="SU",
|
|
@@ -101,7 +108,6 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
101
108
|
)
|
|
102
109
|
)
|
|
103
110
|
]
|
|
104
|
-
)
|
|
105
111
|
|
|
106
112
|
if invoice.seller.address_line_2 is not None:
|
|
107
113
|
eslog_seller.S_NAD.C_C059.D_3042_2 = invoice.seller.address_line_2
|
|
@@ -171,6 +177,7 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
171
177
|
)
|
|
172
178
|
)
|
|
173
179
|
],
|
|
180
|
+
SG8=[],
|
|
174
181
|
SG26=[],
|
|
175
182
|
UNS=ESLOG_S_UNS(
|
|
176
183
|
D_0081="D"
|
|
@@ -210,37 +217,39 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
210
217
|
),
|
|
211
218
|
|
|
212
219
|
],
|
|
213
|
-
SG52=[
|
|
214
|
-
ESLOG_G_SG52(
|
|
215
|
-
S_TAX=ESLOG_S_TAX(
|
|
216
|
-
D_5283="7",
|
|
217
|
-
C_C241=ESLOG_C_C241(
|
|
218
|
-
D_5153="VAT"
|
|
219
|
-
),
|
|
220
|
-
C_C243=ESLOG_C_C243(
|
|
221
|
-
D_5278="25" ## VAT RATE PERCENTAGE
|
|
222
|
-
),
|
|
223
|
-
D_5305="S"
|
|
224
|
-
),
|
|
225
|
-
S_MOA=[
|
|
226
|
-
ESLOG_S_MOA(
|
|
227
|
-
C_C516=ESLOG_C_C516(
|
|
228
|
-
D_5025="125",
|
|
229
|
-
D_5004="1000.00" # Taxable amount
|
|
230
|
-
)
|
|
231
|
-
),
|
|
232
|
-
ESLOG_S_MOA(
|
|
233
|
-
C_C516=ESLOG_C_C516(
|
|
234
|
-
D_5025="124",
|
|
235
|
-
D_5004="250.00" # Tax amount
|
|
236
|
-
)
|
|
237
|
-
),
|
|
238
|
-
]
|
|
239
|
-
)
|
|
240
|
-
],
|
|
220
|
+
SG52=[],
|
|
241
221
|
)
|
|
242
222
|
)
|
|
243
223
|
|
|
224
|
+
for vat_item in invoice.vat_breakdown:
|
|
225
|
+
eslog_tax = ESLOG_G_SG52(
|
|
226
|
+
S_TAX=ESLOG_S_TAX(
|
|
227
|
+
D_5283="7",
|
|
228
|
+
C_C241=ESLOG_C_C241(
|
|
229
|
+
D_5153="VAT"
|
|
230
|
+
),
|
|
231
|
+
C_C243=ESLOG_C_C243(
|
|
232
|
+
D_5278=vat_item.vat_category_rate
|
|
233
|
+
),
|
|
234
|
+
D_5305=vat_item.vat_category_code.value
|
|
235
|
+
),
|
|
236
|
+
S_MOA=[
|
|
237
|
+
ESLOG_S_MOA(
|
|
238
|
+
C_C516=ESLOG_C_C516(
|
|
239
|
+
D_5025="125",
|
|
240
|
+
D_5004=vat_item.taxable_amount
|
|
241
|
+
)
|
|
242
|
+
),
|
|
243
|
+
ESLOG_S_MOA(
|
|
244
|
+
C_C516=ESLOG_C_C516(
|
|
245
|
+
D_5025="124",
|
|
246
|
+
D_5004=vat_item.tax_amount
|
|
247
|
+
)
|
|
248
|
+
),
|
|
249
|
+
]
|
|
250
|
+
)
|
|
251
|
+
eslog_invoice.M_INVOIC.SG52.append(eslog_tax)
|
|
252
|
+
|
|
244
253
|
for index, item in enumerate(invoice.items):
|
|
245
254
|
eslog_item = ESLOG_G_SG26(
|
|
246
255
|
S_LIN=ESLOG_S_LIN(
|
|
@@ -285,14 +294,6 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
285
294
|
)
|
|
286
295
|
)
|
|
287
296
|
),
|
|
288
|
-
ESLOG_G_SG27(
|
|
289
|
-
S_MOA=ESLOG_S_MOA(
|
|
290
|
-
C_C516=ESLOG_C_C516(
|
|
291
|
-
D_5025="38",
|
|
292
|
-
D_5004=item.total_monetary_amount_including_vat,
|
|
293
|
-
)
|
|
294
|
-
)
|
|
295
|
-
),
|
|
296
297
|
],
|
|
297
298
|
G_SG29=[
|
|
298
299
|
ESLOG_G_SG29(
|
|
@@ -305,16 +306,6 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
305
306
|
)
|
|
306
307
|
)
|
|
307
308
|
),
|
|
308
|
-
ESLOG_G_SG29(
|
|
309
|
-
S_PRI=ESLOG_S_PRI(
|
|
310
|
-
C_C509=ESLOG_C_C509(
|
|
311
|
-
D_5125="AAB",
|
|
312
|
-
D_5118=item.item_gross_price,
|
|
313
|
-
D_5284=item.item_price_base_quantity,
|
|
314
|
-
D_6411=item.item_price_base_quantity_unit_of_measure_code,
|
|
315
|
-
)
|
|
316
|
-
)
|
|
317
|
-
),
|
|
318
309
|
],
|
|
319
310
|
G_SG30=[],
|
|
320
311
|
G_SG34=[
|
|
@@ -336,8 +327,46 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
336
327
|
],
|
|
337
328
|
G_SG39=[],
|
|
338
329
|
)
|
|
330
|
+
if item.total_monetary_amount_including_vat:
|
|
331
|
+
eslog_item.G_SG27.append(
|
|
332
|
+
ESLOG_G_SG27(
|
|
333
|
+
S_MOA=ESLOG_S_MOA(
|
|
334
|
+
C_C516=ESLOG_C_C516(
|
|
335
|
+
D_5025="38",
|
|
336
|
+
D_5004=item.total_monetary_amount_including_vat,
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
)
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
if item.item_gross_price:
|
|
343
|
+
eslog_item.G_SG29.append(
|
|
344
|
+
ESLOG_G_SG29(
|
|
345
|
+
S_PRI=ESLOG_S_PRI(
|
|
346
|
+
C_C509=ESLOG_C_C509(
|
|
347
|
+
D_5125="AAB",
|
|
348
|
+
D_5118=item.item_gross_price,
|
|
349
|
+
D_5284=item.item_price_base_quantity,
|
|
350
|
+
D_6411=item.item_price_base_quantity_unit_of_measure_code,
|
|
351
|
+
)
|
|
352
|
+
)
|
|
353
|
+
)
|
|
354
|
+
)
|
|
355
|
+
|
|
339
356
|
eslog_invoice.M_INVOIC.SG26.append(eslog_item)
|
|
340
357
|
|
|
358
|
+
if invoice.payment_due_date:
|
|
359
|
+
eslog_invoice.M_INVOIC.SG8.append(
|
|
360
|
+
ESLOG_G_SG8(
|
|
361
|
+
S_PAT=ESLOG_S_PAT(D_4279="1"),
|
|
362
|
+
S_DTM=[
|
|
363
|
+
ESLOG_S_DTM(
|
|
364
|
+
C_C507=ESLOG_C_C507(D_2005="13", D_2380=invoice.payment_due_date)
|
|
365
|
+
)
|
|
366
|
+
]
|
|
367
|
+
)
|
|
368
|
+
)
|
|
369
|
+
|
|
341
370
|
if invoice.value_added_tax_point_date:
|
|
342
371
|
eslog_invoice.M_INVOIC.DTM.append(
|
|
343
372
|
ESLOG_S_DTM(
|
|
@@ -490,6 +519,7 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
|
|
|
490
519
|
|
|
491
520
|
|
|
492
521
|
xml_string = eslog_invoice.to_xml(
|
|
522
|
+
pretty_print=pretty_print,
|
|
493
523
|
encoding="unicode",
|
|
494
524
|
)
|
|
495
525
|
return xml_string
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from .invoice import Invoice, Item, BusinessEntity, CEF_VAT_EXEMPTION
|
|
1
|
+
from .invoice import Invoice, Item, BusinessEntity, CEF_VAT_EXEMPTION, VATBreakdown
|
|
2
2
|
from .enums import (
|
|
3
3
|
VATPointDateCode,
|
|
4
4
|
BusinessProcessType,
|
|
@@ -15,4 +15,5 @@ __all__ = [
|
|
|
15
15
|
"BusinessProcessType",
|
|
16
16
|
"ItemIdentificationScheme",
|
|
17
17
|
"VATCategoryCode",
|
|
18
|
+
"VATBreakdown",
|
|
18
19
|
]
|
|
@@ -119,6 +119,13 @@ class ESLOG_S_CUX(BaseXmlModel, tag="S_CUX"):
|
|
|
119
119
|
class ESLOG_G_SG7(BaseXmlModel, tag="G_SG7"):
|
|
120
120
|
S_CUX: ESLOG_S_CUX = element(tag="S_CUX")
|
|
121
121
|
|
|
122
|
+
class ESLOG_S_PAT(BaseXmlModel, tag="S_PAT"):
|
|
123
|
+
D_4279: str = element(name="D_4279")
|
|
124
|
+
|
|
125
|
+
class ESLOG_G_SG8(BaseXmlModel, tag="G_SG8"):
|
|
126
|
+
S_PAT: ESLOG_S_PAT = element(tag="S_PAT")
|
|
127
|
+
S_DTM: list[ESLOG_S_DTM] = element(tag="S_DTM")
|
|
128
|
+
|
|
122
129
|
class ESLOG_C_C212(BaseXmlModel, tag="C_C212"):
|
|
123
130
|
D_7140: str = element(name="D_7140")
|
|
124
131
|
D_7143: str = element(name="D_7143")
|
|
@@ -238,6 +245,7 @@ class ESLOG_M_INVOIC(BaseXmlModel, tag="M_INVOIC"):
|
|
|
238
245
|
SG1: list[ESLOG_G_SG1] = element(tag="G_SG1")
|
|
239
246
|
SG2: list[ESLOG_G_SG2] = element(tag="G_SG2")
|
|
240
247
|
SG7: list[ESLOG_G_SG7] = element(tag="G_SG7")
|
|
248
|
+
SG8: list[ESLOG_G_SG8] = element(tag="G_SG8")
|
|
241
249
|
SG26: list[ESLOG_G_SG26] = element(tag="G_SG26")
|
|
242
250
|
UNS: ESLOG_S_UNS = element(tag="S_UNS")
|
|
243
251
|
SG50: list[ESLOG_G_SG50] = element(tag="G_SG50")
|
|
@@ -11,6 +11,13 @@ class CEF_VAT_EXEMPTION(BaseModel):
|
|
|
11
11
|
VAT_EXEMPTION_REASON_CODE: str = Field(description="VAT Exemption Reason (BT-121). Use vode list CEF VATEX — VAT exemption reason code") # TODO Add validation
|
|
12
12
|
VAT_EXEMPTION_REASON_TEXT: str = Field(description="VAT Exemption Reason (BT-120)")
|
|
13
13
|
|
|
14
|
+
|
|
15
|
+
class VATBreakdown(BaseModel):
|
|
16
|
+
taxable_amount: str = Field(description="VAT category taxable amount (BT-116). The sum of all Invoice line net amounts that are subject to a specific VAT category code and VAT category rate, minus all allowances on document level, plus all charges on document level.")
|
|
17
|
+
tax_amount: str = Field(description="VAT category tax amount (BT-117). The total VAT amount for a given VAT category.")
|
|
18
|
+
vat_category_code: VATCategoryCode = Field(description="VAT category code (BT-118). The code that applies to the VAT category.")
|
|
19
|
+
vat_category_rate: str = Field(default=None, description="VAT category rate (BT-119). The VAT rate, represented as a percentage that applies for the relevant VAT category.")
|
|
20
|
+
|
|
14
21
|
class BusinessEntity(BaseModel):
|
|
15
22
|
identifier: str | None = Field(default=None, description="Buyer identifier (BT-46)")
|
|
16
23
|
identifier_identification_scheme_identifier: str | None = Field(default="0088", description="Buyer identifier identification scheme identifier (BT-46-1). The identification scheme identifier of the Buyer identifier. Use code list ISO/IEC 6523 — Identifier scheme code") # Todo validation?
|
|
@@ -54,6 +61,7 @@ class Invoice(BaseModel):
|
|
|
54
61
|
invoice_number: str
|
|
55
62
|
invoice_issue_date: str
|
|
56
63
|
value_added_tax_point_date: str | None = Field(default=None, description="Value added tax point date (BT-7). The date when the VAT becomes accountable for the Seller and for the Buyer in so far as that date can be determined and differs from the date of issue of the invoice, according to the VAT directive.")
|
|
64
|
+
payment_due_date: str | None = Field(default=None, description="Payment due date (BT-9). The date on which the payment is due.")
|
|
57
65
|
value_added_tax_point_date_code: VATPointDateCode | None = Field(default=None, description="Value added tax point date code (BT-8), DESC:The code of the date when the VAT becomes accountable for the Seller and for the Buyer.")
|
|
58
66
|
actual_delivery_date: str | None = Field(default=None, description="Actual delivery date (BT-72). The date on which the delivery is made.")
|
|
59
67
|
invoicing_period_start_date: str | None = Field(default=None, description="Invoicing period start date (BT-73). The date on which the invoicing period starts.")
|
|
@@ -86,6 +94,7 @@ class Invoice(BaseModel):
|
|
|
86
94
|
seller: BusinessEntity = Field(description="Seller")
|
|
87
95
|
reference_currency_code: str = Field(default="EUR", description="Reference currency code (BT-5). The currency in which all Invoice amounts are given, except for the Total VAT amount in accounting currency. Use code list ISO 4217 — Currency codes") # TODO validation
|
|
88
96
|
items: list[Item] = Field(description="Items to include in the invoice. Will be automatically numbered starting from 1.")
|
|
97
|
+
vat_breakdown: list[VATBreakdown] = Field(default_factory=list, description="VAT breakdown (BG-23). A group of business terms providing information about VAT breakdown by different categories, rates and exemption reasons.")
|
|
89
98
|
|
|
90
99
|
# Monetary stuff
|
|
91
100
|
sum_of_invoice_line_net_amount: str = Field(description="Sum of Invoice line net amount (BT-106). The sum of all Invoice line net amounts in the Invoice.")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/business_process_type.py
RENAMED
|
File without changes
|
{pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/item_identification_scheme.py
RENAMED
|
File without changes
|
|
File without changes
|
{pyslog-0.1.0.dev6 → pyslog-0.1.0.dev8}/src/pyslog/eslog2/models/enums/vat_point_date_code.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|