Guest User

Untitled

a guest
Jun 22nd, 2022
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.36 KB | None | 0 0
  1. from spyne import ComplexModel, String, Integer, Array, Date, Boolean, Decimal, DateTime
  2.  
  3. from exim.models import ExportFSS, ImportFSS
  4. import uuid
  5.  
  6. guid = String.customize(
  7. max_length=36, pattern='[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}',
  8. nullable=True)
  9. send_date_time = DateTime.customize(
  10. format="%Y-%m-%dT%H:%M:%SZ", nullable=False)
  11. status = String.customize(min_occurs=0, max_occurs=1)
  12. status_code = Integer.customize(min_occurs=0, max_occurs=1)
  13. inspector = String.customize(min_occurs=0, max_occurs=1, max_length=255)
  14.  
  15.  
  16. class Man(ComplexModel):
  17. man_name = String.customize(max_length=255, nullable=False)
  18. man_father_name = String.customize(max_length=255, nullable=False)
  19. man_family = String.customize(max_length=255, nullable=False)
  20.  
  21.  
  22. class Consignor(ComplexModel):
  23. code = String.customize(min_occurs=0, max_length=10, nullable=True)
  24. name = String.customize(max_length=255, nullable=False)
  25. identifier = String.customize(max_length=30, nullable=True)
  26. identifier_2 = String.customize(max_length=30, nullable=True)
  27. place = String.customize(max_length=512, nullable=False)
  28. address = String.customize(min_occurs=0, max_length=512, nullable=True)
  29. address_code = String.customize(min_occurs=0, max_length=36, nullable=True)
  30. agent = String.customize(max_length=255, nullable=True)
  31. agent_code = Integer.customize(min_occurs=0, nullable=True)
  32. behalf = String.customize(min_occurs=0, max_length=512, nullable=True)
  33. man = Man
  34. type = Integer
  35.  
  36.  
  37. class Consignee(ComplexModel):
  38. code = String.customize(min_occurs=0, max_length=10, nullable=True)
  39. name = String.customize(max_length=255, nullable=False)
  40. identifier = String.customize(max_length=30, nullable=True)
  41. identifier_2 = String.customize(max_length=30, nullable=True)
  42. place = String.customize(max_length=512, nullable=False)
  43. address = String.customize(min_occurs=0, max_length=512, nullable=True)
  44. address_code = String.customize(min_occurs=0, max_length=36, nullable=True)
  45. agent = String.customize(max_length=255, nullable=True)
  46. agent_code = Integer.customize(min_occurs=0, nullable=True)
  47. behalf = String.customize(min_occurs=0, max_length=512, nullable=True)
  48. man = Man
  49. type = Integer
  50.  
  51.  
  52. class Transport(ComplexModel):
  53. __namespace__ = ''
  54. name = String.customize(min_occurs=0, max_length=255, nullable=True)
  55. number = String.customize(max_length=512, nullable=False)
  56. country_code = String.customize(
  57. min_occurs=0, max_length=2, pattern='[A-Z]', nullable=True)
  58. declared_type = String.customize(max_length=100, nullable=False)
  59. declared_type_code = Integer
  60. arrival_date = Date.customize(
  61. min_occurs=0, format='%Y-%m-%d', nullable=True)
  62. arrival_place = String.customize(
  63. min_occurs=0, max_length=512, nullable=True)
  64. document = String.customize(min_occurs=0, max_length=255, nullable=True)
  65. document_date = Date.customize(
  66. min_occurs=0, format='%Y-%m-%d', nullable=True)
  67. document_number = String.customize(
  68. min_occurs=0, max_length=255, nullable=True)
  69.  
  70.  
  71. class ProductDescription(ComplexModel):
  72. __namespace__ = ''
  73. name_rus = String.customize(max_length=1024, nullable=False)
  74. name_eng = String.customize(min_occurs=0, max_length=1024, nullable=True)
  75. name_botanic = String.customize(
  76. min_occurs=0, max_length=1024, nullable=False)
  77. hs = String.customize(min_occurs=0, max_length=512, nullable=True)
  78. hs_code = String.customize(
  79. min_occurs=0, min_length=4, max_length=10, nullable=False)
  80. origin_place = String.customize(max_length=512, nullable=False)
  81. origin_country = String.customize(max_length=100, nullable=False)
  82. origin_country_code = String.customize(
  83. min_occurs=0, max_length=2, pattern='[A-Z]', nullable=True)
  84. manufacturer = String.customize(
  85. min_occurs=0, max_length=255, nullable=False)
  86. manufacturer_code = Integer.customize(min_occurs=0, nullable=True)
  87. manufacturer_identifier = String.customize(
  88. min_occurs=0, max_length=30, nullable=True)
  89. manufacturer_identifier_2 = String.customize(
  90. min_occurs=0, max_length=30, nullable=True)
  91. manufacturer_place = String.customize(
  92. min_occurs=0, max_length=512, nullable=True)
  93. quantity = Decimal.customize(fraction_digits=3, nullable=False)
  94. quantity_unit = String.customize(max_length=100, nullable=False)
  95. quantity_unit_code = String.customize(
  96. min_occurs=0, max_length=3, nullable=True)
  97. quantity_gross = Decimal.customize(
  98. min_occurs=0, fraction_digits=3, nullable=True)
  99. quantity_gross_unit = String.customize(max_length=100, nullable=True)
  100. quantity_gross_unit_code = String.customize(
  101. min_occurs=0, max_length=3, nullable=True)
  102. quantity_special = Decimal.customize(fraction_digits=3, nullable=True)
  103. quantity_special_unit = String.customize(max_length=100, nullable=True)
  104. quantity_special_unit_code = String.customize(
  105. min_occurs=0, max_length=3, nullable=True)
  106. packages = Integer.customize(min_occurs=0, nullable=True)
  107. packages_unit = String.customize(max_length=100, nullable=True)
  108. packages_unit_code = String.customize(
  109. min_occurs=0, max_length=3, nullable=True)
  110. packages_type = String.customize(max_length=100, nullable=True)
  111. packages_type_code = String.customize(
  112. max_length=2, pattern='[0-9A-Z]', nullable=True)
  113. packages_description = String.customize(
  114. min_occurs=0, max_length=512, nullable=True)
  115. volume = Decimal.customize(min_occurs=0, fraction_digits=3, nullable=True)
  116. volume_unit = String.customize(max_length=100, nullable=True)
  117. volume_unit_code = String.customize(
  118. min_occurs=0, max_length=3, nullable=True)
  119. marking = String.customize(min_occurs=0, max_length=255, nullable=True)
  120. expert_opinion_date = Date.customize(
  121. min_occurs=0, format='%Y-%m-%d', nullable=True)
  122. expert_opinion_number = String.customize(
  123. min_occurs=0, max_length=255, nullable=True)
  124. expert_samples = String.customize(
  125. min_occurs=0, max_length=512, nullable=True)
  126. additional_info = String.customize(
  127. min_occurs=0, max_length=2000, nullable=True)
  128.  
  129.  
  130. class Disinfection(ComplexModel):
  131. date = Date.customize(min_occurs=0, format='%Y-%m-%d', nullable=True)
  132. method = String.customize(min_occurs=0, max_length=100, nullable=True)
  133. chemical = String.customize(min_occurs=0, max_length=100, nullable=True)
  134. temperature_times = String.customize(
  135. min_occurs=0, max_length=100, nullable=True)
  136. concentration = String.customize(
  137. min_occurs=0, max_length=100, nullable=True)
  138. additional_info = String.customize(
  139. min_occurs=0, max_length=2000, nullable=True)
  140.  
  141.  
  142. class CertificateMinimumType(ComplexModel):
  143. guid = guid
  144. send_date_time = send_date_time
  145. date = Date.customize(format='%Y-%m-%d', nullable=False)
  146. number = String.customize(max_length=100, nullable=False)
  147. blanc = String.customize(max_length=100, nullable=False)
  148. country_code = String.customize(
  149. max_length=2, pattern='[A-Z]{2}', nullable=True)
  150. expiration_date = Date.customize(format='%Y-%m-%d', nullable=True)
  151. cancelled = Boolean.customize(nullable=True)
  152. issue_place = String.customize(max_length=255, nullable=True)
  153. inspector = inspector
  154.  
  155. # @staticmethod
  156. # def generate(valid=False):
  157. # return {
  158. # 'date': ExportFSS.given_date,
  159. # 'number': ExportFSS.number,
  160. # 'blanc': ExportFSS.order_number,
  161. # 'country_code': ExportFSS.exporter_country.code,
  162. # 'expiration_date': None,
  163. # 'cancelled': "false",
  164. # 'issue_place': ExportFSS.point.name_ru,
  165. # 'inspector': ExportFSS.inspector_name
  166.  
  167. # } if valid else {
  168. # 'date': None,
  169. # 'number': None,
  170. # 'blanc': None,
  171. # 'country_code': None,
  172. # 'expiration_date': None,
  173. # 'cancelled': None,
  174. # 'issue_place': None,
  175. # 'inspector': None
  176. # }
  177.  
  178. @staticmethod
  179. def generate(valid=True):
  180. return {
  181. 'Date': '2022-03-31',
  182. 'Number': 'UZ33333',
  183. 'Blanc': 'UZ33333',
  184. 'CountryCode': 'UZ',
  185. 'ExpirationDate': '0001-01-01',
  186. 'Cancelled': "false",
  187. 'IssuePlace': 'Республика Узбекистан, ',
  188. 'Inspector': 'Абдуллаев'
  189.  
  190. } if valid else {
  191. 'Date': None,
  192. 'Number': None,
  193. 'Blanc': None,
  194. 'CountryCode': None,
  195. 'ExpirationDate': None,
  196. 'Cancelled': None,
  197. 'IssuePlace': None,
  198. 'Inspector': None
  199. }
  200.  
  201. @staticmethod
  202. def guid_generate():
  203. return str(uuid)
  204.  
  205.  
  206. class CertificateMaximumType(ComplexModel):
  207. guid = guid
  208. send_date_time = send_date_time
  209. date = Date.customize(format='%Y-%m-%d', nullable=False)
  210. number = String.customize(max_length=100, nullable=False)
  211. blanc = String.customize(max_length=100, nullable=False)
  212. country_code = String.customize(
  213. max_length=2, pattern='[A-Z]{2}', nullable=True)
  214. expiration_date = Date.customize(format='%Y-%m-%d', nullable=True)
  215. cancelled = Boolean.customize(nullable=True)
  216. issue_place = String.customize(max_length=255, nullable=True)
  217. inspector = inspector
  218. departure_country = String.customize(max_length=100, nullable=False)
  219. departure_country_code = String.customize(
  220. max_length=2, pattern='[A-Z]{2}', nullable=False)
  221. destination_country = String.customize(max_length=100, nullable=False)
  222. destination_country_code = String.customize(
  223. max_length=2, pattern='[A-Z]{2}', nullable=False)
  224. entry_checkpoint = String.customize(max_length=255, nullable=False)
  225. entry_checkpoint_code = Integer.customize(nullable=True)
  226. consignor = Consignor
  227. consignee = Consignee
  228. transport = Transport
  229. product_description = ProductDescription(many=True)
  230. general_marking = String.customize(max_length=512, nullable=True)
  231. general_quarantine_condition = String.customize(
  232. max_length=512, nullable=True)
  233. general_base_document = String.customize(max_length=512, nullable=True)
  234. general_additional_declaration = String.customize(
  235. max_length=4000, nullable=True)
  236. general_mandatory_actions = String.customize(max_length=512, nullable=True)
  237. disinfection = Disinfection
  238. additional_info = String.customize(max_length=2000, nullable=True)
  239. annex_doc = String.customize(max_length=100000, nullable=True)
  240. annex_text = String.customize(max_length=4000, nullable=True)
  241.  
  242. @staticmethod
  243. def generate(valid=True):
  244. return{
  245. "ID": "",
  246. "GUID": "72c368e0-bf6d-4150-b98f-ef4132b0e40f",
  247. "SendDateTime": "2022-04-11T19:50:11",
  248. "Date": "2022-03-31",
  249. "Number": "UZ33333",
  250. "Blanc": "UZ33333",
  251. "CountryCode": "UZ",
  252. "ExpirationDate": "0001-01-01",
  253. "Cancelled": "false",
  254. "IssuePlace": "Республика Узбекистан",
  255. "Inspector": "Абдуллаев.",
  256. "DepartureCountry": "Узбекистан",
  257. "DepartureCountryCode": "UZ",
  258. "DestinationCountry": "Российская Федерация",
  259. "DestinationCountryCode": "RU",
  260. "EntryCheckpoint": "Россия",
  261. "EntryCheckpointCode": "0",
  262. "Consignor": {
  263. "Name": "ТОХИРОВ ШУХРАТ ТОХИРОВИЧ Р.УЗБЕКИСТАН, ",
  264. "Identifier": "2310031475",
  265. "Place": "Р.УЗБЕКИСТАН, ФЕРГАНСКАЯ ОБЛАСТЬ, Г.МАРГИЛАН, УЛИЦА ТАДБИРКОР, 7",
  266. "Type": "0 ",
  267. },
  268. "Consignee": {
  269. "Name": "2310031475 АО ТАНДЕР 350002,РОССИЯ,КРАСНОДАРСКИЙ КРАЙ,",
  270. "Identifier": "2310031475",
  271. "Place": "350002,РОССИЯ,КРАСНОДАРСКИЙ КРАЙ,Г.КРАСНОДАР,УЛ.ЛЕВАНЕВСКОГО,185",
  272. "Type": "0 ",
  273. },
  274. "Transport": {
  275. "Name": "АВТОМОБИЛЬНЫЙ/АВТОМОБИЛЬНЫЙ ГАЗЕЛЬ 884 DAA 07",
  276. "Number": "ГАЗЕЛЬ 884 DAA 07",
  277. "CountryCode": "UZ",
  278. "DeclaredType": "автодорожный транспорт",
  279. "DeclaredTypeCode": "30",
  280. "ArrivalDateTime": "0001-01-01T00:00:00",
  281. "ArrivalPlace": ""
  282. },
  283. "ProductDescription": {
  284. "NameRus": "слива свежая",
  285. "NameEng": "Рlum",
  286. "NameBotanic": "Prunus domestica",
  287. "HS": "",
  288. "HSCode": "0809400500",
  289. "OriginPlace": "РЕСПУБЛИКА УЗБЕКИСТАН ",
  290. "OriginCountry": "РЕСПУБЛИКА УЗБЕКИСТАН ",
  291. "OriginCountryCode": "UZ",
  292. "Manufacturer": "OOO AZAMAT ESTERN TRADE",
  293. "ManufacturerCode": "0",
  294. "ManufacturerIdentifier": "",
  295. "ManufacturerIdentifier2": "",
  296. "ManufacturerPlace": "",
  297. "Quantity": "",
  298. "QuantityUnit": "0.6",
  299. "Packages": "80",
  300. "PackagesUnit": "Место",
  301. "PackagesUnitCode": "698",
  302. "PackagesType": "ящики",
  303. "PackagesDescription": "80 ЯЩИК(ОВ)",
  304. "Marking": "МАРКИРОВАН",
  305. },
  306. "GeneralMarking": "МАРКИРОВАН",
  307. "GeneralAdditionalDeclaration": "КАРАНТИННЫЕ ОБЪЕКТЫ НЕ ОБНАРУЖЕНЫ. СОГЛАСНО ТАБЛИЦЫ ЕДИНЫХ КАРАНТИННЫХ ФИТОСАНИТАРНЫХ ТРЕБОВАНИЙ, ПРЕДЪЯВЛЯЕМЫХ К ПОДКАРАНТИННОЙ ПРОДУКЦИИ И ПОДКАРАНТИННЫМ ОБЪЕКТАМ НА ТАМОЖЕННОЙ ТЕРРИТОРИИ ЕВРАЗИЙСКОГО ЭКОНОМИЧЕСКОГО СОЮЗА (РЕШЕНИЕ СОВЕТА ЕВРАЗИЙСКОЙ ЭКОНОМИЧЕСКОЙ КОМИССИИ ОТ 30.11.2016 ГОДА) №157)",
  308. "GeneralMandatoryActions": "В соответствии со ст. 32 Федерального Закона 'О карантине растений' № 206-ФЗ от 21.07.2014 г.немедленно извещать федеральный орган исполнительной власти по обеспечению карантина растений о прибытии подкарантинной продукции (подкарантинного материала, подкарантинного груза):",
  309. "Disinfection": {
  310. "Date": "0001-01-01T00:00:00",
  311. "Method": "НЕТ",
  312. "Chemical": "НЕТ",
  313. "TemperatureTimes": "НЕТ",
  314. "Concentration": "НЕТ",
  315. "AdditionalInfo": "",
  316. },
  317. "AdditionalInfo": "Адрес места выдачи: Управление Россельхознадзора по Оренбургской области (56), Управление Федеральной службы по ветеринарному и фитосанитарному надзору по Оренбургской области, г.Оренбург, ул.Монтажников, 34. . Количество мест груза: 180",
  318. }if valid else {
  319. 'Date': None,
  320. }
  321.  
  322.  
  323. class ActMinimumType(ComplexModel):
  324. guid = guid
  325. send_date_time = send_date_time
  326. date = Date.customize(format='%Y-%m-%d', nullable=False)
  327. number = String.customize(max_length=100, nullable=False)
  328. blanc = String.customize(max_length=100, nullable=False)
  329. old_date = Date.customize(format='%Y-%m-%d', nullable=True)
  330. old_number = String.customize(max_length=100, nullable=True)
  331. old_blanc = String.customize(max_length=100, nullable=True)
  332. country_code = String.customize(
  333. max_length=2, pattern='[A-Z]{2}', nullable=True)
  334. issue_place = String.customize(max_length=255, nullable=True)
  335. inspector = inspector
  336. inspection_result = String.customize(max_length=255, nullable=False)
  337. inspection_result_code = Integer.customize(nullable=False)
  338. inspection_result_report = String.customize(max_length=512, nullable=False)
  339. inspection_type = String.customize(
  340. min_occurs=0, max_length=255, nullable=True)
  341. inspection_type_code = Integer.customize(min_occurs=0, nullable=True)
  342.  
  343. @staticmethod
  344. def generate(valid=True):
  345. return {
  346. 'Date': '2022-03-31',
  347. 'Number': 'UZ33333',
  348. 'Blanc': 'UZ33333',
  349. 'OldDate': '0001-01-01',
  350. 'OldNumber': None,
  351. 'OldBlanc': None,
  352. 'CountryCode': 'UZ',
  353. 'IssuePlace': 'Республика Узбекистан, ',
  354. 'Inspector': 'Абдуллаев',
  355. 'InspectionResult': 'ВЫПУСК РАЗРЕШЕН',
  356. 'InspectionResultCode': 'Абдуллаев',
  357. 'InspectionResultReport': 'В результате документарной проверки,осмотра транспортных средств,осмотра подкарантинной продукции,досмотра подкарантинной продукции установлено: нарушений не выявлено',
  358. 'InspectionType': 'Вторичный',
  359. 'InspectionTypeCode': '2'
  360.  
  361.  
  362. } if valid else {
  363. 'Date': None,
  364. 'Number': None,
  365. 'Blanc': None,
  366. 'OldDate': None,
  367. 'OldNumber': None,
  368. 'OldBlanc': None,
  369. 'CountryCode': None,
  370. 'IssuePlace': None,
  371. 'Inspector': None,
  372. 'InspectionResult': None,
  373. 'InspectionResultCode': None,
  374. 'InspectionResultReport': None,
  375. 'InspectionType': None,
  376. 'InspectionTypeCode': None
  377. }
  378.  
  379.  
  380. class ActMaximumType(ComplexModel):
  381. guid = guid
  382. send_date_time = send_date_time
  383. date = Date.customize(format='%Y-%m-%d', nullable=False)
  384. number = String.customize(max_length=100, nullable=False)
  385. blanc = String.customize(max_length=100, nullable=False)
  386. old_date = Date.customize(format='%Y-%m-%d', nullable=True)
  387. old_number = String.customize(max_length=100, nullable=True)
  388. old_blanc = String.customize(max_length=100, nullable=True)
  389. country_code = String.customize(
  390. max_length=2, pattern='[A-Z]{2}', nullable=True)
  391. issue_place = String.customize(max_length=255, nullable=True)
  392. inspector = inspector
  393. inspection_result = String.customize(max_length=255, nullable=False)
  394. inspection_result_code = Integer.customize(nullable=False)
  395. inspection_result_report = String.customize(max_length=512, nullable=False)
  396. inspection_type = String.customize(
  397. min_occurs=0, max_length=255, nullable=True)
  398. inspection_type_code = Integer.customize(min_occurs=0, nullable=True)
  399. certificate = CertificateMaximumType
  400. expert_opinion_date = Date.customize(
  401. min_occurs=0, format='%Y-%m-%d', nullable=True)
  402. expert_opinion_number = String.customize(
  403. min_occurs=0, max_length=255, nullable=True)
  404. expert_samples = String.customize(
  405. min_occurs=0, max_length=512, nullable=True)
  406. departure_country = String.customize(max_length=100, nullable=False)
  407. departure_country_code = String.customize(
  408. max_length=2, pattern='[A-Z]{2}', nullable=False)
  409. destination_country = String.customize(max_length=100, nullable=False)
  410. destination_country_code = String.customize(
  411. max_length=2, pattern='[A-Z]{2}', nullable=False)
  412. consignor = Consignor
  413. consignee = Consignee
  414. transport = Transport
  415. general_marking = String.customize(max_length=512, nullable=True)
  416. general_quarantine_condition = String.customize(
  417. max_length=512, nullable=True)
  418. general_base_document = String.customize(max_length=512, nullable=True)
  419. general_additional_declaration = String.customize(
  420. max_length=4000, nullable=True)
  421. general_mandatory_actions = String.customize(max_length=512, nullable=True)
  422. disinfection = Disinfection
  423. additional_info = String.customize(max_length=2000, nullable=True)
  424. annex_doc = String.customize(max_length=100000, nullable=True)
  425. annex_text = String.customize(max_length=4000, nullable=True)
  426.  
  427.  
  428. class Request1Type(ComplexModel):
  429. guid = guid
  430. send_date_time = send_date_time
  431. certificate = CertificateMinimumType
  432. status = status
  433. status_code = status_code
  434. inspector = inspector
  435.  
  436.  
  437. class Request31Type(ComplexModel):
  438. guid = guid
  439. send_date_time = send_date_time
  440. act = ActMaximumType
  441. phytosanitary_checkpoint = String.customize(
  442. min_occurs=0, max_occurs=1, max_length=255)
  443. phytosanitary_checkpoint_code = Integer.customize(
  444. min_occurs=0, max_occurs=1)
  445. status = status
  446. status_code = status_code
  447. inspector = inspector
  448.  
  449.  
  450. class Request91Type(ComplexModel):
  451. guid = guid
  452. send_date_time = send_date_time
  453. certificate = CertificateMaximumType
  454. status = status
  455. status_code = status_code
  456. inspector = inspector
  457.  
  458.  
  459. class Response11Type(ComplexModel):
  460. guid = guid
  461. send_date_time = send_date_time
  462. certificate = CertificateMaximumType
  463. status = status
  464. status_code = status_code
  465. inspector = inspector
  466.  
  467.  
  468. class Response12Type(ComplexModel):
  469. guid = guid
  470. send_date_time = send_date_time
  471. certificate = CertificateMinimumType
  472. status = status
  473. status_code = status_code
  474. inspector = inspector
  475.  
  476.  
  477. class Response3Type(ComplexModel):
  478. guid = guid
  479. send_date_time = send_date_time
  480. act = ActMinimumType
  481. status = status
  482. status_code = status_code
  483. inspector = inspector
  484.  
  485.  
  486. class Response91Type(ComplexModel):
  487. guid = guid
  488. send_date_time = send_date_time
  489. certificate = CertificateMinimumType
  490. status = status
  491. status_code = status_code
  492. inspector = inspector
  493.  
Advertisement
Add Comment
Please, Sign In to add comment