|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\SalesBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
|
|
7
|
|
|
use Oro\Bundle\CurrencyBundle\Entity\MultiCurrency; |
|
8
|
|
|
use Oro\Bundle\CurrencyBundle\Entity\MultiCurrencyHolderInterface; |
|
9
|
|
|
use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro; |
|
10
|
|
|
use Oro\Bundle\EmailBundle\Model\EmailHolderInterface; |
|
11
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; |
|
12
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField; |
|
13
|
|
|
use Oro\Bundle\OrganizationBundle\Entity\Organization; |
|
14
|
|
|
use Oro\Bundle\UserBundle\Entity\User; |
|
15
|
|
|
|
|
16
|
|
|
use OroCRM\Bundle\ChannelBundle\Model\ChannelEntityTrait; |
|
17
|
|
|
use OroCRM\Bundle\ContactBundle\Entity\Contact; |
|
18
|
|
|
use OroCRM\Bundle\SalesBundle\Model\ExtendOpportunity; |
|
19
|
|
|
use OroCRM\Bundle\ChannelBundle\Model\ChannelAwareInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @ORM\Entity(repositoryClass="OroCRM\Bundle\SalesBundle\Entity\Repository\OpportunityRepository") |
|
23
|
|
|
* @ORM\Table( |
|
24
|
|
|
* name="orocrm_sales_opportunity", |
|
25
|
|
|
* indexes={@ORM\Index(name="opportunity_created_idx",columns={"created_at"})} |
|
26
|
|
|
* ) |
|
27
|
|
|
* @ORM\HasLifecycleCallbacks() |
|
28
|
|
|
* @Oro\Loggable |
|
29
|
|
|
* @Config( |
|
30
|
|
|
* routeName="orocrm_sales_opportunity_index", |
|
31
|
|
|
* routeView="orocrm_sales_opportunity_view", |
|
32
|
|
|
* defaultValues={ |
|
33
|
|
|
* "entity"={ |
|
34
|
|
|
* "icon"="icon-usd" |
|
35
|
|
|
* }, |
|
36
|
|
|
* "ownership"={ |
|
37
|
|
|
* "owner_type"="USER", |
|
38
|
|
|
* "owner_field_name"="owner", |
|
39
|
|
|
* "owner_column_name"="user_owner_id", |
|
40
|
|
|
* "organization_field_name"="organization", |
|
41
|
|
|
* "organization_column_name"="organization_id" |
|
42
|
|
|
* }, |
|
43
|
|
|
* "security"={ |
|
44
|
|
|
* "type"="ACL", |
|
45
|
|
|
* "group_name"="", |
|
46
|
|
|
* "category"="sales_data", |
|
47
|
|
|
* "field_acl_supported" = "true" |
|
48
|
|
|
* }, |
|
49
|
|
|
* "form"={ |
|
50
|
|
|
* "form_type"="orocrm_sales_opportunity_select", |
|
51
|
|
|
* "grid_name"="sales-opportunity-grid", |
|
52
|
|
|
* }, |
|
53
|
|
|
* "dataaudit"={ |
|
54
|
|
|
* "auditable"=true, |
|
55
|
|
|
* "immutable"=true |
|
56
|
|
|
* }, |
|
57
|
|
|
* "grid"={ |
|
58
|
|
|
* "default"="sales-opportunity-grid", |
|
59
|
|
|
* "context"="sales-opportunity-for-context-grid" |
|
60
|
|
|
* }, |
|
61
|
|
|
* "tag"={ |
|
62
|
|
|
* "enabled"=true |
|
63
|
|
|
* } |
|
64
|
|
|
* } |
|
65
|
|
|
* ) |
|
66
|
|
|
* |
|
67
|
|
|
* @SuppressWarnings(PHPMD.ExcessivePublicCount) |
|
68
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
|
69
|
|
|
*/ |
|
70
|
|
|
class Opportunity extends ExtendOpportunity implements |
|
71
|
|
|
EmailHolderInterface, |
|
72
|
|
|
ChannelAwareInterface, |
|
73
|
|
|
MultiCurrencyHolderInterface |
|
74
|
|
|
{ |
|
75
|
|
|
use ChannelEntityTrait; |
|
76
|
|
|
|
|
77
|
|
|
const INTERNAL_STATUS_CODE = 'opportunity_status'; |
|
78
|
|
|
|
|
79
|
|
|
const STATUS_LOST = 'lost'; |
|
80
|
|
|
const STATUS_WON = 'won'; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* The key in system config for probability - status map |
|
84
|
|
|
*/ |
|
85
|
|
|
const PROBABILITIES_CONFIG_KEY = 'oro_crm_sales.default_opportunity_probabilities'; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @var int |
|
89
|
|
|
* |
|
90
|
|
|
* @ORM\Id |
|
91
|
|
|
* @ORM\Column(type="integer", name="id") |
|
92
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
93
|
|
|
* @ConfigField( |
|
94
|
|
|
* defaultValues={ |
|
95
|
|
|
* "importexport"={ |
|
96
|
|
|
* "order"=0 |
|
97
|
|
|
* } |
|
98
|
|
|
* } |
|
99
|
|
|
* ) |
|
100
|
|
|
*/ |
|
101
|
|
|
protected $id; |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @var OpportunityCloseReason |
|
105
|
|
|
* |
|
106
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\SalesBundle\Entity\OpportunityCloseReason") |
|
107
|
|
|
* @ORM\JoinColumn(name="close_reason_name", referencedColumnName="name") |
|
108
|
|
|
* @Oro\Versioned |
|
109
|
|
|
* @ConfigField( |
|
110
|
|
|
* defaultValues={ |
|
111
|
|
|
* "dataaudit"={"auditable"=true}, |
|
112
|
|
|
* "importexport"={ |
|
113
|
|
|
* "order"=100, |
|
114
|
|
|
* "short"=true |
|
115
|
|
|
* } |
|
116
|
|
|
* } |
|
117
|
|
|
* ) |
|
118
|
|
|
**/ |
|
119
|
|
|
protected $closeReason; |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @var Contact |
|
123
|
|
|
* |
|
124
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\ContactBundle\Entity\Contact", cascade={"persist"}) |
|
125
|
|
|
* @ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="SET NULL") |
|
126
|
|
|
* @Oro\Versioned |
|
127
|
|
|
* @ConfigField( |
|
128
|
|
|
* defaultValues={ |
|
129
|
|
|
* "dataaudit"={"auditable"=true}, |
|
130
|
|
|
* "importexport"={ |
|
131
|
|
|
* "order"=120, |
|
132
|
|
|
* "short"=true |
|
133
|
|
|
* }, |
|
134
|
|
|
* "form"={ |
|
135
|
|
|
* "form_type"="orocrm_contact_select" |
|
136
|
|
|
* } |
|
137
|
|
|
* } |
|
138
|
|
|
* ) |
|
139
|
|
|
**/ |
|
140
|
|
|
protected $contact; |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @var Lead |
|
144
|
|
|
* |
|
145
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\SalesBundle\Entity\Lead", inversedBy="opportunities") |
|
146
|
|
|
* @ORM\JoinColumn(name="lead_id", referencedColumnName="id", onDelete="SET NULL") |
|
147
|
|
|
* @Oro\Versioned |
|
148
|
|
|
* @ConfigField( |
|
149
|
|
|
* defaultValues={ |
|
150
|
|
|
* "dataaudit"={"auditable"=true}, |
|
151
|
|
|
* "importexport"={ |
|
152
|
|
|
* "order"=130, |
|
153
|
|
|
* "short"=true |
|
154
|
|
|
* } |
|
155
|
|
|
* } |
|
156
|
|
|
* ) |
|
157
|
|
|
**/ |
|
158
|
|
|
protected $lead; |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @var User |
|
162
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
|
163
|
|
|
* @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL") |
|
164
|
|
|
* @Oro\Versioned |
|
165
|
|
|
* @ConfigField( |
|
166
|
|
|
* defaultValues={ |
|
167
|
|
|
* "dataaudit"={"auditable"=true, "immutable"=true}, |
|
168
|
|
|
* "importexport"={ |
|
169
|
|
|
* "order"=140, |
|
170
|
|
|
* "short"=true |
|
171
|
|
|
* } |
|
172
|
|
|
* } |
|
173
|
|
|
* ) |
|
174
|
|
|
*/ |
|
175
|
|
|
protected $owner; |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @var string |
|
179
|
|
|
* |
|
180
|
|
|
* @ORM\Column(name="name", type="string", length=255, nullable=false) |
|
181
|
|
|
* @Oro\Versioned |
|
182
|
|
|
* @ConfigField( |
|
183
|
|
|
* defaultValues={ |
|
184
|
|
|
* "dataaudit"={"auditable"=true}, |
|
185
|
|
|
* "importexport"={ |
|
186
|
|
|
* "order"=10, |
|
187
|
|
|
* "identity"=true |
|
188
|
|
|
* } |
|
189
|
|
|
* } |
|
190
|
|
|
* ) |
|
191
|
|
|
*/ |
|
192
|
|
|
protected $name; |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @var \DateTime |
|
196
|
|
|
* |
|
197
|
|
|
* @ORM\Column(name="close_date", type="date", nullable=true) |
|
198
|
|
|
* @Oro\Versioned |
|
199
|
|
|
* @ConfigField( |
|
200
|
|
|
* defaultValues={ |
|
201
|
|
|
* "dataaudit"={"auditable"=true, "immutable"=true}, |
|
202
|
|
|
* "importexport"={ |
|
203
|
|
|
* "order"=20 |
|
204
|
|
|
* } |
|
205
|
|
|
* } |
|
206
|
|
|
* ) |
|
207
|
|
|
*/ |
|
208
|
|
|
protected $closeDate; |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @var float |
|
212
|
|
|
* |
|
213
|
|
|
* @ORM\Column(name="probability", type="percent", nullable=true) |
|
214
|
|
|
* @Oro\Versioned |
|
215
|
|
|
* @ConfigField( |
|
216
|
|
|
* defaultValues={ |
|
217
|
|
|
* "form"={ |
|
218
|
|
|
* "form_type"="oro_percent", |
|
219
|
|
|
* "form_options"={ |
|
220
|
|
|
* "constraints"={{"Range":{"min":0, "max":100}}}, |
|
221
|
|
|
* } |
|
222
|
|
|
* }, |
|
223
|
|
|
* "dataaudit"={"auditable"=true, "immutable"=true}, |
|
224
|
|
|
* "importexport"={ |
|
225
|
|
|
* "order"=30 |
|
226
|
|
|
* } |
|
227
|
|
|
* } |
|
228
|
|
|
* ) |
|
229
|
|
|
*/ |
|
230
|
|
|
protected $probability; |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* Changes to this value object wont affect entity change set |
|
234
|
|
|
* To change persisted price value you should create and set new Multicurrency |
|
235
|
|
|
* |
|
236
|
|
|
* @var Multicurrency |
|
237
|
|
|
*/ |
|
238
|
|
|
protected $budgetAmount; |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* @var string |
|
242
|
|
|
* |
|
243
|
|
|
* @ORM\Column(name="budget_amount_currency", type="currency", length=3, nullable=true) |
|
244
|
|
|
* @Oro\Versioned |
|
245
|
|
|
* @ConfigField( |
|
246
|
|
|
* defaultValues={ |
|
247
|
|
|
* "dataaudit"={"auditable"=true, "immutable"=true}, |
|
248
|
|
|
* "importexport"={ |
|
249
|
|
|
* "order"=55 |
|
250
|
|
|
* } |
|
251
|
|
|
* } |
|
252
|
|
|
* ) |
|
253
|
|
|
*/ |
|
254
|
|
|
protected $budgetAmountCurrency; |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* @var double |
|
258
|
|
|
* |
|
259
|
|
|
* @ORM\Column(name="budget_amount_value", type="money", nullable=true) |
|
260
|
|
|
* @Oro\Versioned |
|
261
|
|
|
* @ConfigField( |
|
262
|
|
|
* defaultValues={ |
|
263
|
|
|
* "form"={ |
|
264
|
|
|
* "form_type"="oro_money", |
|
265
|
|
|
* "form_options"={ |
|
266
|
|
|
* "constraints"={{"Range":{"min":0}}}, |
|
267
|
|
|
* } |
|
268
|
|
|
* }, |
|
269
|
|
|
* "dataaudit"={ |
|
270
|
|
|
* "auditable"=true |
|
271
|
|
|
* }, |
|
272
|
|
|
* "importexport"={ |
|
273
|
|
|
* "order"=50 |
|
274
|
|
|
* } |
|
275
|
|
|
* } |
|
276
|
|
|
* ) |
|
277
|
|
|
*/ |
|
278
|
|
|
protected $budgetAmountValue; |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* Changes to this value object wont affect entity change set |
|
282
|
|
|
* To change persisted price value you should create and set new Multicurrency |
|
283
|
|
|
* |
|
284
|
|
|
* @var Multicurrency |
|
285
|
|
|
*/ |
|
286
|
|
|
protected $closeRevenue; |
|
287
|
|
|
|
|
288
|
|
|
/** |
|
289
|
|
|
* @var string |
|
290
|
|
|
* |
|
291
|
|
|
* @ORM\Column(name="close_revenue_currency", type="currency", length=3, nullable=true) |
|
292
|
|
|
* @Oro\Versioned |
|
293
|
|
|
* @ConfigField( |
|
294
|
|
|
* defaultValues={ |
|
295
|
|
|
* "dataaudit"={"auditable"=true, "immutable"=true}, |
|
296
|
|
|
* "importexport"={ |
|
297
|
|
|
* "order"=65 |
|
298
|
|
|
* } |
|
299
|
|
|
* } |
|
300
|
|
|
* ) |
|
301
|
|
|
*/ |
|
302
|
|
|
protected $closeRevenueCurrency; |
|
303
|
|
|
|
|
304
|
|
|
/** |
|
305
|
|
|
* @var double |
|
306
|
|
|
* |
|
307
|
|
|
* @ORM\Column(name="close_revenue_value", type="money", nullable=true) |
|
308
|
|
|
* @Oro\Versioned |
|
309
|
|
|
* @ConfigField( |
|
310
|
|
|
* defaultValues={ |
|
311
|
|
|
* "form"={ |
|
312
|
|
|
* "form_type"="oro_money", |
|
313
|
|
|
* "form_options"={ |
|
314
|
|
|
* "constraints"={{"Range":{"min":0}}}, |
|
315
|
|
|
* } |
|
316
|
|
|
* }, |
|
317
|
|
|
* "dataaudit"={ |
|
318
|
|
|
* "auditable"=true |
|
319
|
|
|
* }, |
|
320
|
|
|
* "importexport"={ |
|
321
|
|
|
* "order"=60 |
|
322
|
|
|
* } |
|
323
|
|
|
* } |
|
324
|
|
|
* ) |
|
325
|
|
|
*/ |
|
326
|
|
|
protected $closeRevenueValue; |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* @var string |
|
330
|
|
|
* |
|
331
|
|
|
* @ORM\Column(name="customer_need", type="text", nullable=true) |
|
332
|
|
|
* @Oro\Versioned |
|
333
|
|
|
* @ConfigField( |
|
334
|
|
|
* defaultValues={ |
|
335
|
|
|
* "dataaudit"={"auditable"=true}, |
|
336
|
|
|
* "importexport"={ |
|
337
|
|
|
* "order"=60 |
|
338
|
|
|
* } |
|
339
|
|
|
* } |
|
340
|
|
|
* ) |
|
341
|
|
|
*/ |
|
342
|
|
|
protected $customerNeed; |
|
343
|
|
|
|
|
344
|
|
|
/** |
|
345
|
|
|
* @var string |
|
346
|
|
|
* |
|
347
|
|
|
* @ORM\Column(name="proposed_solution", type="text", nullable=true) |
|
348
|
|
|
* @Oro\Versioned |
|
349
|
|
|
* @ConfigField( |
|
350
|
|
|
* defaultValues={ |
|
351
|
|
|
* "dataaudit"={"auditable"=true}, |
|
352
|
|
|
* "importexport"={ |
|
353
|
|
|
* "order"=70 |
|
354
|
|
|
* } |
|
355
|
|
|
* } |
|
356
|
|
|
* ) |
|
357
|
|
|
*/ |
|
358
|
|
|
protected $proposedSolution; |
|
359
|
|
|
|
|
360
|
|
|
/** |
|
361
|
|
|
* @var \DateTime |
|
362
|
|
|
* |
|
363
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
|
364
|
|
|
* @ConfigField( |
|
365
|
|
|
* defaultValues={ |
|
366
|
|
|
* "entity"={ |
|
367
|
|
|
* "label"="oro.ui.created_at" |
|
368
|
|
|
* }, |
|
369
|
|
|
* "importexport"={ |
|
370
|
|
|
* "excluded"=true |
|
371
|
|
|
* } |
|
372
|
|
|
* } |
|
373
|
|
|
* ) |
|
374
|
|
|
*/ |
|
375
|
|
|
protected $createdAt; |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* @var \DateTime |
|
379
|
|
|
* |
|
380
|
|
|
* @ORM\Column(name="updated_at", type="datetime") |
|
381
|
|
|
* @ConfigField( |
|
382
|
|
|
* defaultValues={ |
|
383
|
|
|
* "entity"={ |
|
384
|
|
|
* "label"="oro.ui.updated_at" |
|
385
|
|
|
* }, |
|
386
|
|
|
* "importexport"={ |
|
387
|
|
|
* "excluded"=true |
|
388
|
|
|
* } |
|
389
|
|
|
* } |
|
390
|
|
|
* ) |
|
391
|
|
|
*/ |
|
392
|
|
|
protected $updatedAt; |
|
393
|
|
|
|
|
394
|
|
|
/** |
|
395
|
|
|
* @var string |
|
396
|
|
|
* |
|
397
|
|
|
* @ORM\Column(name="notes", type="text", nullable=true) |
|
398
|
|
|
* @Oro\Versioned |
|
399
|
|
|
* @ConfigField( |
|
400
|
|
|
* defaultValues={ |
|
401
|
|
|
* "dataaudit"={ |
|
402
|
|
|
* "auditable"=true |
|
403
|
|
|
* }, |
|
404
|
|
|
* "importexport"={ |
|
405
|
|
|
* "order"=80 |
|
406
|
|
|
* } |
|
407
|
|
|
* } |
|
408
|
|
|
* ) |
|
409
|
|
|
*/ |
|
410
|
|
|
protected $notes; |
|
411
|
|
|
|
|
412
|
|
|
/** |
|
413
|
|
|
* @var Organization |
|
414
|
|
|
* |
|
415
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") |
|
416
|
|
|
* @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL") |
|
417
|
|
|
*/ |
|
418
|
|
|
protected $organization; |
|
419
|
|
|
|
|
420
|
|
|
/** |
|
421
|
|
|
* @var B2bCustomer |
|
422
|
|
|
* |
|
423
|
|
|
* @ORM\ManyToOne( |
|
424
|
|
|
* targetEntity="OroCRM\Bundle\SalesBundle\Entity\B2bCustomer", |
|
425
|
|
|
* inversedBy="opportunities", |
|
426
|
|
|
* cascade={"persist"} |
|
427
|
|
|
* ) |
|
428
|
|
|
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="SET NULL") |
|
429
|
|
|
* @Oro\Versioned |
|
430
|
|
|
* @ConfigField( |
|
431
|
|
|
* defaultValues={ |
|
432
|
|
|
* "dataaudit"={"auditable"=true}, |
|
433
|
|
|
* "importexport"={ |
|
434
|
|
|
* "order"=110, |
|
435
|
|
|
* "short"=true |
|
436
|
|
|
* }, |
|
437
|
|
|
* "form"={ |
|
438
|
|
|
* "form_type"="orocrm_sales_b2bcustomer_select" |
|
439
|
|
|
* } |
|
440
|
|
|
* } |
|
441
|
|
|
* ) |
|
442
|
|
|
*/ |
|
443
|
|
|
protected $customer; |
|
444
|
|
|
|
|
445
|
|
|
/** |
|
446
|
|
|
* @var \DateTime |
|
447
|
|
|
* |
|
448
|
|
|
* @ORM\Column(type="datetime", name="closed_at", nullable=true) |
|
449
|
|
|
* @ConfigField( |
|
450
|
|
|
* defaultValues={ |
|
451
|
|
|
* "dataaudit"={"auditable"=true, "immutable"=true}, |
|
452
|
|
|
* "importexport"={"excluded"=true, "immutable"=true} |
|
453
|
|
|
* } |
|
454
|
|
|
* ) |
|
455
|
|
|
*/ |
|
456
|
|
|
protected $closedAt; |
|
457
|
|
|
|
|
458
|
|
|
/** |
|
459
|
|
|
* @return int |
|
460
|
|
|
*/ |
|
461
|
|
|
public function getId() |
|
462
|
|
|
{ |
|
463
|
|
|
return $this->id; |
|
464
|
|
|
} |
|
465
|
|
|
|
|
466
|
|
|
/** |
|
467
|
|
|
* @param Lead $lead |
|
468
|
|
|
* @return Opportunity |
|
469
|
|
|
*/ |
|
470
|
|
|
public function setLead($lead) |
|
471
|
|
|
{ |
|
472
|
|
|
$this->lead = $lead; |
|
473
|
|
|
|
|
474
|
|
|
return $this; |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* @return Lead |
|
479
|
|
|
*/ |
|
480
|
|
|
public function getLead() |
|
481
|
|
|
{ |
|
482
|
|
|
return $this->lead; |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* @return MultiCurrency|null |
|
487
|
|
|
*/ |
|
488
|
|
|
public function getBudgetAmount() |
|
489
|
|
|
{ |
|
490
|
|
|
return $this->budgetAmount; |
|
491
|
|
|
} |
|
492
|
|
|
|
|
493
|
|
|
/** |
|
494
|
|
|
* @param MultiCurrency $budgetAmount|null |
|
|
|
|
|
|
495
|
|
|
* @return Opportunity |
|
496
|
|
|
*/ |
|
497
|
|
|
public function setBudgetAmount(MultiCurrency $budgetAmount = null) |
|
498
|
|
|
{ |
|
499
|
|
|
$this->budgetAmount = $budgetAmount; |
|
|
|
|
|
|
500
|
|
|
$this->updateMultiCurrencyFields(); |
|
501
|
|
|
|
|
502
|
|
|
return $this; |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
/** |
|
506
|
|
|
* @ORM\PostLoad |
|
507
|
|
|
*/ |
|
508
|
|
|
public function loadMultiCurrencyFields() |
|
509
|
|
|
{ |
|
510
|
|
|
$this->budgetAmount = MultiCurrency::create($this->budgetAmountValue, $this->budgetAmountCurrency); |
|
511
|
|
|
$this->closeRevenue = MultiCurrency::create($this->closeRevenueValue, $this->closeRevenueCurrency); |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
/** |
|
515
|
|
|
* @ORM\PrePersist |
|
516
|
|
|
* @ORM\PreUpdate |
|
517
|
|
|
* |
|
518
|
|
|
* @return void |
|
519
|
|
|
*/ |
|
520
|
|
|
public function updateMultiCurrencyFields() |
|
521
|
|
|
{ |
|
522
|
|
|
if ($this->budgetAmount) { |
|
523
|
|
|
$this->budgetAmountValue = $this->budgetAmount->getValue(); |
|
524
|
|
|
$currency = $this->budgetAmount->getValue() !== null ? |
|
525
|
|
|
$this->budgetAmount->getCurrency() : |
|
526
|
|
|
null; |
|
527
|
|
|
$this->budgetAmountCurrency = $currency; |
|
528
|
|
|
} |
|
529
|
|
|
if ($this->closeRevenue) { |
|
530
|
|
|
$this->closeRevenueValue = $this->closeRevenue->getValue(); |
|
531
|
|
|
$currency = $this->closeRevenue->getValue() !== null ? |
|
532
|
|
|
$this->closeRevenue->getCurrency() : |
|
533
|
|
|
null; |
|
534
|
|
|
$this->closeRevenueCurrency = $currency; |
|
535
|
|
|
} |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
/** |
|
539
|
|
|
* @param string $currency |
|
540
|
|
|
* @return Opportunity |
|
541
|
|
|
*/ |
|
542
|
|
|
public function setBudgetAmountCurrency($currency) |
|
543
|
|
|
{ |
|
544
|
|
|
$this->budgetAmountCurrency = $currency; |
|
545
|
|
|
|
|
546
|
|
|
if ($this->budgetAmount instanceof MultiCurrency) { |
|
|
|
|
|
|
547
|
|
|
$this->budgetAmount->setCurrency($currency); |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
|
|
return $this; |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
/** |
|
554
|
|
|
* @param string $budgetAmountValue |
|
555
|
|
|
* @return Opportunity |
|
556
|
|
|
*/ |
|
557
|
|
|
public function setBudgetAmountValue($budgetAmountValue) |
|
558
|
|
|
{ |
|
559
|
|
|
$this->budgetAmountValue = $budgetAmountValue; |
|
|
|
|
|
|
560
|
|
|
|
|
561
|
|
|
if ($this->budgetAmount instanceof MultiCurrency) { |
|
|
|
|
|
|
562
|
|
|
$this->budgetAmount->setValue($budgetAmountValue); |
|
563
|
|
|
} |
|
564
|
|
|
|
|
565
|
|
|
return $this; |
|
566
|
|
|
} |
|
567
|
|
|
|
|
568
|
|
|
/** |
|
569
|
|
|
* @return string |
|
570
|
|
|
*/ |
|
571
|
|
|
public function getBudgetAmountCurrency() |
|
572
|
|
|
{ |
|
573
|
|
|
return $this->budgetAmountCurrency; |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
/** |
|
577
|
|
|
* @return float |
|
578
|
|
|
*/ |
|
579
|
|
|
public function getBudgetAmountValue() |
|
580
|
|
|
{ |
|
581
|
|
|
return $this->budgetAmountValue; |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
/** |
|
585
|
|
|
* @param string $currency |
|
586
|
|
|
* @return Opportunity |
|
587
|
|
|
*/ |
|
588
|
|
|
public function setCloseRevenueCurrency($currency) |
|
589
|
|
|
{ |
|
590
|
|
|
$this->closeRevenueCurrency = $currency; |
|
591
|
|
|
|
|
592
|
|
|
if ($this->closeRevenue instanceof MultiCurrency) { |
|
|
|
|
|
|
593
|
|
|
$this->closeRevenue->setCurrency($currency); |
|
594
|
|
|
} |
|
595
|
|
|
|
|
596
|
|
|
return $this; |
|
597
|
|
|
} |
|
598
|
|
|
|
|
599
|
|
|
/** |
|
600
|
|
|
* @param float $closeRevenueValue |
|
601
|
|
|
* @return Opportunity |
|
602
|
|
|
*/ |
|
603
|
|
|
public function setCloseRevenueValue($closeRevenueValue) |
|
604
|
|
|
{ |
|
605
|
|
|
$this->closeRevenueValue = $closeRevenueValue; |
|
606
|
|
|
|
|
607
|
|
|
if ($this->closeRevenue instanceof MultiCurrency) { |
|
|
|
|
|
|
608
|
|
|
$this->closeRevenue->setValue($closeRevenueValue); |
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
return $this; |
|
612
|
|
|
} |
|
613
|
|
|
|
|
614
|
|
|
/** |
|
615
|
|
|
* @return string |
|
616
|
|
|
*/ |
|
617
|
|
|
public function getCloseRevenueCurrency() |
|
618
|
|
|
{ |
|
619
|
|
|
return $this->closeRevenueCurrency; |
|
620
|
|
|
} |
|
621
|
|
|
|
|
622
|
|
|
/** |
|
623
|
|
|
* @return float |
|
624
|
|
|
*/ |
|
625
|
|
|
public function getCloseRevenueValue() |
|
626
|
|
|
{ |
|
627
|
|
|
return $this->closeRevenueValue; |
|
628
|
|
|
} |
|
629
|
|
|
|
|
630
|
|
|
/** |
|
631
|
|
|
* @param \DateTime $closeDate |
|
632
|
|
|
* @return Opportunity |
|
633
|
|
|
*/ |
|
634
|
|
|
public function setCloseDate($closeDate) |
|
635
|
|
|
{ |
|
636
|
|
|
$this->closeDate = $closeDate; |
|
637
|
|
|
|
|
638
|
|
|
return $this; |
|
639
|
|
|
} |
|
640
|
|
|
|
|
641
|
|
|
/** |
|
642
|
|
|
* @return \DateTime |
|
643
|
|
|
*/ |
|
644
|
|
|
public function getCloseDate() |
|
645
|
|
|
{ |
|
646
|
|
|
return $this->closeDate; |
|
647
|
|
|
} |
|
648
|
|
|
|
|
649
|
|
|
/** |
|
650
|
|
|
* @param Contact $contact |
|
651
|
|
|
* @return Opportunity |
|
652
|
|
|
*/ |
|
653
|
|
|
public function setContact($contact) |
|
654
|
|
|
{ |
|
655
|
|
|
$this->contact = $contact; |
|
656
|
|
|
|
|
657
|
|
|
return $this; |
|
658
|
|
|
} |
|
659
|
|
|
|
|
660
|
|
|
/** |
|
661
|
|
|
* @return Contact |
|
662
|
|
|
*/ |
|
663
|
|
|
public function getContact() |
|
664
|
|
|
{ |
|
665
|
|
|
return $this->contact; |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
/** |
|
669
|
|
|
* @param string $customerNeed |
|
670
|
|
|
* @return Opportunity |
|
671
|
|
|
*/ |
|
672
|
|
|
public function setCustomerNeed($customerNeed) |
|
673
|
|
|
{ |
|
674
|
|
|
$this->customerNeed = $customerNeed; |
|
675
|
|
|
|
|
676
|
|
|
return $this; |
|
677
|
|
|
} |
|
678
|
|
|
|
|
679
|
|
|
/** |
|
680
|
|
|
* @return string |
|
681
|
|
|
*/ |
|
682
|
|
|
public function getCustomerNeed() |
|
683
|
|
|
{ |
|
684
|
|
|
return $this->customerNeed; |
|
685
|
|
|
} |
|
686
|
|
|
|
|
687
|
|
|
/** |
|
688
|
|
|
* @param float $probability |
|
689
|
|
|
* @return Opportunity |
|
690
|
|
|
*/ |
|
691
|
|
|
public function setProbability($probability) |
|
692
|
|
|
{ |
|
693
|
|
|
$this->probability = $probability; |
|
694
|
|
|
|
|
695
|
|
|
return $this; |
|
696
|
|
|
} |
|
697
|
|
|
|
|
698
|
|
|
/** |
|
699
|
|
|
* @return float |
|
700
|
|
|
*/ |
|
701
|
|
|
public function getProbability() |
|
702
|
|
|
{ |
|
703
|
|
|
return $this->probability; |
|
704
|
|
|
} |
|
705
|
|
|
|
|
706
|
|
|
/** |
|
707
|
|
|
* @param string $proposedSolution |
|
708
|
|
|
* @return Opportunity |
|
709
|
|
|
*/ |
|
710
|
|
|
public function setProposedSolution($proposedSolution) |
|
711
|
|
|
{ |
|
712
|
|
|
$this->proposedSolution = $proposedSolution; |
|
713
|
|
|
|
|
714
|
|
|
return $this; |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
/** |
|
718
|
|
|
* @return string |
|
719
|
|
|
*/ |
|
720
|
|
|
public function getProposedSolution() |
|
721
|
|
|
{ |
|
722
|
|
|
return $this->proposedSolution; |
|
723
|
|
|
} |
|
724
|
|
|
|
|
725
|
|
|
/** |
|
726
|
|
|
* @param string $name |
|
727
|
|
|
* @return Opportunity |
|
728
|
|
|
*/ |
|
729
|
|
|
public function setName($name) |
|
730
|
|
|
{ |
|
731
|
|
|
$this->name = $name; |
|
732
|
|
|
|
|
733
|
|
|
return $this; |
|
734
|
|
|
} |
|
735
|
|
|
|
|
736
|
|
|
/** |
|
737
|
|
|
* @return string |
|
738
|
|
|
*/ |
|
739
|
|
|
public function getName() |
|
740
|
|
|
{ |
|
741
|
|
|
return $this->name; |
|
742
|
|
|
} |
|
743
|
|
|
|
|
744
|
|
|
/** |
|
745
|
|
|
* @param OpportunityCloseReason $closeReason |
|
746
|
|
|
* @return Opportunity |
|
747
|
|
|
*/ |
|
748
|
|
|
public function setCloseReason($closeReason) |
|
749
|
|
|
{ |
|
750
|
|
|
$this->closeReason = $closeReason; |
|
751
|
|
|
|
|
752
|
|
|
return $this; |
|
753
|
|
|
} |
|
754
|
|
|
|
|
755
|
|
|
/** |
|
756
|
|
|
* @return OpportunityCloseReason |
|
757
|
|
|
*/ |
|
758
|
|
|
public function getCloseReason() |
|
759
|
|
|
{ |
|
760
|
|
|
return $this->closeReason; |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
/** |
|
764
|
|
|
* @param MultiCurrency $closeRevenue|null |
|
|
|
|
|
|
765
|
|
|
* @return Opportunity |
|
766
|
|
|
*/ |
|
767
|
|
|
public function setCloseRevenue(MultiCurrency $closeRevenue = null) |
|
768
|
|
|
{ |
|
769
|
|
|
if ($closeRevenue) { |
|
770
|
|
|
$this->closeRevenue = $closeRevenue; |
|
|
|
|
|
|
771
|
|
|
$this->updateMultiCurrencyFields(); |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
return $this; |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
/** |
|
778
|
|
|
* @return MultiCurrency|null |
|
779
|
|
|
*/ |
|
780
|
|
|
public function getCloseRevenue() |
|
781
|
|
|
{ |
|
782
|
|
|
return $this->closeRevenue; |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
/** |
|
786
|
|
|
* @return \DateTime |
|
787
|
|
|
*/ |
|
788
|
|
|
public function getCreatedAt() |
|
789
|
|
|
{ |
|
790
|
|
|
return $this->createdAt; |
|
791
|
|
|
} |
|
792
|
|
|
|
|
793
|
|
|
/** |
|
794
|
|
|
* @param \DateTime $created |
|
795
|
|
|
* @return Opportunity |
|
796
|
|
|
*/ |
|
797
|
|
|
public function setCreatedAt($created) |
|
798
|
|
|
{ |
|
799
|
|
|
$this->createdAt = $created; |
|
800
|
|
|
|
|
801
|
|
|
return $this; |
|
802
|
|
|
} |
|
803
|
|
|
|
|
804
|
|
|
/** |
|
805
|
|
|
* @return \DateTime |
|
806
|
|
|
*/ |
|
807
|
|
|
public function getUpdatedAt() |
|
808
|
|
|
{ |
|
809
|
|
|
return $this->updatedAt; |
|
810
|
|
|
} |
|
811
|
|
|
|
|
812
|
|
|
/** |
|
813
|
|
|
* @param \DateTime $updated |
|
814
|
|
|
* @return Opportunity |
|
815
|
|
|
*/ |
|
816
|
|
|
public function setUpdatedAt($updated) |
|
817
|
|
|
{ |
|
818
|
|
|
$this->updatedAt = $updated; |
|
819
|
|
|
|
|
820
|
|
|
return $this; |
|
821
|
|
|
} |
|
822
|
|
|
|
|
823
|
|
|
/** |
|
824
|
|
|
* Get the primary email address of the related contact |
|
825
|
|
|
* |
|
826
|
|
|
* @return string |
|
827
|
|
|
*/ |
|
828
|
|
|
public function getEmail() |
|
829
|
|
|
{ |
|
830
|
|
|
$contact = $this->getContact(); |
|
831
|
|
|
if (!$contact) { |
|
832
|
|
|
return null; |
|
833
|
|
|
} |
|
834
|
|
|
|
|
835
|
|
|
return $contact->getEmail(); |
|
836
|
|
|
} |
|
837
|
|
|
|
|
838
|
|
|
public function __toString() |
|
839
|
|
|
{ |
|
840
|
|
|
return (string) $this->getName(); |
|
|
|
|
|
|
841
|
|
|
} |
|
842
|
|
|
/** |
|
843
|
|
|
* @ORM\PrePersist |
|
844
|
|
|
*/ |
|
845
|
|
|
public function beforeSave() |
|
846
|
|
|
{ |
|
847
|
|
|
$this->createdAt = new \DateTime('now', new \DateTimeZone('UTC')); |
|
848
|
|
|
$this->beforeUpdate(); |
|
849
|
|
|
} |
|
850
|
|
|
|
|
851
|
|
|
/** |
|
852
|
|
|
* @ORM\PreUpdate |
|
853
|
|
|
*/ |
|
854
|
|
|
public function beforeUpdate() |
|
855
|
|
|
{ |
|
856
|
|
|
$this->updatedAt = new \DateTime('now', new \DateTimeZone('UTC')); |
|
857
|
|
|
} |
|
858
|
|
|
|
|
859
|
|
|
/** |
|
860
|
|
|
* @return User |
|
861
|
|
|
*/ |
|
862
|
|
|
public function getOwner() |
|
863
|
|
|
{ |
|
864
|
|
|
return $this->owner; |
|
865
|
|
|
} |
|
866
|
|
|
|
|
867
|
|
|
/** |
|
868
|
|
|
* @param User $owningUser |
|
869
|
|
|
* @return Opportunity |
|
870
|
|
|
*/ |
|
871
|
|
|
public function setOwner($owningUser) |
|
872
|
|
|
{ |
|
873
|
|
|
$this->owner = $owningUser; |
|
874
|
|
|
|
|
875
|
|
|
return $this; |
|
876
|
|
|
} |
|
877
|
|
|
|
|
878
|
|
|
/** |
|
879
|
|
|
* @return string |
|
880
|
|
|
*/ |
|
881
|
|
|
public function getNotes() |
|
882
|
|
|
{ |
|
883
|
|
|
return $this->notes; |
|
884
|
|
|
} |
|
885
|
|
|
|
|
886
|
|
|
/** |
|
887
|
|
|
* @param string $notes |
|
888
|
|
|
* @return Opportunity |
|
889
|
|
|
*/ |
|
890
|
|
|
public function setNotes($notes) |
|
891
|
|
|
{ |
|
892
|
|
|
$this->notes = $notes; |
|
893
|
|
|
|
|
894
|
|
|
return $this; |
|
895
|
|
|
} |
|
896
|
|
|
|
|
897
|
|
|
/** |
|
898
|
|
|
* @param B2bCustomer $customer |
|
899
|
|
|
* @TODO remove null after BAP-5248 |
|
900
|
|
|
*/ |
|
901
|
|
|
public function setCustomer(B2bCustomer $customer = null) |
|
902
|
|
|
{ |
|
903
|
|
|
$this->customer = $customer; |
|
904
|
|
|
} |
|
905
|
|
|
|
|
906
|
|
|
/** |
|
907
|
|
|
* @return B2bCustomer |
|
908
|
|
|
*/ |
|
909
|
|
|
public function getCustomer() |
|
910
|
|
|
{ |
|
911
|
|
|
return $this->customer; |
|
912
|
|
|
} |
|
913
|
|
|
|
|
914
|
|
|
/** |
|
915
|
|
|
* Set organization |
|
916
|
|
|
* |
|
917
|
|
|
* @param Organization $organization |
|
918
|
|
|
* @return Opportunity |
|
919
|
|
|
*/ |
|
920
|
|
|
public function setOrganization(Organization $organization = null) |
|
921
|
|
|
{ |
|
922
|
|
|
$this->organization = $organization; |
|
923
|
|
|
|
|
924
|
|
|
return $this; |
|
925
|
|
|
} |
|
926
|
|
|
|
|
927
|
|
|
/** |
|
928
|
|
|
* Get organization |
|
929
|
|
|
* |
|
930
|
|
|
* @return Organization |
|
931
|
|
|
*/ |
|
932
|
|
|
public function getOrganization() |
|
933
|
|
|
{ |
|
934
|
|
|
return $this->organization; |
|
935
|
|
|
} |
|
936
|
|
|
|
|
937
|
|
|
/** |
|
938
|
|
|
* Remove Customer |
|
939
|
|
|
* |
|
940
|
|
|
* @return Lead |
|
941
|
|
|
*/ |
|
942
|
|
|
public function removeCustomer() |
|
943
|
|
|
{ |
|
944
|
|
|
$this->customer = null; |
|
945
|
|
|
} |
|
946
|
|
|
|
|
947
|
|
|
/** |
|
948
|
|
|
* @param \DateTime $closedAt |
|
949
|
|
|
*/ |
|
950
|
|
|
public function setClosedAt(\DateTime $closedAt = null) |
|
951
|
|
|
{ |
|
952
|
|
|
$this->closedAt = $closedAt; |
|
953
|
|
|
} |
|
954
|
|
|
|
|
955
|
|
|
/** |
|
956
|
|
|
* @return \DateTime |
|
957
|
|
|
*/ |
|
958
|
|
|
public function getClosedAt() |
|
959
|
|
|
{ |
|
960
|
|
|
return $this->closedAt; |
|
961
|
|
|
} |
|
962
|
|
|
} |
|
963
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.