src/Diplix/KMGBundle/Entity/PriceList.php line 13

Open in your IDE?
  1. <?php
  2. namespace Diplix\KMGBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Table(name="pricelists", indexes={@ORM\Index(name="be_deleted",columns={"be_deleted"})})
  8.  * @ORM\Entity(repositoryClass="Diplix\KMGBundle\Repository\PriceListRepository")
  9.  */
  10. class PriceList extends BasicEntity
  11. {
  12.     const DEFAULT_HOME_ADDRESS "67063 Ludwigshafen am Rhein, Deutschland";
  13.     const CALC_MODE_DEFAULT 0;
  14.     const CALC_MODE_INFINITE_AS_ADDITION 1;
  15.     const CALC_MODE_NO_FLAT_CHARGES 2;
  16.     /**
  17.      * @ORM\Column(type="integer",name="id")
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     protected $id;
  22.      /**
  23.      * @ORM\Column(type="string")
  24.      */
  25.     protected $name "";
  26.     /**
  27.      * @ORM\Column(type="string")
  28.      */
  29.     protected $homeAddress self::DEFAULT_HOME_ADDRESS;
  30.     /**
  31.      * @ORM\Column(type="string")
  32.      */
  33.     protected $caption "";
  34.     /**
  35.      * @ORM\Column(type="text")
  36.      */
  37.     protected $notice "";
  38.     /**
  39.      * @ORM\Column(type="text")
  40.      */
  41.     protected $noticeEn "";
  42.     /**
  43.      * @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
  44.      */
  45.     protected $extraCharge 0.0;
  46.     /**
  47.      * @ORM\OneToMany(targetEntity="Diplix\KMGBundle\Entity\PriceListItem", mappedBy="priceList",cascade={"persist"}, fetch="EAGER")
  48.      * @ORM\OrderBy({"fromKm" = "ASC"})  -- not working :: https://github.com/doctrine/orm/issues/4256
  49.      */
  50.     protected $items;
  51.     /**
  52.      * @ORM\Column(type="json")
  53.      */
  54.     protected $carTypeFilter = array();
  55.     /**
  56.      * Calculator class
  57.      * @ORM\Column(type="string")
  58.      */
  59.     protected $calculator;
  60.     /**
  61.      * @ORM\Column(type="json")
  62.      */
  63.     protected $configuration = array();
  64.     /**
  65.      * @ORM\Column(type="integer")
  66.      */
  67.     protected $defaultCalculationMode self::CALC_MODE_DEFAULT;
  68.     /**
  69.      * @ORM\Column(type="boolean", options={"default"="1"})
  70.      */
  71.     protected $requiresDistance true;
  72.     /**
  73.      * @ORM\Column(type="boolean", options={"default"="0"})
  74.      */
  75.     protected $requiresOptions false;
  76.     /**
  77.      * @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\File", fetch="EAGER")
  78.      * @ORM\JoinColumn(referencedColumnName="id",nullable=true)
  79.      */
  80.     protected $image null;
  81.     /**
  82.      * @ORM\Column(type="string", nullable=true)
  83.      */
  84.     protected $overwriteCustomerNameForTamiWithThis;
  85.     /**
  86.      * @ORM\Column(type="boolean", options={"default"="0"})
  87.      */
  88.     protected $isNetto false;
  89.     /**
  90.      * @ORM\ManyToMany(targetEntity="Diplix\KMGBundle\Entity\PaymentType")
  91.      */
  92.     protected $paymentTypes;
  93.     /**
  94.      * @ORM\Column(type="integer", options={"default"="80"})
  95.      * no deduction if 0
  96.      */
  97.     protected $combinationRideDeduction 80;
  98.     /**
  99.      * @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
  100.      */
  101.     protected $werksFahrtProH 0.0;
  102.     /**
  103.      * @ORM\Column(type="string", nullable=false)
  104.      */
  105.     protected $werksFahrtAccNumber '';
  106.     /**
  107.      * @ORM\Column(type="string", nullable=false)
  108.      */
  109.     protected $slcAccNumber '';
  110.     /**
  111.      * @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
  112.      */
  113.     protected $slcPrice0.0;
  114.     /**
  115.      * @ORM\Column(type="string", nullable=false)
  116.      */
  117.     protected $orderChargeAccNumber '';
  118.     /**
  119.      * @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
  120.      */
  121.     protected $orderChargePrice0.0;
  122.     /**
  123.      * @ORM\Column(type="string", nullable=false)
  124.      */
  125.     protected $applicantTimeRideAccNumber '';
  126.     /**
  127.      * @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
  128.      */
  129.     protected $applicantTimeRidePrice0.0;
  130.     /**
  131.      * @ORM\Column(type="string", nullable=false)
  132.      */
  133.     protected $vvcAccNumber '';
  134.     /**
  135.      * @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
  136.      */
  137.     protected $vvcPrice0.0;
  138.     /**
  139.      * @ORM\Column(type="string", nullable=false)
  140.      */
  141.     protected $stornoAccNumber='';
  142.     /**
  143.      * @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
  144.      */
  145.     protected $stornoPrice0.0;
  146.     /**
  147.      * @ORM\Column(type="string", nullable=false)
  148.      */
  149.     protected $extraCostAccNumber='';
  150.     /**
  151.      * @ORM\Column(type="datetime",nullable=true)
  152.      */
  153.     protected $validSince null;
  154.     /**
  155.      * @ORM\Column(type="datetime",nullable=true)
  156.      */
  157.     protected $validUntil null;
  158.     /**
  159.      * @ORM\Column(type="boolean", options={"default"="0"})
  160.      */
  161.     protected $hidden false;
  162.     function __construct()
  163.     {
  164.         $this->items = new ArrayCollection();
  165.     }
  166.     /**
  167.      * @return mixed
  168.      */
  169.     public function getId()
  170.     {
  171.         return $this->id;
  172.     }
  173.     public function clearId()
  174.     {
  175.         $this->id null;
  176.         $this->beOwner null;
  177.         $this->beCreated null;
  178.         $this->beEdited null;
  179.     }
  180.     /**
  181.      * @return mixed
  182.      */
  183.     public function getName()
  184.     {
  185.         return $this->name;
  186.     }
  187.     /**
  188.      * @param mixed $name
  189.      */
  190.     public function setName($name)
  191.     {
  192.         $this->name $name;
  193.     }
  194.     /**
  195.      * @return ArrayCollection
  196.      */
  197.     public function getItems()
  198.     {
  199.         // so eine fickscheiße - beDeletedFilter funzt nicht mit OneToMany falls nicht die Entität direkt, sondern
  200.         // mehrere geladen wurden, da der filter nur an die erste Tabelle, nicht aber an die Joins geklemmt wird
  201.         // So was sinnloses!
  202.         // @see https://github.com/Atlantic18/DoctrineExtensions/issues/1463
  203.         // Sortierung funzt auch nicht
  204.         // @see https://github.com/doctrine/orm/issues/4256
  205.         // Workaround
  206.         $iterator $this->items->getIterator();
  207.         $iterator->uasort(function ($a$b) {
  208.             return ($a->getFromKm() < $b->getFromKm()) ? -1;
  209.         });
  210.         $ac = new ArrayCollection();
  211.         foreach ($iterator as $i)
  212.         {
  213.             if (!$i->getBeDeleted()) $ac->add($i);
  214.         }
  215.         return $ac;
  216.     }
  217.     /**
  218.      * @param mixed $items
  219.      */
  220.     public function setItems($items)
  221.     {
  222.         $this->items $items;
  223.     }
  224.     public static function checkItems(Collection $items)
  225.     {
  226.         $messages = array();
  227.         $infiniteCount 0;
  228.         if ($items->count()< )
  229.         {
  230.             $messages[]="Keine Einträge in der Preisliste !";
  231.         }
  232.         else
  233.         {
  234.             $first $items->first();
  235.             if ($first->getFromKm()!= 1)
  236.             {
  237.                 $messages[]="Startwert fehlt (ab 1 KM) !";
  238.             }
  239.             $km 0;
  240.             /** @var PriceListItem $item */
  241.             foreach ($items as $item)
  242.             {
  243.                 $infiniteCount += ($item->getToInfinite()? 0);
  244.                 if ($item != $first)
  245.                 {
  246.                     if ( $item->getFromKm() != $km+$messages[] = sprintf("Lücke oder Überlappung zwischen KM %d und %d",$km,$item->getFromKm());
  247.                 }
  248.                 $km $item->getToKm();
  249.             }
  250.             if ($infiniteCount != 1)
  251.             {
  252.                 $messages[]="Überkilometer-Eintrag fehlt oder mehrfach vorhanden !";
  253.             }
  254.         }
  255.         return $messages;
  256.     }
  257.     /**
  258.      * @return mixed
  259.      */
  260.     public function getExtraCharge()
  261.     {
  262.         return $this->extraCharge;
  263.     }
  264.     /**
  265.      * @param mixed $extraCharge
  266.      */
  267.     public function setExtraCharge($extraCharge)
  268.     {
  269.         $this->extraCharge $extraCharge;
  270.     }
  271.     /**
  272.      * @return mixed
  273.      */
  274.     public function getHomeAddress()
  275.     {
  276.         return $this->homeAddress;
  277.     }
  278.     /**
  279.      * @param mixed $homeAddress
  280.      */
  281.     public function setHomeAddress($homeAddress)
  282.     {
  283.         $this->homeAddress $homeAddress;
  284.     }
  285.     /**
  286.      * @return mixed
  287.      */
  288.     public function getNotice()
  289.     {
  290.         return $this->notice;
  291.     }
  292.     /**
  293.      * @param mixed $notice
  294.      */
  295.     public function setNotice($notice)
  296.     {
  297.         $this->notice $notice;
  298.     }
  299.     /**
  300.      * @return mixed
  301.      */
  302.     public function getCaption()
  303.     {
  304.         if ($this->caption == "") return $this->name;
  305.         return $this->caption;
  306.     }
  307.     /**
  308.      * @param mixed $caption
  309.      */
  310.     public function setCaption($caption)
  311.     {
  312.         $this->caption $caption;
  313.     }
  314.     /**
  315.      * @return array
  316.      */
  317.     public function getCarTypeFilter()
  318.     {
  319.         return $this->carTypeFilter;
  320.     }
  321.     /**
  322.      * @param array $carTypeFilter
  323.      */
  324.     public function setCarTypeFilter($carTypeFilter)
  325.     {
  326.         $this->carTypeFilter $carTypeFilter;
  327.     }
  328.     /**
  329.      * @return mixed
  330.      */
  331.     public function getCalculator($short=false)
  332.     {
  333.         if ($short)
  334.         {
  335.             $c $this->calculator;
  336.             $pp strrpos($c,"\\");
  337.             return substr($c,$pp+1);
  338.         }
  339.         return $this->calculator;
  340.     }
  341.     /**
  342.      * @param mixed $calculator
  343.      */
  344.     public function setCalculator($calculator)
  345.     {
  346.         $this->calculator $calculator;
  347.     }
  348.     /**
  349.      * @return array
  350.      */
  351.     public function getConfiguration()
  352.     {
  353.         return $this->configuration;
  354.     }
  355.     /**
  356.      * @param array $configuration
  357.      */
  358.     public function setConfiguration($configuration)
  359.     {
  360.         $this->configuration $configuration;
  361.     }
  362.     /**
  363.      * @return mixed
  364.      */
  365.     public function getNoticeEn()
  366.     {
  367.         return $this->noticeEn;
  368.     }
  369.     /**
  370.      * @param mixed $noticeEn
  371.      */
  372.     public function setNoticeEn($noticeEn)
  373.     {
  374.         $this->noticeEn $noticeEn;
  375.     }
  376.     /**
  377.      * @return int
  378.      */
  379.     public function getDefaultCalculationMode()
  380.     {
  381.         return $this->defaultCalculationMode;
  382.     }
  383.     /**
  384.      * @param int $defaultCalculationMode
  385.      */
  386.     public function setDefaultCalculationMode($defaultCalculationMode)
  387.     {
  388.         $this->defaultCalculationMode $defaultCalculationMode;
  389.     }
  390.     /**
  391.      * @return mixed
  392.      */
  393.     public function getRequiresDistance()
  394.     {
  395.         return $this->requiresDistance;
  396.     }
  397.     /**
  398.      * @param mixed $requiresDistance
  399.      */
  400.     public function setRequiresDistance($requiresDistance)
  401.     {
  402.         $this->requiresDistance $requiresDistance;
  403.     }
  404.     /**
  405.      * @return mixed
  406.      */
  407.     public function getRequiresOptions()
  408.     {
  409.         return $this->requiresOptions;
  410.     }
  411.     /**
  412.      * @param mixed $requiresOptions
  413.      */
  414.     public function setRequiresOptions($requiresOptions)
  415.     {
  416.         $this->requiresOptions $requiresOptions;
  417.     }
  418.     /**
  419.      * @return mixed
  420.      */
  421.     public function getImage()
  422.     {
  423.         return $this->image;
  424.     }
  425.     /**
  426.      * @param mixed $image
  427.      */
  428.     public function setImage($image)
  429.     {
  430.         $this->image $image;
  431.     }
  432.     /**
  433.      * @return mixed
  434.      */
  435.     public function getOverwriteCustomerNameForTamiWithThis()
  436.     {
  437.         return $this->overwriteCustomerNameForTamiWithThis;
  438.     }
  439.     /**
  440.      * @param mixed $overwriteCustomerNameForTamiWithThis
  441.      */
  442.     public function setOverwriteCustomerNameForTamiWithThis($overwriteCustomerNameForTamiWithThis)
  443.     {
  444.         $this->overwriteCustomerNameForTamiWithThis $overwriteCustomerNameForTamiWithThis;
  445.     }
  446.     /**
  447.      * @return bool
  448.      */
  449.     public function isNetto(): bool
  450.     {
  451.         return $this->isNetto;
  452.     }
  453.     /**
  454.      * @param bool $isNetto
  455.      */
  456.     public function setIsNetto(bool $isNetto): void
  457.     {
  458.         $this->isNetto $isNetto;
  459.     }
  460.     /**
  461.      * @return mixed
  462.      */
  463.     public function getPaymentTypes()
  464.     {
  465.         return $this->paymentTypes;
  466.     }
  467.     /**
  468.      * @param mixed $paymentTypes
  469.      */
  470.     public function setPaymentTypes($paymentTypes): void
  471.     {
  472.         $this->paymentTypes $paymentTypes;
  473.     }
  474.     /**
  475.      * @return int
  476.      */
  477.     public function getCombinationRideDeduction(): int
  478.     {
  479.         return $this->combinationRideDeduction;
  480.     }
  481.     /**
  482.      * @param int $combinationRideDeduction
  483.      */
  484.     public function setCombinationRideDeduction(int $combinationRideDeduction): void
  485.     {
  486.         $this->combinationRideDeduction $combinationRideDeduction;
  487.     }
  488.     /**
  489.      * @return float
  490.      */
  491.     public function getWerksFahrtProH(): float
  492.     {
  493.         return $this->werksFahrtProH;
  494.     }
  495.     /**
  496.      * @param float $werksFahrtProH
  497.      */
  498.     public function setWerksFahrtProH(float $werksFahrtProH): void
  499.     {
  500.         $this->werksFahrtProH $werksFahrtProH;
  501.     }
  502.     /**
  503.      * @return string
  504.      */
  505.     public function getWerksFahrtAccNumber(): string
  506.     {
  507.         return $this->werksFahrtAccNumber;
  508.     }
  509.     /**
  510.      * @param string $werksFahrtAccNumber
  511.      */
  512.     public function setWerksFahrtAccNumber(string $werksFahrtAccNumber): void
  513.     {
  514.         $this->werksFahrtAccNumber $werksFahrtAccNumber;
  515.     }
  516.     /**
  517.      * @return string
  518.      */
  519.     public function getSlcAccNumber(): string
  520.     {
  521.         return $this->slcAccNumber;
  522.     }
  523.     /**
  524.      * @param string $slcAccNumber
  525.      */
  526.     public function setSlcAccNumber(string $slcAccNumber): void
  527.     {
  528.         $this->slcAccNumber $slcAccNumber;
  529.     }
  530.     /**
  531.      * @return float
  532.      */
  533.     public function getSlcPrice(): float
  534.     {
  535.         return $this->slcPrice;
  536.     }
  537.     /**
  538.      * @param float $slcPrice
  539.      */
  540.     public function setSlcPrice(float $slcPrice): void
  541.     {
  542.         $this->slcPrice $slcPrice;
  543.     }
  544.     /**
  545.      * @return string
  546.      */
  547.     public function getVvcAccNumber(): string
  548.     {
  549.         return $this->vvcAccNumber;
  550.     }
  551.     /**
  552.      * @param string $vvcAccNumber
  553.      */
  554.     public function setVvcAccNumber(string $vvcAccNumber): void
  555.     {
  556.         $this->vvcAccNumber $vvcAccNumber;
  557.     }
  558.     /**
  559.      * @return float
  560.      */
  561.     public function getVvcPrice(): float
  562.     {
  563.         return $this->vvcPrice;
  564.     }
  565.     /**
  566.      * @param float $vvcPrice
  567.      */
  568.     public function setVvcPrice(float $vvcPrice): void
  569.     {
  570.         $this->vvcPrice $vvcPrice;
  571.     }
  572.     /**
  573.      * @return string
  574.      */
  575.     public function getStornoAccNumber(): string
  576.     {
  577.         return $this->stornoAccNumber;
  578.     }
  579.     /**
  580.      * @param string $stornoAccNumber
  581.      */
  582.     public function setStornoAccNumber(string $stornoAccNumber): void
  583.     {
  584.         $this->stornoAccNumber $stornoAccNumber;
  585.     }
  586.     /**
  587.      * @return float
  588.      */
  589.     public function getStornoPrice(): float
  590.     {
  591.         return $this->stornoPrice;
  592.     }
  593.     /**
  594.      * @param float $stornoPrice
  595.      */
  596.     public function setStornoPrice(float $stornoPrice): void
  597.     {
  598.         $this->stornoPrice $stornoPrice;
  599.     }
  600.     /**
  601.      * @return string
  602.      */
  603.     public function getExtraCostAccNumber(): string
  604.     {
  605.         return $this->extraCostAccNumber;
  606.     }
  607.     /**
  608.      * @param string $extraCostAccNumber
  609.      */
  610.     public function setExtraCostAccNumber(string $extraCostAccNumber): void
  611.     {
  612.         $this->extraCostAccNumber $extraCostAccNumber;
  613.     }
  614.     /**
  615.      * @return bool
  616.      */
  617.     public function isHidden(): bool
  618.     {
  619.         return $this->hidden;
  620.     }
  621.     /**
  622.      * @param bool $hidden
  623.      */
  624.     public function setHidden(bool $hidden): void
  625.     {
  626.         $this->hidden $hidden;
  627.     }
  628.     /**
  629.      * @return null|\DateTime
  630.      */
  631.     public function getValidSince(): ?\DateTime
  632.     {
  633.         return $this->validSince;
  634.     }
  635.     /**
  636.      * @param \DateTime|null $validSince
  637.      */
  638.     public function setValidSince(?\DateTime $validSince): void
  639.     {
  640.         $this->validSince $validSince;
  641.     }
  642.     /**
  643.      * @return null|\DateTime
  644.      */
  645.     public function getValidUntil(): ?\DateTime
  646.     {
  647.         return $this->validUntil;
  648.     }
  649.     /**
  650.      * @param \DateTime|null $validUntil
  651.      */
  652.     public function setValidUntil(?\DateTime $validUntil): void
  653.     {
  654.         $this->validUntil $validUntil;
  655.     }
  656.     /**
  657.      * @return string
  658.      */
  659.     public function getApplicantTimeRideAccNumber(): string
  660.     {
  661.         return $this->applicantTimeRideAccNumber;
  662.     }
  663.     /**
  664.      * @param string $applicantTimeRideAccNumber
  665.      */
  666.     public function setApplicantTimeRideAccNumber(string $applicantTimeRideAccNumber): void
  667.     {
  668.         $this->applicantTimeRideAccNumber $applicantTimeRideAccNumber;
  669.     }
  670.     /**
  671.      * @return float
  672.      */
  673.     public function getApplicantTimeRidePrice(): float
  674.     {
  675.         return $this->applicantTimeRidePrice;
  676.     }
  677.     /**
  678.      * @param float $applicantTimeRidePrice
  679.      */
  680.     public function setApplicantTimeRidePrice(float $applicantTimeRidePrice): void
  681.     {
  682.         $this->applicantTimeRidePrice $applicantTimeRidePrice;
  683.     }
  684.     /**
  685.      * @return string
  686.      */
  687.     public function getOrderChargeAccNumber(): string
  688.     {
  689.         return $this->orderChargeAccNumber;
  690.     }
  691.     /**
  692.      * @param string $orderChargeAccNumber
  693.      */
  694.     public function setOrderChargeAccNumber(string $orderChargeAccNumber): void
  695.     {
  696.         $this->orderChargeAccNumber $orderChargeAccNumber;
  697.     }
  698.     /**
  699.      * @return float
  700.      */
  701.     public function getOrderChargePrice(): float
  702.     {
  703.         return $this->orderChargePrice;
  704.     }
  705.     /**
  706.      * @param float $orderChargePrice
  707.      */
  708.     public function setOrderChargePrice(float $orderChargePrice): void
  709.     {
  710.         $this->orderChargePrice $orderChargePrice;
  711.     }
  712. }