oneCInteraction 1.3.2__tar.gz → 1.3.4__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.
- {onecinteraction-1.3.2/src/oneCInteraction.egg-info → onecinteraction-1.3.4}/PKG-INFO +3 -5
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/README.md +2 -4
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/connection.py +0 -1
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/orders.py +47 -41
- {onecinteraction-1.3.2 → onecinteraction-1.3.4/src/oneCInteraction.egg-info}/PKG-INFO +3 -5
- onecinteraction-1.3.4/src/oneCInteraction.egg-info/scm_version.json +8 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/tests/test_lib.py +5 -0
- onecinteraction-1.3.2/src/oneCInteraction.egg-info/scm_version.json +0 -8
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/.github/workflows/publish.yml +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/.gitignore +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/LICENSE +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/pyproject.toml +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/setup.cfg +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/__init__.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/categories.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/characteristics.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/customers.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/discounts.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/groups.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/log.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/nomenclature.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/properties.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction/structures.py +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction.egg-info/SOURCES.txt +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction.egg-info/dependency_links.txt +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction.egg-info/requires.txt +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction.egg-info/scm_file_list.json +0 -0
- {onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oneCInteraction
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.4
|
|
4
4
|
Summary: A Python library for interacting with 1C:Enterprise databases via COM connection.
|
|
5
5
|
Author: agcl
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -68,7 +68,6 @@ def __init__(self, s_oneCDatabasePathIn: str, s_usernameIn: str, s_passwordIn: s
|
|
|
68
68
|
|
|
69
69
|
#### Key Attributes:
|
|
70
70
|
- `s_warehouse_code` (str): 1C warehouse code for new orders.
|
|
71
|
-
- `s_counteragent_code` (str): 1C counteragent (customer) code for new orders.
|
|
72
71
|
- `s_organisation_code` (str): 1C organization code for new orders.
|
|
73
72
|
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая", "Закупочная"]`).
|
|
74
73
|
- `c_v8`: The active 1C COM connection object (equals `None` if not connected).
|
|
@@ -239,8 +238,8 @@ Defined in [orders.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
239
238
|
- Returns the number of the created document in 1C (or an empty string on error).
|
|
240
239
|
- `get(s_codeIn: str) -> Order | None`
|
|
241
240
|
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID, and the price type is retrieved.
|
|
242
|
-
- `
|
|
243
|
-
Returns a list of all
|
|
241
|
+
- `get_by_date(target_date: date | datetime, s_counteragent_code: str = "") -> list`
|
|
242
|
+
Returns a list of all orders for a specific date (accepting `datetime.date` or `datetime.datetime`), optionally filtered by counteragent or counteragent group code.
|
|
244
243
|
- `update_info(c_orderObjIn: Order) -> bool`
|
|
245
244
|
Updates the comment field of the order in 1C. Writes a formatted string to the comment field:
|
|
246
245
|
`"[Full Name] [Phone] [Telegram ID] [Waybill/TTN] [Status]"`
|
|
@@ -312,7 +311,6 @@ c_conn = Connection(
|
|
|
312
311
|
|
|
313
312
|
# 2. Configure 1C Default Codes
|
|
314
313
|
c_conn.s_warehouse_code = "000000001" # Warehouse code
|
|
315
|
-
c_conn.s_counteragent_code = "000000045" # Bot customer/counteragent code
|
|
316
314
|
c_conn.s_organisation_code = "000000001" # Organization code
|
|
317
315
|
|
|
318
316
|
# 3. Establish connection to 1C
|
|
@@ -53,7 +53,6 @@ def __init__(self, s_oneCDatabasePathIn: str, s_usernameIn: str, s_passwordIn: s
|
|
|
53
53
|
|
|
54
54
|
#### Key Attributes:
|
|
55
55
|
- `s_warehouse_code` (str): 1C warehouse code for new orders.
|
|
56
|
-
- `s_counteragent_code` (str): 1C counteragent (customer) code for new orders.
|
|
57
56
|
- `s_organisation_code` (str): 1C organization code for new orders.
|
|
58
57
|
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая", "Закупочная"]`).
|
|
59
58
|
- `c_v8`: The active 1C COM connection object (equals `None` if not connected).
|
|
@@ -224,8 +223,8 @@ Defined in [orders.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
224
223
|
- Returns the number of the created document in 1C (or an empty string on error).
|
|
225
224
|
- `get(s_codeIn: str) -> Order | None`
|
|
226
225
|
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID, and the price type is retrieved.
|
|
227
|
-
- `
|
|
228
|
-
Returns a list of all
|
|
226
|
+
- `get_by_date(target_date: date | datetime, s_counteragent_code: str = "") -> list`
|
|
227
|
+
Returns a list of all orders for a specific date (accepting `datetime.date` or `datetime.datetime`), optionally filtered by counteragent or counteragent group code.
|
|
229
228
|
- `update_info(c_orderObjIn: Order) -> bool`
|
|
230
229
|
Updates the comment field of the order in 1C. Writes a formatted string to the comment field:
|
|
231
230
|
`"[Full Name] [Phone] [Telegram ID] [Waybill/TTN] [Status]"`
|
|
@@ -297,7 +296,6 @@ c_conn = Connection(
|
|
|
297
296
|
|
|
298
297
|
# 2. Configure 1C Default Codes
|
|
299
298
|
c_conn.s_warehouse_code = "000000001" # Warehouse code
|
|
300
|
-
c_conn.s_counteragent_code = "000000045" # Bot customer/counteragent code
|
|
301
299
|
c_conn.s_organisation_code = "000000001" # Organization code
|
|
302
300
|
|
|
303
301
|
# 3. Establish connection to 1C
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from datetime import datetime
|
|
1
|
+
from datetime import datetime, date
|
|
2
2
|
from .log import log_sys
|
|
3
3
|
from . import structures
|
|
4
4
|
|
|
@@ -13,12 +13,12 @@ class OrdersManager:
|
|
|
13
13
|
def push(self, c_orderObjIn) -> str:
|
|
14
14
|
"""Pushes a new customer order to 1C database, returning the created order number or empty string."""
|
|
15
15
|
if not self.c_v8:
|
|
16
|
-
log_sys("Failed to push order: No connection to 1C. Returning
|
|
17
|
-
return
|
|
16
|
+
log_sys("Failed to push order: No connection to 1C. Returning \"\"", 1)
|
|
17
|
+
return ""
|
|
18
18
|
|
|
19
|
-
if not self.c_connection.s_warehouse_code or not self.c_connection.
|
|
20
|
-
log_sys("Failed to push order: No warehouse code and/or
|
|
21
|
-
return
|
|
19
|
+
if not self.c_connection.s_warehouse_code or not self.c_connection.s_organisation_code:
|
|
20
|
+
log_sys("Failed to push order: No warehouse code and/or organisation code. Returning \"\"", 1)
|
|
21
|
+
return ""
|
|
22
22
|
|
|
23
23
|
try:
|
|
24
24
|
c_newOrder = self.c_v8.Documents.ЗаказПокупателя.CreateDocument()
|
|
@@ -50,7 +50,6 @@ class OrdersManager:
|
|
|
50
50
|
# Client / Counteragent
|
|
51
51
|
c_clientRef = None
|
|
52
52
|
c_customer = getattr(c_orderObjIn, "c_orderCustomer", None)
|
|
53
|
-
b_isBotCounteragent = False
|
|
54
53
|
|
|
55
54
|
if c_customer:
|
|
56
55
|
log_sys("Customer structure found in order. Trying to resolve counteragent in 1C...")
|
|
@@ -73,20 +72,11 @@ class OrdersManager:
|
|
|
73
72
|
c_clientRef = c_ref
|
|
74
73
|
log_sys("New customer created and resolved.")
|
|
75
74
|
except Exception as e:
|
|
76
|
-
log_sys(f"Failed to resolve customer: {e}.
|
|
75
|
+
log_sys(f"Failed to resolve customer: {e}.", 1)
|
|
77
76
|
|
|
78
|
-
# Fallback to Bot Counteragent if customer resolution failed or customer wasn't provided
|
|
79
77
|
if not c_clientRef or c_clientRef.IsEmpty():
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
try:
|
|
83
|
-
c_clientRef = self.c_v8.Catalogs.Контрагенты.FindByCode(self.c_connection.s_counteragent_code)
|
|
84
|
-
if c_clientRef.IsEmpty():
|
|
85
|
-
log_sys(f"Can't find bot contragent by code: {self.c_connection.s_counteragent_code}. Returning \"\"", 1)
|
|
86
|
-
return ""
|
|
87
|
-
except Exception as e:
|
|
88
|
-
log_sys(f"Failed to resolve bot contragent: {e}. Returning \"\"", 1)
|
|
89
|
-
return ""
|
|
78
|
+
log_sys("Customer reference is empty or not resolved in 1C. Returning \"\"", 1)
|
|
79
|
+
return ""
|
|
90
80
|
|
|
91
81
|
try:
|
|
92
82
|
c_newOrder.Контрагент = c_clientRef
|
|
@@ -397,54 +387,70 @@ class OrdersManager:
|
|
|
397
387
|
log_sys(f"Error occurred while retrieving order {s_codeIn}: {e}", 1)
|
|
398
388
|
return None
|
|
399
389
|
|
|
400
|
-
def
|
|
401
|
-
"""Retrieves all orders
|
|
390
|
+
def get_by_date(self, target_date, s_counteragent_code: str = "") -> list:
|
|
391
|
+
"""Retrieves all orders for a specific date (date or datetime object), optionally filtered by counteragent or counteragent group code."""
|
|
402
392
|
if not self.c_v8:
|
|
403
|
-
log_sys("Failed to get
|
|
393
|
+
log_sys("Failed to get orders by date: No connection to 1C.", 1)
|
|
404
394
|
return []
|
|
405
395
|
|
|
406
|
-
if len(self.c_connection.s_counteragent_code) < 1:
|
|
407
|
-
log_sys("Failed to get today's orders: No counteragent code. Returning []", 1)
|
|
408
|
-
return []
|
|
409
|
-
|
|
410
396
|
try:
|
|
411
|
-
log_sys("Fetching
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
397
|
+
log_sys(f"Fetching orders for date {target_date}...")
|
|
398
|
+
|
|
399
|
+
if isinstance(target_date, datetime):
|
|
400
|
+
dt_obj = target_date
|
|
401
|
+
elif isinstance(target_date, date):
|
|
402
|
+
dt_obj = datetime.combine(target_date, datetime.min.time())
|
|
403
|
+
elif hasattr(target_date, "year") and hasattr(target_date, "month") and hasattr(target_date, "day"):
|
|
404
|
+
dt_obj = datetime(target_date.year, target_date.month, target_date.day)
|
|
405
|
+
else:
|
|
406
|
+
log_sys(f"Invalid date format passed to get_by_date: {target_date}. Returning []", 1)
|
|
416
407
|
return []
|
|
417
408
|
|
|
418
|
-
|
|
409
|
+
if dt_obj.tzinfo is not None:
|
|
410
|
+
dt_obj = dt_obj.astimezone(self.c_connection.tz_kiev).replace(tzinfo=None)
|
|
411
|
+
|
|
412
|
+
c_startDate = dt_obj.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
413
|
+
c_endDate = dt_obj.replace(hour=23, minute=59, second=59, microsecond=0)
|
|
414
|
+
|
|
419
415
|
c_query = self.c_v8.NewObject("Query")
|
|
420
|
-
|
|
416
|
+
|
|
417
|
+
s_query_text = """
|
|
421
418
|
SELECT Номер AS Number
|
|
422
419
|
FROM Документ.ЗаказПокупателя
|
|
423
|
-
WHERE Дата >= &StartDate
|
|
424
|
-
AND Контрагент = &ClientBot
|
|
420
|
+
WHERE Дата >= &StartDate AND Дата <= &EndDate
|
|
425
421
|
AND ПометкаУдаления = FALSE
|
|
426
|
-
ORDER BY Дата DESC
|
|
427
422
|
"""
|
|
428
|
-
|
|
429
|
-
|
|
423
|
+
|
|
424
|
+
if s_counteragent_code:
|
|
425
|
+
c_clientRef = self.c_v8.Catalogs.Контрагенты.FindByCode(s_counteragent_code)
|
|
426
|
+
if c_clientRef is None or c_clientRef.IsEmpty():
|
|
427
|
+
log_sys(f"Counteragent with code '{s_counteragent_code}' not found in 1C. Returning []", 1)
|
|
428
|
+
return []
|
|
429
|
+
s_query_text += "\n AND Контрагент В ИЕРАРХИИ(&ClientRef)"
|
|
430
|
+
c_query.SetParameter("ClientRef", c_clientRef)
|
|
431
|
+
|
|
432
|
+
s_query_text += "\nORDER BY Дата DESC"
|
|
433
|
+
c_query.Text = s_query_text
|
|
434
|
+
c_query.SetParameter("StartDate", c_startDate)
|
|
435
|
+
c_query.SetParameter("EndDate", c_endDate)
|
|
430
436
|
|
|
431
437
|
c_result = c_query.Execute()
|
|
432
438
|
l_ordersList = []
|
|
433
439
|
|
|
434
440
|
if not c_result.IsEmpty():
|
|
435
441
|
c_selection = c_result.Select()
|
|
436
|
-
log_sys("Found some orders. Starting to parse...")
|
|
442
|
+
log_sys("Found some orders for the date. Starting to parse...")
|
|
437
443
|
|
|
438
444
|
while c_selection.Next():
|
|
439
445
|
c_orderObj = self.get(c_selection.Number)
|
|
440
446
|
if c_orderObj:
|
|
441
447
|
l_ordersList.append(c_orderObj)
|
|
442
448
|
|
|
443
|
-
log_sys(f"Successfully retrieved {len(l_ordersList)} orders for
|
|
449
|
+
log_sys(f"Successfully retrieved {len(l_ordersList)} orders for date {target_date}.")
|
|
444
450
|
return l_ordersList
|
|
445
451
|
|
|
446
452
|
except Exception as e:
|
|
447
|
-
log_sys(f"Error in
|
|
453
|
+
log_sys(f"Error in get_by_date: {e}", 1)
|
|
448
454
|
return []
|
|
449
455
|
|
|
450
456
|
def update_info(self, c_orderObjIn) -> bool:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oneCInteraction
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.4
|
|
4
4
|
Summary: A Python library for interacting with 1C:Enterprise databases via COM connection.
|
|
5
5
|
Author: agcl
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -68,7 +68,6 @@ def __init__(self, s_oneCDatabasePathIn: str, s_usernameIn: str, s_passwordIn: s
|
|
|
68
68
|
|
|
69
69
|
#### Key Attributes:
|
|
70
70
|
- `s_warehouse_code` (str): 1C warehouse code for new orders.
|
|
71
|
-
- `s_counteragent_code` (str): 1C counteragent (customer) code for new orders.
|
|
72
71
|
- `s_organisation_code` (str): 1C organization code for new orders.
|
|
73
72
|
- `sl_price_types` (list): List of price type names to cache automatically (defaults to `["Розничная", "Оптовая", "Закупочная"]`).
|
|
74
73
|
- `c_v8`: The active 1C COM connection object (equals `None` if not connected).
|
|
@@ -239,8 +238,8 @@ Defined in [orders.py](file:///c:/Users/agcl/PycharmProjects/oneCInteractionLib/
|
|
|
239
238
|
- Returns the number of the created document in 1C (or an empty string on error).
|
|
240
239
|
- `get(s_codeIn: str) -> Order | None`
|
|
241
240
|
Retrieves a buyer's order by its 1C document number and parses it into an `Order` object. The comment field is parsed to retrieve the Telegram ID, and the price type is retrieved.
|
|
242
|
-
- `
|
|
243
|
-
Returns a list of all
|
|
241
|
+
- `get_by_date(target_date: date | datetime, s_counteragent_code: str = "") -> list`
|
|
242
|
+
Returns a list of all orders for a specific date (accepting `datetime.date` or `datetime.datetime`), optionally filtered by counteragent or counteragent group code.
|
|
244
243
|
- `update_info(c_orderObjIn: Order) -> bool`
|
|
245
244
|
Updates the comment field of the order in 1C. Writes a formatted string to the comment field:
|
|
246
245
|
`"[Full Name] [Phone] [Telegram ID] [Waybill/TTN] [Status]"`
|
|
@@ -312,7 +311,6 @@ c_conn = Connection(
|
|
|
312
311
|
|
|
313
312
|
# 2. Configure 1C Default Codes
|
|
314
313
|
c_conn.s_warehouse_code = "000000001" # Warehouse code
|
|
315
|
-
c_conn.s_counteragent_code = "000000045" # Bot customer/counteragent code
|
|
316
314
|
c_conn.s_organisation_code = "000000001" # Organization code
|
|
317
315
|
|
|
318
316
|
# 3. Establish connection to 1C
|
|
@@ -134,6 +134,11 @@ try:
|
|
|
134
134
|
assert c_conn.properties is not None
|
|
135
135
|
print("Success: Checked all composition managers exist (including properties).")
|
|
136
136
|
|
|
137
|
+
# Test OrdersManager when connection is not active
|
|
138
|
+
assert c_conn.orders.get_by_date(datetime.now()) == []
|
|
139
|
+
assert c_conn.orders.push(c_order) == ""
|
|
140
|
+
print("Success: OrdersManager.get_by_date and push tested with no active connection.")
|
|
141
|
+
|
|
137
142
|
# Test PropertiesManager when connection is not active
|
|
138
143
|
assert c_conn.properties.get_assigned_properties("ART001") == []
|
|
139
144
|
assert c_conn.properties.write("ART001", "Колір", "Зелений") is False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{onecinteraction-1.3.2 → onecinteraction-1.3.4}/src/oneCInteraction.egg-info/scm_file_list.json
RENAMED
|
File without changes
|
|
File without changes
|