2 namespace Stock\DataBin;
9 class Stock extends \Workspace\Service\DataBin
15 protected $meta = array(
17 'DatasetName' => 'stock',
18 'Entity' => '\Stock\Entity\Stock',
19 'References' => array(
20 'region' => '\Location\Entity\Region',
21 'type' => '\Stock\Entity\Type',
22 'fuelType' => '\Stock\Entity\FuelType',
23 'transmissionType' => '\Stock\Entity\TransmissionType',
24 'exteriorColour' => '\Stock\Entity\ExteriorColour',
25 'interiorColour' => '\Stock\Entity\InteriorColour',
26 'condition' => '\Stock\Entity\Condition',
27 'vehicleYear' => '\Stock\Entity\Year',
28 'upholstery' => '\Stock\Entity\Upholstery',
29 'papers' => '\Stock\Entity\Paper',
30 'natis' => '\Stock\Entity\Natis',
31 'fullServiceHistory' => '\Stock\Entity\FullServiceHistory',
32 'mainImage' => '\Utility\Entity\Image',
33 'frontImage' => '\Utility\Entity\Image',
34 'rightImage' => '\Utility\Entity\Image',
35 'leftImage' => '\Utility\Entity\Image',
36 'backImage' => '\Utility\Entity\Image',
37 'interiorImage' => '\Utility\Entity\Image',
38 'engineImage' => '\Utility\Entity\Image',
39 'natisImage' => '\Utility\Entity\Image'
41 'Dependants' => array(
42 'accessories' => '\Stock\Entity\Accessory'
48 protected $metaList = array(
50 'Contract' => 'Recurring',
51 'RequiredInput' => array(),
52 'OptionalInput' => array(
57 'referenceNumber' => 'String12',
62 'stockNumber' => 'String15',
63 'registrationNumber' => 'String15',
64 'vinNumber' => 'String40',
65 'engineNumber' => 'String40',
67 'transmissionType' => 'Id',
68 'exteriorColour' => 'Id',
69 'interiorColour' => 'Id',
71 'vehicleYear' => 'Id',
76 'spareKeys' => 'Boolean',
77 'fullServiceHistory' => 'Id',
78 'tradePrice' => 'Decimal',
79 'retailPrice' => 'Decimal',
80 'listPrice' => 'Decimal',
81 'retailAmountRequired' => 'Decimal',
82 'purchasePrice' => 'Decimal',
83 'salePrice' => 'Decimal',
84 'previousRepairsNotes' => 'String500',
85 'previousRepairsNoted' => 'Boolean',
86 'jobState' => 'String25',
87 'makeManual' => 'String150',
88 'modelManual' => 'String150',
89 'typeManual' => 'String150'
96 'introYear', 'introMonth',
97 'discYear', 'discMonth'
104 protected $metaGrid = array(
107 'Builder' => '\Stock\Report\StockGrid',
108 'Writer' => '\Utility\Export\ExcelReport',
109 'Output' => 'Download',
110 'Contract' => 'Recurring',
113 'ExportToExcel' => false
116 'RequiredInput' => array(),
117 'OptionalInput' => array(
119 'NumberOfRecords' => 'Integer',
122 'OrderBy' => 'Array',
126 'NumberOfRecords' => 20,
127 'Query' => 'SELECT [SELECTION]
128 FROM \Stock\Entity\Stock stock
129 JOIN stock.company company
130 JOIN stock.vehicleYear vehicleYear
132 JOIN type.model model
134 LEFT JOIN stock.auction auction
135 LEFT JOIN stock.valuation valuation
136 LEFT JOIN stock.priceGuide priceGuide
137 LEFT JOIN company.group companyGroup
138 LEFT JOIN company.groupDivision groupDivision
139 LEFT JOIN stock.exteriorColour exteriorColour
141 'Selection' => 'stock, valuation, company, companyGroup, groupDivision, auction, priceGuide, exteriorColour, vehicleYear, make, model, type',
143 'stock.archived' => false,
144 'stock.jobState' => '!=Valuation'
146 'OrderBy' => array('stock.created' => 'DESC'),
150 'created' => 'DateTime',
151 'registrationNumber',
163 'vehicleYear' => array(
166 'exteriorColour' => array(
169 'priceGuide' => array(
172 'valuation' => array(
182 'retailAmountRequired',
192 protected $metaTradeCenterGrid = array(
195 'Builder' => '\Stock\Report\StockGrid',
196 'Writer' => '\Utility\Export\ExcelReport',
197 'Output' => 'Download',
198 'Contract' => 'Recurring',
201 'ExportToExcel' => false
204 'RequiredInput' => array(),
205 'OptionalInput' => array(
207 'NumberOfRecords' => 'Integer',
210 'OrderBy' => 'Array',
214 'NumberOfRecords' => 10,
215 'Query' => 'SELECT [SELECTION]
216 FROM \Stock\Entity\Stock stock
217 JOIN stock.company company
218 JOIN stock.vehicleYear vehicleYear
220 JOIN type.model model
222 LEFT JOIN stock.auction auction
223 LEFT JOIN stock.valuation valuation
224 LEFT JOIN company.group companyGroup
225 LEFT JOIN company.groupDivision groupDivision
226 LEFT JOIN stock.exteriorColour exteriorColour
228 'Selection' => 'stock, valuation, company, companyGroup, groupDivision, auction, exteriorColour, vehicleYear, make, model, type',
230 'stock.archived' => false,
231 'stock.jobState' => 'IN Trade Center,Auction,Sold'
233 'OrderBy' => array('stock.created' => 'DESC'),
237 'created' => 'DateTime',
238 'registrationNumber',
253 'vehicleYear' => array(
256 'valuation' => array(
266 'retailAmountRequired',
275 protected $metaView = array(
284 'Intersect' => array()
289 protected $metaCreate = array(
291 'Contract' => 'Recurring',
292 'ExecuteBefore' => array(
295 'ExecuteAfter' => array(
296 'generateHistoryList',
299 'RequiredInput' => array(
301 'vehicleYear' => 'Id',
302 'stockNumber' => 'String15',
303 'registrationNumber' => 'String15',
305 'transmissionType' => 'Id'
308 'OptionalInput' => array(
315 'vinNumber' => 'String40',
316 'engineNumber' => 'String40',
317 'exteriorColour' => 'Id',
318 'interiorColour' => 'Id',
321 'upholstery' => 'Id',
324 'spareKeys' => 'Boolean',
325 'fullServiceHistory' => 'Id',
326 'fshNotes' => 'String500',
327 'tradePrice' => 'Decimal',
328 'retailPrice' => 'Decimal',
329 'listPrice' => 'Decimal',
330 'retailAmountRequired' => 'Decimal',
331 'purchasePrice' => 'Decimal',
332 'salePrice' => 'Decimal',
334 'frontImage' => 'Id',
335 'rightImage' => 'Id',
338 'interiorImage' => 'Id',
339 'engineImage' => 'Id',
340 'natisImage' => 'Id',
341 'accessories' => 'Collection',
342 'accessoryNotes' => 'String500',
343 'damages' => 'Collection',
344 'damageTotal' => 'Decimal',
345 'previousRepairsNoted' => 'Boolean',
346 'previousRepairsNotes' => 'String500',
347 'damageNotes' => 'String500',
348 'coverReceived' => 'String500',
349 'makeManual' => 'String150',
350 'modelManual' => 'String150',
351 'typeManual' => 'String150'
360 protected $metaCreateAuction = array(
362 'Contract' => 'Recurring',
363 'ExecuteBefore' => array(
366 'ExecuteAfter' => array(
367 'generateHistoryList',
371 'NewStockItem.Status' => 'Auction.NewItemFromStock'
373 'RequiredInput' => array(
376 'reservePrice' => 'Decimal'
379 'vehicleYear' => 'Id',
380 'stockNumber' => 'String15',
381 'registrationNumber' => 'String15',
383 'transmissionType' => 'Id'
386 'OptionalInput' => array(
393 'vinNumber' => 'String40',
394 'engineNumber' => 'String40',
395 'exteriorColour' => 'Id',
396 'interiorColour' => 'Id',
399 'upholstery' => 'Id',
402 'spareKeys' => 'Boolean',
403 'fullServiceHistory' => 'Id',
404 'fshNotes' => 'String500',
405 'tradePrice' => 'Decimal',
406 'retailPrice' => 'Decimal',
407 'listPrice' => 'Decimal',
408 'retailAmountRequired' => 'Decimal',
409 'purchasePrice' => 'Decimal',
410 'salePrice' => 'Decimal',
412 'frontImage' => 'Id',
413 'rightImage' => 'Id',
416 'interiorImage' => 'Id',
417 'engineImage' => 'Id',
418 'natisImage' => 'Id',
419 'accessories' => 'Collection',
420 'accessoryNotes' => 'String500',
421 'damages' => 'Collection',
422 'damageTotal' => 'Decimal',
423 'previousRepairsNoted' => 'Boolean',
424 'previousRepairsNotes' => 'String500',
425 'damageNotes' => 'String500',
426 'coverReceived' => 'String500',
427 'makeManual' => 'String150',
428 'modelManual' => 'String150',
429 'typeManual' => 'String150'
436 protected $metaUpdate = array(
438 'Contract' => 'UseOnce',
454 'ExecuteBefore' => array(
455 'updateCustomVehicles'
457 'ExecuteAfter' => array(
460 'RequiredInput' => array(
462 'vehicleYear' => 'Id',
463 'stockNumber' => 'String15',
464 'registrationNumber' => 'String15',
466 'transmissionType' => 'Id'
469 'OptionalInput' => array(
476 'vinNumber' => 'String40',
477 'engineNumber' => 'String40',
478 'exteriorColour' => 'Id',
479 'interiorColour' => 'Id',
482 'upholstery' => 'Id',
485 'spareKeys' => 'Boolean',
486 'fullServiceHistory' => 'Id',
487 'fshNotes' => 'String500',
488 'tradePrice' => 'Decimal',
489 'retailPrice' => 'Decimal',
490 'listPrice' => 'Decimal',
491 'oldTradePrice' => 'Decimal',
492 'oldRetailPrice' => 'Decimal',
493 'oldListPrice' => 'Decimal',
494 'retailAmountRequired' => 'Decimal',
495 'purchasePrice' => 'Decimal',
496 'salePrice' => 'Decimal',
498 'frontImage' => 'Id',
499 'rightImage' => 'Id',
502 'interiorImage' => 'Id',
503 'engineImage' => 'Id',
504 'natisImage' => 'Id',
505 'accessories' => 'Collection',
506 'accessoryNotes' => 'String500',
507 'damages' => 'Collection',
508 'damageTotal' => 'Decimal',
509 'previousRepairsNoted' => 'Boolean',
510 'previousRepairsNotes' => 'String500',
511 'damageNotes' => 'String500',
512 'coverReceived' => 'String500',
513 'makeManual' => 'String150',
514 'modelManual' => 'String150',
515 'typeManual' => 'String150'
522 protected $metaLimitedUpdate = array(
524 'Contract' => 'UseOnce',
525 'ExecuteBefore' => array(
526 'updateCustomVehicles'
528 'ExecuteAfter' => array(
547 'RequiredInput' => array(),
548 'OptionalInput' => array()
553 protected $metaDelete = array(
555 'Contract' => 'UseOnce',
556 'ExecuteAfter' => array(
563 protected $metaSendToRetail = array(
565 'Contract' => 'UseOnce',
566 'ExecuteAfter' => array(
569 'RequiredInput' => array(
571 'retailOutlets' => 'Array'
574 'minimumAmount' => 'Decimal'
577 'OptionalInput' => array()
582 protected $metaRouteSendToRetail = array(
584 'Contract' => 'UseOnce',
585 'Destination' => 'Retail.NewItemFromStock',
586 'Surrogate' => 'metaSendToRetail'
591 protected $metaRouteSendToPriceGuide = array(
593 'Contract' => 'UseOnce',
594 'Destination' => 'PriceGuide.NewItemFromStock',
595 'ExecuteAfter' => array(
598 'RequiredInput' => array(
603 'OptionalInput' => array()
608 protected $metaRouteSendToAuction = array(
610 'Contract' => 'UseOnce',
611 'Destination' => 'Auction.NewItemFromStock',
612 'ExecuteAfter' => array(
615 'RequiredInput' => array(
618 'reservePrice' => 'Decimal'
621 'OptionalInput' => array()
627 * Add some dynamic filtering to our grids.
629 public function __construct()
631 $authData = \Utility\Registry::getAuthData();
632 switch (\Utility\Registry::getUserType())
635 $groupFilter = \Utility\Registry::getSudo('Group', false);
637 && $this->metaGrid['Filter']['IDENTITY(company.group)'] = $groupFilter;
638 $divisionFilter = \Utility\Registry::getSudo('Division', false);
640 && $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $divisionFilter;
641 $companyFilter = \Utility\Registry::getSudo('Company', false);
643 && $this->metaGrid['Filter']['company.id'] = $companyFilter;
645 && $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $companyFilter;
648 $this->metaGrid['Filter']['IDENTITY(company.group)'] = $authData['company']['group']['id'];
649 $divisionFilter = \Utility\Registry::getSudo('Division', false);
651 && $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $divisionFilter;
652 $companyFilter = \Utility\Registry::getSudo('Company', false);
654 && $this->metaGrid['Filter']['company.id'] = $companyFilter;
656 && $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $companyFilter;
658 case 'Dealer Principle':
659 $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $authData['company']['groupDivision']['id'];
660 $companyFilter = \Utility\Registry::getSudo('Company', false);
662 && $this->metaGrid['Filter']['company.id'] = $companyFilter;
664 && $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $companyFilter;
667 $this->metaGrid['Filter']['company.id'] = $authData['company']['id'];
668 $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $authData['company']['id'];