channel-app 0.0.157a11__tar.gz → 0.0.157a13__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.
Files changed (107) hide show
  1. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/PKG-INFO +1 -1
  2. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/logs/services.py +1 -1
  3. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/products.py +4 -0
  4. channel_app-0.0.157a13/channel_app/reports/__init__.py +0 -0
  5. channel_app-0.0.157a13/channel_app/reports/services.py +184 -0
  6. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app.egg-info/PKG-INFO +1 -1
  7. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app.egg-info/SOURCES.txt +2 -0
  8. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/setup.py +1 -1
  9. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/.gitignore +0 -0
  10. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/.vscode/settings.json +0 -0
  11. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/Makefile +0 -0
  12. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/Procfile-dist +0 -0
  13. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/README.md +0 -0
  14. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/akinon.json-dist +0 -0
  15. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/bitbucket-pipelines.yml +0 -0
  16. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/build.sh-dist +0 -0
  17. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/__init__.py +0 -0
  18. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/alembic.ini +0 -0
  19. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/__init__.py +0 -0
  20. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/order/__init__.py +0 -0
  21. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/order/service.py +0 -0
  22. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product/__init__.py +0 -0
  23. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product/service.py +0 -0
  24. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product_image/__init__.py +0 -0
  25. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product_image/service.py +0 -0
  26. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product_price/__init__.py +0 -0
  27. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product_price/service.py +0 -0
  28. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product_stock/__init__.py +0 -0
  29. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/product_stock/service.py +0 -0
  30. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/setup/__init__.py +0 -0
  31. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/app/setup/service.py +0 -0
  32. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/__init__.py +0 -0
  33. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/__init__.py +0 -0
  34. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/orders/__init__.py +0 -0
  35. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/orders/orders.py +0 -0
  36. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/product_categories.py +0 -0
  37. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/product_images.py +0 -0
  38. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/product_prices.py +0 -0
  39. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/product_stocks.py +0 -0
  40. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/products.py +0 -0
  41. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/commands/setup.py +0 -0
  42. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/channel/integration.py +0 -0
  43. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/__init__.py +0 -0
  44. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/clients.py +0 -0
  45. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/commands.py +0 -0
  46. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/data.py +0 -0
  47. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/integration.py +0 -0
  48. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/products.py +0 -0
  49. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/settings.py +0 -0
  50. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/tests.py +0 -0
  51. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/core/utilities.py +0 -0
  52. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/database/__init__.py +0 -0
  53. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/database/migrations/README +0 -0
  54. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/database/migrations/env.py +0 -0
  55. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/database/migrations/script.py.mako +0 -0
  56. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/database/migrations/versions/6d5ae5b9c541_create_initial_tables.py +0 -0
  57. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/database/models.py +0 -0
  58. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/database/services.py +0 -0
  59. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/logs/__init__.py +0 -0
  60. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/logs/encoders.py +0 -0
  61. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/logs/enums.py +0 -0
  62. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/migrate.py +0 -0
  63. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/__init__.py +0 -0
  64. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/batch_request.py +0 -0
  65. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/__init__.py +0 -0
  66. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/batch_requests.py +0 -0
  67. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/error_reports.py +0 -0
  68. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/integration_actions.py +0 -0
  69. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/orders/__init__.py +0 -0
  70. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/orders/addresses.py +0 -0
  71. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/orders/cargo_companies.py +0 -0
  72. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/orders/customers.py +0 -0
  73. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/orders/orders.py +0 -0
  74. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/product_categories.py +0 -0
  75. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/product_images.py +0 -0
  76. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/product_prices.py +0 -0
  77. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/product_stocks.py +0 -0
  78. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/setup.py +0 -0
  79. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/tests/__init__.py +0 -0
  80. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/tests/test_orders.py +0 -0
  81. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/tests/test_product_images.py +0 -0
  82. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/tests/test_product_prices.py +0 -0
  83. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/tests/test_product_stocks.py +0 -0
  84. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/commands/tests/test_products.py +0 -0
  85. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/constants.py +0 -0
  86. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/exceptions.py +0 -0
  87. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app/omnitron/integration.py +0 -0
  88. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app.egg-info/dependency_links.txt +0 -0
  89. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app.egg-info/requires.txt +0 -0
  90. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/channel_app.egg-info/top_level.txt +0 -0
  91. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/Makefile +0 -0
  92. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/make.bat +0 -0
  93. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/requirements.txt +0 -0
  94. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/architecture.rst +0 -0
  95. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/command_reference.rst +0 -0
  96. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/conf.py +0 -0
  97. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/flows.rst +0 -0
  98. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/images/async.png +0 -0
  99. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/images/batch_request_state_machine.png +0 -0
  100. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/images/sync.png +0 -0
  101. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/index.rst +0 -0
  102. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/installation_and_usage.rst +0 -0
  103. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/docs/source/terminology.rst +0 -0
  104. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/requirements-dev.txt +0 -0
  105. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/requirements.txt +0 -0
  106. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/setup.cfg +0 -0
  107. {channel_app-0.0.157a11 → channel_app-0.0.157a13}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: channel_app
3
- Version: 0.0.157a11
3
+ Version: 0.0.157a13
4
4
  Summary: Channel app for Sales Channels
5
5
  Home-page: https://github.com/akinon/channel_app
6
6
  Author: akinonteam
@@ -32,7 +32,7 @@ class LogService:
32
32
  def create_flow(
33
33
  self,
34
34
  name: str,
35
- transaction_id: str,
35
+ transaction_id: str = None,
36
36
  flow_author: LogFlowAuthor = LogFlowAuthor.system,
37
37
  ):
38
38
  self.flow = {
@@ -43,6 +43,10 @@ class GetInsertedProducts(OmnitronCommandInterface):
43
43
 
44
44
  def get_products(self, limit: int) -> List[Product]:
45
45
  params = {"product_type": 0, "limit": limit}
46
+ initialized_params = getattr(self, "param_{}".format("params"), None)
47
+ if initialized_params:
48
+ params.update(initialized_params)
49
+
46
50
  language = getattr(self, "param_language", None)
47
51
  if language:
48
52
  products = self.endpoint(
File without changes
@@ -0,0 +1,184 @@
1
+ from decimal import Decimal
2
+ from typing import List
3
+ from channel_app.core.settings import OmnitronIntegration
4
+ from channel_app.logs.services import LogService
5
+ from channel_app.omnitron.integration import OmnitronIntegration as IOmnitronIntegration
6
+ from channel_app.omnitron.constants import ContentType
7
+ from omnisdk.omnitron.models import Product
8
+
9
+
10
+ class ReportService:
11
+ @staticmethod
12
+ def get_not_for_sale_products(limit: int = 10) -> List[Product]:
13
+ """
14
+ Get not for sale products from Omnitron API.
15
+ """
16
+
17
+ log_service = LogService()
18
+ log_service.create_flow(name="Get Not For Sale Products")
19
+
20
+ try:
21
+ with OmnitronIntegration(
22
+ content_type=ContentType.product.value,
23
+ ) as omnitron_integration:
24
+ omnitron_integration: IOmnitronIntegration
25
+
26
+ with log_service.step("get_not_for_sale_products"):
27
+ products: List[Product] = omnitron_integration.do_action(
28
+ key="get_inserted_products",
29
+ params={
30
+ "catalogitem__isnull": True,
31
+ },
32
+ objects={
33
+ "limit": limit,
34
+ },
35
+ )
36
+
37
+ return products
38
+ except Exception as fatal:
39
+ log_service.add_exception(fatal)
40
+ raise
41
+ finally:
42
+ log_service.save()
43
+
44
+ @staticmethod
45
+ def get_price_differences_from_products(marketplace_products: List[Product]):
46
+ """
47
+ Get price differences from products.
48
+ :param marketplace_products: List of products from marketplace
49
+ :return: List of products with price differences
50
+
51
+ marketplace_products: List[Product] = [
52
+ Product(
53
+ pk=1,
54
+ price=100.0,
55
+ sku="test-sku-1",
56
+ ...
57
+ ),
58
+ Product(
59
+ pk=3,
60
+ price=200.0,
61
+ sku="test-sku-2",
62
+ ...
63
+ ),
64
+ ]
65
+ """
66
+
67
+ log_service = LogService()
68
+ log_service.create_flow(name="Get Price Differences")
69
+
70
+ try:
71
+ with OmnitronIntegration(
72
+ content_type=ContentType.product_price.value,
73
+ ) as omnitron_integration:
74
+ omnitron_integration: IOmnitronIntegration
75
+
76
+ with log_service.step("get_product_prices"):
77
+ omnitron_products = omnitron_integration.do_action(
78
+ key="get_product_prices",
79
+ objects=marketplace_products,
80
+ )
81
+
82
+ with log_service.step("get_price_differences"):
83
+ differences = []
84
+ for omnitron_product in omnitron_products:
85
+ if omnitron_product.productprice is None:
86
+ continue
87
+
88
+ if omnitron_product.productprice.price is None:
89
+ continue
90
+
91
+ for marketplace_product in marketplace_products:
92
+ if omnitron_product.sku == marketplace_product.sku:
93
+ if Decimal(
94
+ omnitron_product.productprice.price
95
+ ) != Decimal(marketplace_product.price):
96
+ differences.append(
97
+ {
98
+ "product_pk": omnitron_product.pk,
99
+ "product_sku": omnitron_product.sku,
100
+ "price_difference": abs(
101
+ Decimal(
102
+ omnitron_product.productprice.price
103
+ )
104
+ - Decimal(marketplace_product.price)
105
+ ),
106
+ "updated_at": omnitron_product.productprice.modified_date,
107
+ }
108
+ )
109
+
110
+ return differences
111
+ except Exception as fatal:
112
+ log_service.add_exception(fatal)
113
+ raise
114
+ finally:
115
+ log_service.save()
116
+
117
+ @staticmethod
118
+ def get_stock_differences_from_products(marketplace_products: List[Product]):
119
+ """
120
+ Get stock differences from products.
121
+ :param marketplace_products: List of products from marketplace
122
+ :return: List of products with stock differences
123
+
124
+ marketplace_products: List[Product] = [
125
+ Product(
126
+ pk=1,
127
+ stock=100,
128
+ sku="test-sku-1",
129
+ ...
130
+ ),
131
+ Product(
132
+ pk=3,
133
+ stock=200,
134
+ sku="test-sku-2",
135
+ ...
136
+ ),
137
+ ]
138
+ """
139
+ log_service = LogService()
140
+ log_service.create_flow(name="Get Stock Differences")
141
+
142
+ try:
143
+ with OmnitronIntegration(
144
+ content_type=ContentType.product_stock.value,
145
+ ) as omnitron_integration:
146
+ omnitron_integration: IOmnitronIntegration
147
+
148
+ with log_service.step("get_product_stocks"):
149
+ omnitron_products = omnitron_integration.do_action(
150
+ key="get_product_stocks",
151
+ objects=marketplace_products,
152
+ )
153
+
154
+ with log_service.step("get_stock_differences"):
155
+ differences = []
156
+ for omnitron_product in omnitron_products:
157
+ if omnitron_product.productstock is None:
158
+ continue
159
+
160
+ if omnitron_product.productstock.stock is None:
161
+ continue
162
+
163
+ for marketplace_product in marketplace_products:
164
+ if omnitron_product.sku == marketplace_product.sku:
165
+ if int(omnitron_product.productstock.stock) != int(
166
+ marketplace_product.stock
167
+ ):
168
+ differences.append(
169
+ {
170
+ "product_pk": omnitron_product.pk,
171
+ "product_sku": omnitron_product.sku,
172
+ "stock_difference": abs(
173
+ int(omnitron_product.productstock.stock)
174
+ - int(marketplace_product.stock)
175
+ ),
176
+ "updated_at": omnitron_product.productstock.modified_date,
177
+ }
178
+ )
179
+ return differences
180
+ except Exception as fatal:
181
+ log_service.add_exception(fatal)
182
+ raise
183
+ finally:
184
+ log_service.save()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: channel-app
3
- Version: 0.0.157a11
3
+ Version: 0.0.157a13
4
4
  Summary: Channel app for Sales Channels
5
5
  Home-page: https://github.com/akinon/channel_app
6
6
  Author: akinonteam
@@ -88,6 +88,8 @@ channel_app/omnitron/commands/tests/test_product_images.py
88
88
  channel_app/omnitron/commands/tests/test_product_prices.py
89
89
  channel_app/omnitron/commands/tests/test_product_stocks.py
90
90
  channel_app/omnitron/commands/tests/test_products.py
91
+ channel_app/reports/__init__.py
92
+ channel_app/reports/services.py
91
93
  docs/Makefile
92
94
  docs/make.bat
93
95
  docs/requirements.txt
@@ -5,7 +5,7 @@ with open("README.md") as f:
5
5
 
6
6
  setup(
7
7
  name="channel_app",
8
- version="0.0.157a11", # alpha prerelease
8
+ version="0.0.157a13", # alpha prerelease
9
9
  packages=find_packages(),
10
10
  url="https://github.com/akinon/channel_app",
11
11
  description="Channel app for Sales Channels",