pyslog 0.1.0.dev7__tar.gz → 0.1.0.dev9__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.dev7
3
+ Version: 0.1.0.dev9
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyslog"
3
- version = "0.1.0.dev7"
3
+ version = "0.1.0.dev9"
4
4
  description = "Python e-SLOG library. Simplifies the generation of Slovenian e-SLOG electronic documents."
5
5
  license = "MIT"
6
6
  authors = [
@@ -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(invoice: Invoice) -> str:
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"
@@ -287,14 +294,6 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
287
294
  )
288
295
  )
289
296
  ),
290
- ESLOG_G_SG27(
291
- S_MOA=ESLOG_S_MOA(
292
- C_C516=ESLOG_C_C516(
293
- D_5025="38",
294
- D_5004=item.total_monetary_amount_including_vat,
295
- )
296
- )
297
- ),
298
297
  ],
299
298
  G_SG29=[
300
299
  ESLOG_G_SG29(
@@ -307,16 +306,6 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
307
306
  )
308
307
  )
309
308
  ),
310
- ESLOG_G_SG29(
311
- S_PRI=ESLOG_S_PRI(
312
- C_C509=ESLOG_C_C509(
313
- D_5125="AAB",
314
- D_5118=item.item_gross_price,
315
- D_5284=item.item_price_base_quantity,
316
- D_6411=item.item_price_base_quantity_unit_of_measure_code,
317
- )
318
- )
319
- ),
320
309
  ],
321
310
  G_SG30=[],
322
311
  G_SG34=[
@@ -338,8 +327,49 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
338
327
  ],
339
328
  G_SG39=[],
340
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
+
341
356
  eslog_invoice.M_INVOIC.SG26.append(eslog_item)
342
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
+ S_PAI=ESLOG_S_PAI(
368
+ C_C534=ESLOG_C_C534(D_4461=invoice.payment_means_code.value)
369
+ ) if invoice.payment_means_code else None
370
+ )
371
+ )
372
+
343
373
  if invoice.value_added_tax_point_date:
344
374
  eslog_invoice.M_INVOIC.DTM.append(
345
375
  ESLOG_S_DTM(
@@ -492,6 +522,7 @@ def generate_eslog_invoice(invoice: Invoice) -> str:
492
522
 
493
523
 
494
524
  xml_string = eslog_invoice.to_xml(
525
+ pretty_print=pretty_print,
495
526
  encoding="unicode",
496
527
  )
497
528
  return xml_string
@@ -119,6 +119,20 @@ 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_C_C534(BaseXmlModel, tag="C_C534"):
126
+ D_4461: str = element(name="D_4461")
127
+
128
+ class ESLOG_S_PAI(BaseXmlModel, tag="S_PAI"):
129
+ C_C534: ESLOG_C_C534 = element(tag="C_C534")
130
+
131
+ class ESLOG_G_SG8(BaseXmlModel, tag="G_SG8"):
132
+ S_PAT: ESLOG_S_PAT = element(tag="S_PAT")
133
+ S_DTM: list[ESLOG_S_DTM] = element(tag="S_DTM")
134
+ S_PAI: ESLOG_S_PAI | None = element(tag="S_PAI", default=None)
135
+
122
136
  class ESLOG_C_C212(BaseXmlModel, tag="C_C212"):
123
137
  D_7140: str = element(name="D_7140")
124
138
  D_7143: str = element(name="D_7143")
@@ -238,6 +252,7 @@ class ESLOG_M_INVOIC(BaseXmlModel, tag="M_INVOIC"):
238
252
  SG1: list[ESLOG_G_SG1] = element(tag="G_SG1")
239
253
  SG2: list[ESLOG_G_SG2] = element(tag="G_SG2")
240
254
  SG7: list[ESLOG_G_SG7] = element(tag="G_SG7")
255
+ SG8: list[ESLOG_G_SG8] = element(tag="G_SG8")
241
256
  SG26: list[ESLOG_G_SG26] = element(tag="G_SG26")
242
257
  UNS: ESLOG_S_UNS = element(tag="S_UNS")
243
258
  SG50: list[ESLOG_G_SG50] = element(tag="G_SG50")
@@ -2,10 +2,12 @@ from .vat_point_date_code import VATPointDateCode
2
2
  from .business_process_type import BusinessProcessType
3
3
  from .item_identification_scheme import ItemIdentificationScheme
4
4
  from .vat_category_code import VATCategoryCode
5
+ from .payment_means_code import PaymentMeansCode
5
6
 
6
7
  __all__ = [
7
8
  "VATPointDateCode",
8
9
  "BusinessProcessType",
9
10
  "ItemIdentificationScheme",
10
11
  "VATCategoryCode",
12
+ "PaymentMeansCode",
11
13
  ]
@@ -0,0 +1,5 @@
1
+ from enum import Enum
2
+
3
+ class PaymentMeansCode(str, Enum):
4
+ CREDIT_TRANSFER = "30"
5
+ SEPA_CREDIT_TRANSFER = "58"
@@ -4,6 +4,7 @@ from .enums import (
4
4
  BusinessProcessType,
5
5
  ItemIdentificationScheme,
6
6
  VATCategoryCode,
7
+ PaymentMeansCode,
7
8
  )
8
9
 
9
10
 
@@ -16,7 +17,7 @@ class VATBreakdown(BaseModel):
16
17
  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
18
  tax_amount: str = Field(description="VAT category tax amount (BT-117). The total VAT amount for a given VAT category.")
18
19
  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
+ 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
21
 
21
22
  class BusinessEntity(BaseModel):
22
23
  identifier: str | None = Field(default=None, description="Buyer identifier (BT-46)")
@@ -61,6 +62,8 @@ class Invoice(BaseModel):
61
62
  invoice_number: str
62
63
  invoice_issue_date: str
63
64
  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.")
65
+ payment_due_date: str | None = Field(default=None, description="Payment due date (BT-9). The date on which the payment is due.")
66
+ payment_means_code: PaymentMeansCode = Field(default=PaymentMeansCode.SEPA_CREDIT_TRANSFER, description="Payment means type code (BT-81). The means, expressed as code, for how a payment is expected to be or has been settled.")
64
67
  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.")
65
68
  actual_delivery_date: str | None = Field(default=None, description="Actual delivery date (BT-72). The date on which the delivery is made.")
66
69
  invoicing_period_start_date: str | None = Field(default=None, description="Invoicing period start date (BT-73). The date on which the invoicing period starts.")
File without changes