pyslog 0.1.0.dev5__tar.gz → 0.1.0.dev7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyslog
3
- Version: 0.1.0.dev5
3
+ Version: 0.1.0.dev7
4
4
  Summary: Python e-SLOG library. Simplifies the generation of Slovenian e-SLOG electronic documents.
5
5
  Keywords: eslog,eracun,e-racun,e-invoice
6
6
  Author: Gregor Gabrovšek
@@ -101,7 +101,7 @@ item = Item(
101
101
  invoice = Invoice(
102
102
  invoice_number="INV-2026-001",
103
103
  invoice_issue_date="2026-01-13",
104
- business_process_type=BusinessProcessType.INVOICING_BASED_ON_CONTRACT,
104
+ #business_process_type=BusinessProcessType.INVOICING_BASED_ON_CONTRACT,
105
105
  buyer=buyer,
106
106
  seller=seller,
107
107
  items=[item],
@@ -70,7 +70,7 @@ item = Item(
70
70
  invoice = Invoice(
71
71
  invoice_number="INV-2026-001",
72
72
  invoice_issue_date="2026-01-13",
73
- business_process_type=BusinessProcessType.INVOICING_BASED_ON_CONTRACT,
73
+ #business_process_type=BusinessProcessType.INVOICING_BASED_ON_CONTRACT,
74
74
  buyer=buyer,
75
75
  seller=seller,
76
76
  items=[item],
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyslog"
3
- version = "0.1.0.dev5"
3
+ version = "0.1.0.dev7"
4
4
  description = "Python e-SLOG library. Simplifies the generation of Slovenian e-SLOG electronic documents."
5
5
  license = "MIT"
6
6
  authors = [
@@ -116,6 +116,16 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
116
116
  D_3228=invoice.seller.country_subdivision,
117
117
  )
118
118
 
119
+ doc_field = ESLOG_S_FTX(
120
+ D_4451="DOC",
121
+ C_C108=ESLOG_C_C108(
122
+ D_4440="urn:cen.eu:en16931:2017"
123
+ )
124
+ )
125
+ if invoice.business_process_type is not None:
126
+ doc_field.C_C107 = ESLOG_C_C107(
127
+ D_4441=invoice.business_process_type.value
128
+ )
119
129
 
120
130
  eslog_invoice = ESLOG_Invoice(
121
131
  M_INVOIC=ESLOG_M_INVOIC(
@@ -145,17 +155,7 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
145
155
  )
146
156
  ),
147
157
  ],
148
- FTX=[
149
- ESLOG_S_FTX(
150
- D_4451="DOC",
151
- C_C107=ESLOG_C_C107(
152
- D_4441=invoice.business_process_type.value
153
- ),
154
- C_C108=ESLOG_C_C108(
155
- D_4440="urn:cen.eu:en16931:2017"
156
- )
157
- ),
158
- ],
158
+ FTX=[doc_field],
159
159
  SG1=[],
160
160
  SG2=[
161
161
  eslog_buyer,
@@ -210,37 +210,39 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
210
210
  ),
211
211
 
212
212
  ],
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
- ],
213
+ SG52=[],
241
214
  )
242
215
  )
243
216
 
217
+ for vat_item in invoice.vat_breakdown:
218
+ eslog_tax = ESLOG_G_SG52(
219
+ S_TAX=ESLOG_S_TAX(
220
+ D_5283="7",
221
+ C_C241=ESLOG_C_C241(
222
+ D_5153="VAT"
223
+ ),
224
+ C_C243=ESLOG_C_C243(
225
+ D_5278=vat_item.vat_category_rate
226
+ ),
227
+ D_5305=vat_item.vat_category_code.value
228
+ ),
229
+ S_MOA=[
230
+ ESLOG_S_MOA(
231
+ C_C516=ESLOG_C_C516(
232
+ D_5025="125",
233
+ D_5004=vat_item.taxable_amount
234
+ )
235
+ ),
236
+ ESLOG_S_MOA(
237
+ C_C516=ESLOG_C_C516(
238
+ D_5025="124",
239
+ D_5004=vat_item.tax_amount
240
+ )
241
+ ),
242
+ ]
243
+ )
244
+ eslog_invoice.M_INVOIC.SG52.append(eslog_tax)
245
+
244
246
  for index, item in enumerate(invoice.items):
245
247
  eslog_item = ESLOG_G_SG26(
246
248
  S_LIN=ESLOG_S_LIN(
@@ -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
  ]
@@ -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 | None = 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?
@@ -71,7 +78,8 @@ class Invoice(BaseModel):
71
78
  default=None,
72
79
  description="Invoice note (BT-22). A textual note that gives unstructured information that is relevant to the Invoice as a whole. A group of business terms providing textual notes that are relevant for the invoice, together with an indication of the note subject."
73
80
  )
74
- business_process_type: BusinessProcessType = Field(
81
+ business_process_type: BusinessProcessType | None = Field(
82
+ default=None,
75
83
  description="Business process type (BT-23). Identifies the business process context in which the transaction appears, to enable the Buyer to process the Invoice in an appropriate way."
76
84
  )
77
85
  payment_means_text: str | None = Field(
@@ -85,6 +93,7 @@ class Invoice(BaseModel):
85
93
  seller: BusinessEntity = Field(description="Seller")
86
94
  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
87
95
  items: list[Item] = Field(description="Items to include in the invoice. Will be automatically numbered starting from 1.")
96
+ 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.")
88
97
 
89
98
  # Monetary stuff
90
99
  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.")