1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Daaner\NovaPoshta\Traits; |
4
|
|
|
|
5
|
|
|
trait CounterpartyProperty |
6
|
|
|
{ |
7
|
|
|
protected $counterpartyType; |
8
|
|
|
protected $counterpartyProperty; |
9
|
|
|
protected $ownershipForm; |
10
|
|
|
protected $EDRPOU; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Установка типа контрагента. |
14
|
|
|
* |
15
|
|
|
* @param string $counterpartyType Тип контрагента (PrivatePerson) |
16
|
|
|
* @return $this |
17
|
|
|
*/ |
18
|
|
|
public function setCounterpartyType(string $counterpartyType): self |
19
|
|
|
{ |
20
|
|
|
$this->counterpartyType = $counterpartyType; |
21
|
|
|
|
22
|
|
|
return $this; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Установка свойства контрагента. |
27
|
|
|
* |
28
|
|
|
* @param string $counterpartyProperty Свойства контрагента (Recipient / Sender) |
29
|
|
|
* @return $this |
30
|
|
|
*/ |
31
|
|
|
public function setCounterpartyProperty(string $counterpartyProperty): self |
32
|
|
|
{ |
33
|
|
|
$this->counterpartyProperty = $counterpartyProperty; |
34
|
|
|
|
35
|
|
|
return $this; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Установка формы собственности. |
40
|
|
|
* |
41
|
|
|
* @param string $ownershipForm Ref формы собственности |
42
|
|
|
* @return $this |
43
|
|
|
*/ |
44
|
|
|
public function setOwnershipForm(string $ownershipForm): self |
45
|
|
|
{ |
46
|
|
|
$this->ownershipForm = $ownershipForm; |
47
|
|
|
|
48
|
|
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Установка ЕДРПОУ. |
53
|
|
|
* |
54
|
|
|
* @param string $EDRPOU ЕРДПОУ |
55
|
|
|
* @return $this |
56
|
|
|
*/ |
57
|
|
|
public function setEDRPOU(string $EDRPOU): self |
58
|
|
|
{ |
59
|
|
|
$this->EDRPOU = $EDRPOU; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
public function getCounterpartyType(): void |
68
|
|
|
{ |
69
|
|
|
if (! $this->counterpartyType) { |
70
|
|
|
$this->counterpartyType = 'PrivatePerson'; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$this->methodProperties['CounterpartyType'] = $this->counterpartyType; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
public function getCounterpartyProperty(): void |
80
|
|
|
{ |
81
|
|
|
//Сделано для getCounterpartyAddresses, |
82
|
|
|
//однако этот справочник игнорирует СounterpartyProperty в поиске |
83
|
|
|
if ($this->counterpartyProperty == 'All') { |
84
|
|
|
return; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
if (! $this->counterpartyProperty) { |
88
|
|
|
$this->counterpartyProperty = 'Recipient'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$this->methodProperties['CounterpartyProperty'] = $this->counterpartyProperty; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return void |
96
|
|
|
*/ |
97
|
|
|
public function getOwnershipForm(): void |
98
|
|
|
{ |
99
|
|
|
if ($this->ownershipForm) { |
100
|
|
|
$this->methodProperties['OwnershipForm'] = $this->ownershipForm; |
101
|
|
|
$this->methodProperties['CounterpartyType'] = 'Organization'; |
102
|
|
|
$this->makeOrganization(); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return void |
108
|
|
|
*/ |
109
|
|
|
public function getEDRPOU(): void |
110
|
|
|
{ |
111
|
|
|
if ($this->EDRPOU) { |
112
|
|
|
$this->methodProperties['EDRPOU'] = $this->EDRPOU; |
113
|
|
|
$this->methodProperties['CounterpartyProperty'] = 'ThirdPerson'; |
114
|
|
|
$this->makeOrganization(); |
|
|
|
|
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Вынесенная логика для удаления контактов |
120
|
|
|
* используется для создания / изменения данных организаций или третьих лиц. |
121
|
|
|
* |
122
|
|
|
* @deprecated НЕ СДЕЛАНО, сложно проверить |
123
|
|
|
* |
124
|
|
|
* TODO Не сделано |
125
|
|
|
* |
126
|
|
|
* @return void |
127
|
|
|
*/ |
128
|
|
|
public function makeOrganization(): void |
129
|
|
|
{ |
130
|
|
|
//need clear data |
131
|
|
|
// $lastName = ''; |
132
|
|
|
// $middleName = ''; |
133
|
|
|
// $phone = ''; |
134
|
|
|
// $email = ''; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.