src/Entity/Factures.php line 18

Open in your IDE?
  1. <?php
  2. /**
  3.  * FacturesEntete.php
  4.  * Created by Stéphane Brun
  5.  * Date: 19/04/2018 at 16:39
  6.  */
  7. namespace App\Entity;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Symfony\Component\Serializer\Annotation\MaxDepth;
  11. /**
  12.  * @ORM\Entity
  13.  * @ORM\Table(name="tfacturesentete")
  14.  * @ORM\Entity(repositoryClass="App\Repository\FacturesRepository")
  15.  */
  16. class Factures
  17. {
  18.     const COUPONS_POURCENT 5;
  19.     const HISTORY_WATCH = array(
  20.         'date' => 'Date',
  21.         'client' => 'Client',
  22.         'transport' => 'Livraison',
  23.         'commentaire' => 'Commentaire',
  24.     );
  25.     /**
  26.      * @ORM\Column(name="EFacture", type="integer")
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue(strategy="AUTO")
  29.      */
  30.     protected $id;
  31.     /**
  32.      * @ORM\Column(name="EDate", type="date", nullable=true)
  33.      */
  34.     protected $date;
  35.     /**
  36.      * @ORM\Column(name="EBonCommande", type="string", length=100, nullable=true)
  37.      */
  38.     protected $bonCommande;
  39.     /**
  40.      * @ORM\Column(name="commentaire", type="string", length=255, nullable=true)
  41.      */
  42.     protected $commentaire;
  43.     /**
  44.      * @ORM\Column(name="ECommission", type="integer", nullable=true)
  45.      */
  46.     protected $commission;
  47.     /**
  48.      * @ORM\Column(name="ETransport", type="float", nullable=false, options={"default": 0})
  49.      */
  50.     protected $transport 0;
  51.     /**
  52.      * @ORM\Column(name="ETPS", type="float", nullable=true)
  53.      */
  54.     protected $tps;
  55.     /**
  56.      * @ORM\Column(name="ETVQ", type="float", nullable=true)
  57.      */
  58.     protected $tvq;
  59.     /**
  60.      * @ORM\Column(name="EFermee", type="boolean", nullable=true)
  61.      */
  62.     protected $fermee false;
  63.     /**
  64.      * @ORM\Column(name="ERabaisP", type="integer", nullable=true)
  65.      */
  66.     protected $rabaisP 0;
  67.     /**
  68.      * @ORM\Column(name="ERabaisM", type="float", nullable=true)
  69.      */
  70.     protected $rabaisM 0;
  71.     /**
  72.      * @ORM\Column(name="ERabaisCatalogue", type="float", nullable=true)
  73.      */
  74.     protected $rabaisCatalogue;
  75.     /**
  76.      * @ORM\Column(name="EComptant", type="float", nullable=true)
  77.      */
  78.     protected $comptant;
  79.     /**
  80.      * @ORM\Column(name="EInteract", type="float", nullable=true)
  81.      */
  82.     protected $interact;
  83.     /**
  84.      * @ORM\Column(name="ECarteMC", type="float", nullable=true)
  85.      */
  86.     protected $carteMC;
  87.     /**
  88.      * @ORM\Column(name="ECarteV", type="float", nullable=true)
  89.      */
  90.     protected $carteV;
  91.     /**
  92.      * @ORM\Column(name="ECoupons", type="float", nullable=true)
  93.      */
  94.     protected $coupons;
  95.     /**
  96.      * @ORM\Column(name="ECertificatsCadeaux", type="float", nullable=true)
  97.      */
  98.     protected $certificatsCadeaux;
  99.     /**
  100.      * @ORM\Column(name="ECertificatsCentre", type="float", nullable=true)
  101.      */
  102.     protected $certificatsCentre;
  103.     /**
  104.      * @ORM\Column(name="EFidelite", type="float", nullable=true)
  105.      */
  106.     protected $fidelite;
  107.     /**
  108.      * @ORM\Column(name="ECarteAPuce", type="float", nullable=true)
  109.      */
  110.     protected $carteAPuce;
  111.     /**
  112.      * @ORM\Column(name="EMonnaie", type="float", nullable=true)
  113.      */
  114.     protected $monnaie 0;
  115.     /**
  116.      * @ORM\Column(name="ESoldeARecevoir", type="float", nullable=true)
  117.      */
  118.     protected $soldeARecevoir;
  119.     /**
  120.      * @ORM\Column(name="EAcompte", type="float", nullable=true)
  121.      */
  122.     protected $acompte;
  123.     /**
  124.      * @ORM\Column(name="EacompteUtilise", type="float", nullable=true)
  125.      */
  126.     protected $acompteUtilise;
  127.     /**
  128.      * @ORM\Column(name="ECommis", type="integer", nullable=true)
  129.      */
  130.     protected $commis;
  131.     /**
  132.      * @ORM\Column(name="EAnnulee", type="boolean", nullable=true)
  133.      */
  134.     protected $annulee 0;
  135.     /**
  136.      * @ORM\Column(name="EAnnuleeRaison", type="string", length=100, nullable=true)
  137.      */
  138.     protected $annuleeRaison;
  139.     /**
  140.      * @ORM\Column(name="EAnnuleeOp", type="string", length=50, nullable=true)
  141.      */
  142.     protected $annuleeOp;
  143.     /**
  144.      * @ORM\Column(name="EannuleeQuand", type="datetime", nullable=true)
  145.      */
  146.     protected $annuleeQuand;
  147.     /**
  148.      * @ORM\Column(name="ECaisse", type="string", length=50, nullable=true)
  149.      */
  150.     protected $caisse;
  151.     /**
  152.      * @ORM\Column(name="ESession", type="string", length=50, nullable=true)
  153.      */
  154.     protected $session;
  155.     /**
  156.      * @ORM\Column(name="ECertN1", type="integer", nullable=true)
  157.      */
  158.     protected $certN1;
  159.     /**
  160.      * @ORM\Column(name="ECertN2", type="integer", nullable=true)
  161.      */
  162.     protected $certN2;
  163.     /**
  164.      * @ORM\Column(name="ECertN3", type="integer", nullable=true)
  165.      */
  166.     protected $certN3;
  167.     /**
  168.      * @ORM\Column(name="ECertN4", type="integer", nullable=true)
  169.      */
  170.     protected $certN4;
  171.     /**
  172.      * @ORM\Column(name="ECertM1", type="float", nullable=true)
  173.      */
  174.     protected $certM1;
  175.     /**
  176.      * @ORM\Column(name="ECertM2", type="float", nullable=true)
  177.      */
  178.     protected $certM2;
  179.     /**
  180.      * @ORM\Column(name="ECertM3", type="float", nullable=true)
  181.      */
  182.     protected $certM3;
  183.     /**
  184.      * @ORM\Column(name="ECertM4", type="float", nullable=true)
  185.      */
  186.     protected $certM4;
  187.     /**
  188.      * @ORM\Column(name="ETS", type="datetime", nullable=true)
  189.      */
  190.     protected $ts;
  191.     /**
  192.      * one Fournisseurs (Transporteur)
  193.      *
  194.      * @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs")
  195.      * @ORM\JoinColumn(name="ETransporteur", referencedColumnName="id", nullable=true)
  196.      */
  197.     protected $transporteur;
  198.     /**
  199.      * Many Factures has one Company (Succursalle)
  200.      *
  201.      * @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="factures")
  202.      * @ORM\JoinColumn(name="ESuccursale", referencedColumnName="id", nullable=true)
  203.      */
  204.     protected $succursale;
  205.     /**
  206.      * Many Factures has one Client
  207.      *
  208.      * @ORM\ManyToOne(targetEntity="App\Entity\Clients")
  209.      * @ORM\JoinColumn(name="EClient", referencedColumnName="id", nullable=true)
  210.      */
  211.     protected $client;
  212.     
  213.     /**
  214.      * Many Factures has one Provenance
  215.      *
  216.      * @ORM\ManyToOne(targetEntity="App\Entity\Provenances")
  217.      * @ORM\JoinColumn(name="EProvenance", referencedColumnName="id", nullable=true)
  218.      */
  219.     protected $provenance;
  220.     /**
  221.      * Many Factures has one ClientsAdressesLivraison
  222.      *
  223.      * @ORM\ManyToOne(targetEntity="App\Entity\ClientsAdressesLivraison")
  224.      * @ORM\JoinColumn(name="EClientADL", referencedColumnName="id", nullable=true)
  225.      */
  226.     protected $clientADL;
  227.     /**
  228.      * One Factures has many FacturesDetail
  229.      * , fetch="EAGER" ???
  230.      *
  231.      *
  232.      * @ORM\OneToMany(targetEntity="FacturesDetail", mappedBy="facture", cascade={"persist", "remove"}, orphanRemoval=true)
  233.      * @MaxDepth(1)
  234.      */
  235.     protected $details;
  236.     /**
  237.      * has one Company
  238.      *
  239.      * @ORM\ManyToOne(targetEntity="App\Entity\Company")
  240.      * @ORM\JoinColumn(name="company_id", referencedColumnName="id", nullable=true)
  241.      * @MaxDepth(1)
  242.      */
  243.     protected $company;
  244.     public function __construct()
  245.     {
  246.         $this->details = new ArrayCollection();
  247.         $this->date = new \DateTime();
  248.     }
  249.     /**
  250.      * @return mixed
  251.      */
  252.     public function getCompany()
  253.     {
  254.         return $this->company;
  255.     }
  256.     /**
  257.      * @param Company $company
  258.      */
  259.     public function setCompany(Company $company)
  260.     {
  261.         $this->company $company;
  262.     }
  263.     /**
  264.      * @return mixed
  265.      */
  266.     public function getId()
  267.     {
  268.         return $this->id;
  269.     }
  270.     /**
  271.      * @return mixed
  272.      */
  273.     public function getDate()
  274.     {
  275.         return $this->date;
  276.     }
  277.     /**
  278.      * @param mixed $date
  279.      */
  280.     public function setDate($date)
  281.     {
  282.         $this->date $date;
  283.     }
  284.     /**
  285.      * @return mixed
  286.      */
  287.     public function getBonCommande()
  288.     {
  289.         return $this->bonCommande;
  290.     }
  291.     /**
  292.      * @param mixed $bonCommande
  293.      */
  294.     public function setBonCommande($bonCommande)
  295.     {
  296.         $this->bonCommande $bonCommande;
  297.     }
  298.     /**
  299.     /**
  300.      * @return mixed
  301.      */
  302.     public function getTransport()
  303.     {
  304.         return $this->transport;
  305.     }
  306.     /**
  307.      * @param mixed $transport
  308.      */
  309.     public function setTransport($transport)
  310.     {
  311.         $this->transport $transport;
  312.     }
  313.     /**
  314.      * @return mixed
  315.      */
  316.     public function getTps()
  317.     {
  318.         return $this->tps;
  319.     }
  320.     /**
  321.      * @param mixed $tps
  322.      */
  323.     public function setTps($tps)
  324.     {
  325.         $this->tps $tps;
  326.     }
  327.     /**
  328.      * @return mixed
  329.      */
  330.     public function getTvq()
  331.     {
  332.         return $this->tvq;
  333.     }
  334.     /**
  335.      * @param mixed $tvq
  336.      */
  337.     public function setTvq($tvq)
  338.     {
  339.         $this->tvq $tvq;
  340.     }
  341.     /**
  342.      * @return mixed
  343.      */
  344.     public function getFermee()
  345.     {
  346.         return $this->fermee;
  347.     }
  348.     /**
  349.      * @param mixed $fermee
  350.      */
  351.     public function setFermee($fermee)
  352.     {
  353.         $this->fermee $fermee;
  354.     }
  355.     /**
  356.      * @return mixed
  357.      */
  358.     public function getRabaisP()
  359.     {
  360.         return $this->rabaisP;
  361.     }
  362.     /**
  363.      * @param mixed $rabaisP
  364.      */
  365.     public function setRabaisP($rabaisP)
  366.     {
  367.         $this->rabaisP $rabaisP;
  368.     }
  369.     /**
  370.      * @return mixed
  371.      */
  372.     public function getRabaisM()
  373.     {
  374.         return $this->rabaisM;
  375.     }
  376.     /**
  377.      * @param mixed $rabaisM
  378.      */
  379.     public function setRabaisM($rabaisM)
  380.     {
  381.         $this->rabaisM $rabaisM;
  382.     }
  383.     /**
  384.      * @return mixed
  385.      */
  386.     public function getRabaisCatalogue()
  387.     {
  388.         return $this->rabaisCatalogue;
  389.     }
  390.     /**
  391.      * @param mixed $rabaisCatalogue
  392.      */
  393.     public function setRabaisCatalogue($rabaisCatalogue)
  394.     {
  395.         $this->rabaisCatalogue $rabaisCatalogue;
  396.     }
  397.     /**
  398.      * @return mixed
  399.      */
  400.     public function getComptant()
  401.     {
  402.         return $this->comptant;
  403.     }
  404.     /**
  405.      * @param mixed $comptant
  406.      */
  407.     public function setComptant($comptant)
  408.     {
  409.         $this->comptant $comptant;
  410.     }
  411.     /**
  412.      * @return mixed
  413.      */
  414.     public function getInteract()
  415.     {
  416.         return $this->interact;
  417.     }
  418.     /**
  419.      * @param mixed $interact
  420.      */
  421.     public function setInteract($interact)
  422.     {
  423.         $this->interact $interact;
  424.     }
  425.     /**
  426.      * @return mixed
  427.      */
  428.     public function getCarteMC()
  429.     {
  430.         return $this->carteMC;
  431.     }
  432.     /**
  433.      * @param mixed $carteMC
  434.      */
  435.     public function setCarteMC($carteMC)
  436.     {
  437.         $this->carteMC $carteMC;
  438.     }
  439.     /**
  440.      * @return mixed
  441.      */
  442.     public function getCarteV()
  443.     {
  444.         return $this->carteV;
  445.     }
  446.     /**
  447.      * @param mixed $carteV
  448.      */
  449.     public function setCarteV($carteV)
  450.     {
  451.         $this->carteV $carteV;
  452.     }
  453.     /**
  454.      * @return mixed
  455.      */
  456.     public function getCoupons()
  457.     {
  458.         return $this->coupons;
  459.     }
  460.     /**
  461.      * @param mixed $coupons
  462.      */
  463.     public function setCoupons($coupons)
  464.     {
  465.         $this->coupons $coupons;
  466.     }
  467.     /**
  468.      * @return mixed
  469.      */
  470.     public function getCertificatsCadeaux()
  471.     {
  472.         return $this->certificatsCadeaux;
  473.     }
  474.     /**
  475.      * @param mixed $certificatsCadeaux
  476.      */
  477.     public function setCertificatsCadeaux($certificatsCadeaux)
  478.     {
  479.         $this->certificatsCadeaux $certificatsCadeaux;
  480.     }
  481.     /**
  482.      * @return mixed
  483.      */
  484.     public function getCertificatsCentre()
  485.     {
  486.         return $this->certificatsCentre;
  487.     }
  488.     /**
  489.      * @param mixed $certificatsCentre
  490.      */
  491.     public function setCertificatsCentre($certificatsCentre)
  492.     {
  493.         $this->certificatsCentre $certificatsCentre;
  494.     }
  495.     /**
  496.      * @return mixed
  497.      */
  498.     public function getFidelite()
  499.     {
  500.         return $this->fidelite;
  501.     }
  502.     /**
  503.      * @param mixed $fidelite
  504.      */
  505.     public function setFidelite($fidelite)
  506.     {
  507.         $this->fidelite $fidelite;
  508.     }
  509.     /**
  510.      * @return mixed
  511.      */
  512.     public function getCarteAPuce()
  513.     {
  514.         return $this->carteAPuce;
  515.     }
  516.     /**
  517.      * @param mixed $carteAPuce
  518.      */
  519.     public function setCarteAPuce($carteAPuce)
  520.     {
  521.         $this->carteAPuce $carteAPuce;
  522.     }
  523.     /**
  524.      * @return mixed
  525.      */
  526.     public function getMonnaie()
  527.     {
  528.         if (empty($this->monnaie)) {
  529.             return 0;
  530.         }
  531.         return $this->monnaie;
  532.     }
  533.     /**
  534.      * @param mixed $monnaie
  535.      */
  536.     public function setMonnaie($monnaie): void
  537.     {
  538.         $this->monnaie $monnaie;
  539.     }
  540.     /**
  541.      * @return mixed
  542.      */
  543.     public function getSoldeARecevoir()
  544.     {
  545.         return $this->soldeARecevoir;
  546.     }
  547.     /**
  548.      * @param mixed $soldeARecevoir
  549.      */
  550.     public function setSoldeARecevoir($soldeARecevoir)
  551.     {
  552.         $this->soldeARecevoir $soldeARecevoir;
  553.     }
  554.     /**
  555.      * @return mixed
  556.      */
  557.     public function getAcompte()
  558.     {
  559.         return $this->acompte;
  560.     }
  561.     /**
  562.      * @param mixed $acompte
  563.      */
  564.     public function setAcompte($acompte)
  565.     {
  566.         $this->acompte $acompte;
  567.     }
  568.     /**
  569.      * @return mixed
  570.      */
  571.     public function getAcompteUtilise()
  572.     {
  573.         return $this->acompteUtilise;
  574.     }
  575.     /**
  576.      * @param mixed $acompteUtilise
  577.      */
  578.     public function setAcompteUtilise($acompteUtilise)
  579.     {
  580.         $this->acompteUtilise $acompteUtilise;
  581.     }
  582.     /**
  583.      * @return mixed
  584.      */
  585.     public function getCommis()
  586.     {
  587.         return $this->commis;
  588.     }
  589.     /**
  590.      * @param mixed $commis
  591.      */
  592.     public function setCommis($commis)
  593.     {
  594.         $this->commis $commis;
  595.     }
  596.     /**
  597.      * @return mixed
  598.      */
  599.     public function getAnnulee()
  600.     {
  601.         return $this->annulee;
  602.     }
  603.     /**
  604.      * @param mixed $annulee
  605.      */
  606.     public function setAnnulee($annulee)
  607.     {
  608.         $this->annulee $annulee;
  609.     }
  610.     /**
  611.      * @return mixed
  612.      */
  613.     public function getAnnuleeRaison()
  614.     {
  615.         return $this->annuleeRaison;
  616.     }
  617.     /**
  618.      * @param mixed $annuleeRaison
  619.      */
  620.     public function setAnnuleeRaison($annuleeRaison)
  621.     {
  622.         $this->annuleeRaison $annuleeRaison;
  623.     }
  624.     /**
  625.      * @return mixed
  626.      */
  627.     public function getAnnuleeOp()
  628.     {
  629.         return $this->annuleeOp;
  630.     }
  631.     /**
  632.      * @param mixed $annuleeOp
  633.      */
  634.     public function setAnnuleeOp($annuleeOp)
  635.     {
  636.         $this->annuleeOp $annuleeOp;
  637.     }
  638.     /**
  639.      * @return mixed
  640.      */
  641.     public function getAnnuleeQuand()
  642.     {
  643.         return $this->annuleeQuand;
  644.     }
  645.     /**
  646.      * @param mixed $annuleeQuand
  647.      */
  648.     public function setAnnuleeQuand($annuleeQuand)
  649.     {
  650.         $this->annuleeQuand $annuleeQuand;
  651.     }
  652.     /**
  653.      * @return mixed
  654.      */
  655.     public function getCaisse()
  656.     {
  657.         return $this->caisse;
  658.     }
  659.     /**
  660.      * @param mixed $caisse
  661.      */
  662.     public function setCaisse($caisse)
  663.     {
  664.         $this->caisse $caisse;
  665.     }
  666.     /**
  667.      * @return mixed
  668.      */
  669.     public function getSession()
  670.     {
  671.         return $this->session;
  672.     }
  673.     /**
  674.      * @param mixed $session
  675.      */
  676.     public function setSession($session)
  677.     {
  678.         $this->session $session;
  679.     }
  680.     /**
  681.      * @return mixed
  682.      */
  683.     public function getCertN1()
  684.     {
  685.         return $this->certN1;
  686.     }
  687.     /**
  688.      * @param mixed $certN1
  689.      */
  690.     public function setCertN1($certN1)
  691.     {
  692.         $this->certN1 $certN1;
  693.     }
  694.     /**
  695.      * @return mixed
  696.      */
  697.     public function getCertN2()
  698.     {
  699.         return $this->certN2;
  700.     }
  701.     /**
  702.      * @param mixed $certN2
  703.      */
  704.     public function setCertN2($certN2)
  705.     {
  706.         $this->certN2 $certN2;
  707.     }
  708.     /**
  709.      * @return mixed
  710.      */
  711.     public function getCertN3()
  712.     {
  713.         return $this->certN3;
  714.     }
  715.     /**
  716.      * @param mixed $certN3
  717.      */
  718.     public function setCertN3($certN3)
  719.     {
  720.         $this->certN3 $certN3;
  721.     }
  722.     /**
  723.      * @return mixed
  724.      */
  725.     public function getCertN4()
  726.     {
  727.         return $this->certN4;
  728.     }
  729.     /**
  730.      * @param mixed $certN4
  731.      */
  732.     public function setCertN4($certN4)
  733.     {
  734.         $this->certN4 $certN4;
  735.     }
  736.     /**
  737.      * @return mixed
  738.      */
  739.     public function getCertM1()
  740.     {
  741.         return $this->certM1;
  742.     }
  743.     /**
  744.      * @param mixed $certM1
  745.      */
  746.     public function setCertM1($certM1)
  747.     {
  748.         $this->certM1 $certM1;
  749.     }
  750.     /**
  751.      * @return mixed
  752.      */
  753.     public function getCertM2()
  754.     {
  755.         return $this->certM2;
  756.     }
  757.     /**
  758.      * @param mixed $certM2
  759.      */
  760.     public function setCertM2($certM2)
  761.     {
  762.         $this->certM2 $certM2;
  763.     }
  764.     /**
  765.      * @return mixed
  766.      */
  767.     public function getCertM3()
  768.     {
  769.         return $this->certM3;
  770.     }
  771.     /**
  772.      * @param mixed $certM3
  773.      */
  774.     public function setCertM3($certM3)
  775.     {
  776.         $this->certM3 $certM3;
  777.     }
  778.     /**
  779.      * @return mixed
  780.      */
  781.     public function getCertM4()
  782.     {
  783.         return $this->certM4;
  784.     }
  785.     /**
  786.      * @param mixed $certM4
  787.      */
  788.     public function setCertM4($certM4)
  789.     {
  790.         $this->certM4 $certM4;
  791.     }
  792.     /**
  793.      * @return mixed
  794.      */
  795.     public function getTs()
  796.     {
  797.         return $this->ts;
  798.     }
  799.     /**
  800.      * @param mixed $ts
  801.      */
  802.     public function setTs($ts)
  803.     {
  804.         $this->ts $ts;
  805.     }
  806.     /**
  807.      * @return mixed
  808.      */
  809.     public function getClient()
  810.     {
  811.         return $this->client;
  812.     }
  813.     /**
  814.      * @param Clients $client
  815.      */
  816.     public function setClient(Clients $client)
  817.     {
  818.         $this->client $client;
  819.     }
  820.     /**
  821.      * @return mixed
  822.      */
  823.     public function getClientADL()
  824.     {
  825.         return $this->clientADL;
  826.     }
  827.     /**
  828.      * @param mixed $clientADL
  829.      */
  830.     public function setClientADL($clientADL=null)
  831.     {
  832.         $this->clientADL $clientADL;
  833.     }
  834.     /**
  835.      * @return mixed
  836.      */
  837.     public function getDetails()
  838.     {
  839.         return $this->details;
  840.     }
  841.     /**
  842.      * @param mixed $details
  843.      */
  844.     public function setDetails($details)
  845.     {
  846.         $this->details $details;
  847.     }
  848.     /**
  849.      * @param FacturesDetail $detail
  850.      * @return Factures
  851.      */
  852.     public function addDetail(FacturesDetail $detail)
  853.     {
  854.         if (!$this->details->contains($detail)) {
  855.             $this->details->add($detail);
  856.             $detail->setFacture($this);
  857.         }
  858.         return $this;
  859.     }
  860.     /**
  861.      * @param FacturesDetail $detail
  862.      * @return $this
  863.      */
  864.     public function removeDetail(FacturesDetail $detail)
  865.     {
  866.         if ($this->details->contains($detail)) {
  867.             $this->details->removeElement($detail);
  868. //            $detail->setFacture(null);
  869.         }
  870.         return $this;
  871.     }
  872.     /**
  873.      * @return mixed
  874.      */
  875.     public function getSuccursale()
  876.     {
  877.         return $this->succursale;
  878.     }
  879.     /**
  880.      * @param Company $succursale
  881.      */
  882.     public function setSuccursale(Company $succursale null)
  883.     {
  884.         $this->succursale $succursale;
  885.     }
  886.     /**
  887.      * @return mixed
  888.      */
  889.     public function getTransporteur()
  890.     {
  891.         return $this->transporteur;
  892.     }
  893.     /**
  894.      * @param Fournisseurs $transporteur
  895.      */
  896.     public function setTransporteur(Fournisseurs $transporteur null)
  897.     {
  898.         $this->transporteur $transporteur;
  899.     }
  900.     /**
  901.      * @return mixed
  902.      */
  903.     public function getCommission()
  904.     {
  905.         return $this->commission;
  906.     }
  907.     /**
  908.      * @param mixed $commission
  909.      */
  910.     public function setCommission($commission)
  911.     {
  912.         $this->commission $commission;
  913.     }
  914.     /**
  915.      * @return mixed
  916.      */
  917.     public function getCommentaire()
  918.     {
  919.         return $this->commentaire;
  920.     }
  921.     /**
  922.      * @param mixed $commentaire
  923.      * @return Factures
  924.      */
  925.     public function setCommentaire($commentaire)
  926.     {
  927.         $this->commentaire $commentaire;
  928.         return $this;
  929.     }
  930.     
  931.     /**
  932.      * @return mixed
  933.      */
  934.     public function getProvenance()
  935.     {
  936.         return $this->provenance;
  937.     }
  938.     
  939.     /**
  940.      * @param Provenances $provenance
  941.      */
  942.     public function setProvenance(Provenances $provenance null)
  943.     {
  944.         $this->provenance $provenance;
  945.     }
  946.     /**
  947.      * @return string
  948.      */
  949.     public function getNumero()
  950.     {
  951.         $n $this->getCompany()->getId().$this->getId();
  952.         return $n;
  953.     }
  954.     /**
  955.      *
  956.      * @param int $tvq
  957.      * @param int $tps
  958.      * @param bool $usedQteDelivred
  959.      * @return array
  960.      */
  961.     public function getTotals($tvq=0$tps=0$usedQteDelivred false)
  962.     {
  963.         $totals = [
  964.             "brut" => 0,
  965.             "net" => 0,
  966.             "rabaisP" => 0,
  967.             "rabaisM" => 0,
  968.             "rabaisTotal" => 0,
  969.             "acompte" => 0,
  970.             "total" => 0,
  971.             "tvq" => 0,
  972.             "tps" => 0,
  973.             "coupons" => 0,
  974.             "monaie" => 0,
  975.             "cstotal" => 0,
  976.             "cstvq" => 0,
  977.             "cstps" => 0,
  978.         ];
  979.         $client $this->getClient();
  980.         /** @var FacturesDetail $detail */
  981.         foreach ($this->getDetails() as $detail) {
  982.             $net $detail->getNet($usedQteDelivred);
  983.             $totals["brut"] += $detail->getBrut($usedQteDelivred);
  984.             $totals["net"] += $net;
  985.             $totals["rabaisP"] += $detail->getRabaisP();
  986.             $totals["rabaisM"] += $detail->getRabaisM();
  987.             $totals["rabaisTotal"] += $detail->getRabaisTotal();
  988.             // Si la facture est encore ouverte, on recalcule le total des taxes
  989. //            if (false == $this->getFermee()) {
  990.             $dtps 0;
  991.             if (!$client->getExemptTps() && $detail->getTps()) {
  992.                 $dtps = ($net $tps);
  993.                 $totals["tps"] += (!empty($dtps)) ? $dtps 0;
  994.             }
  995.             $dtvq 0;
  996.             if (!$client->getExemptTvq() && $detail->getTvq()) {
  997.                 $dtvq = ($net $tvq);
  998.                 $totals["tvq"] += (!empty($dtvq)) ? $dtvq 0;
  999.             }
  1000.             $totals["total"] += ($net $dtps $dtvq);
  1001.         }
  1002.         
  1003.         $totals["cstotal"] = $totals["total"];
  1004.         $totals["cstvq"]   = $totals["tvq"];
  1005.         $totals["cstps"]   = $totals["tps"];
  1006.         if (true == $this->getFermee()) {
  1007.             // Le transport est déjà inclu
  1008.             $totals["tps"] = $this->getTps();
  1009.             $totals["tvq"] = $this->getTvq();
  1010.             $totals["total"] = ($totals["net"] + $totals["tps"] + $totals["tvq"]);
  1011.         } else {
  1012.             // On ajoute le transport
  1013.             $totals["tps"] = $this->getTps() + ($this->getTransport() * $tps);
  1014.             $totals["tvq"] = $this->getTvq() + ($this->getTransport() * $tvq);
  1015.             $totals["total"] = ($totals["net"] + $totals["tps"] + $totals["tvq"]);
  1016.         }
  1017.         $totals["acompte"] = $this->getAcompteUtilise();
  1018. //        $totals["total"] -= $this->getAcompteUtilise();
  1019.         $totals["monaie"] = $this->getMonnaie();
  1020.         // Ajoute le transport
  1021.         $totals["total"] += $this->getTransport();
  1022.         //Calcul coupons total
  1023.         if (empty($totals["rabaisP"]) && empty($totals["rabaisM"]) &&
  1024.             (!empty($this->getComptant()) || !empty($this->getInteract()))
  1025.         ) {
  1026.             $totals["coupons"] = round(
  1027.                 ((($this->getComptant()+$this->getInteract()) * self::COUPONS_POURCENT) / 100)
  1028.             , 2);
  1029.             if ($totals["coupons"] < 0) {
  1030.                 $totals["coupons"] = 0;
  1031.             }
  1032.         }
  1033.         return $totals;
  1034.     }
  1035.     /**
  1036.      * @return array
  1037.      */
  1038.     public function getPaiementsUsed() : array
  1039.     {
  1040.         $paiements = [];
  1041.         if ($this->getComptant()) {
  1042.             $paiements['comptant'] = $this->getComptant();
  1043.         }
  1044.         if ($this->getInteract()) {
  1045.             $paiements['interact'] = $this->getInteract();
  1046.         }
  1047.         if ($this->getCarteMC()) {
  1048.             $paiements['carteMC'] = $this->getCarteMC();
  1049.         }
  1050.         if ($this->getCarteV()) {
  1051.             $paiements['carteV'] = $this->getCarteV();
  1052.         }
  1053.         if ($this->getCoupons()) {
  1054.             $paiements['coupons'] = $this->getCoupons();
  1055.         }
  1056.         if ($this->getCertificatsCadeaux()) {
  1057.             $paiements['certifCadeaux'] = $this->getCertificatsCadeaux();
  1058.         }
  1059.         if ($this->getCertificatsCentre()) {
  1060.             $paiements['certifCentre'] = $this->getCertificatsCentre();
  1061.         }
  1062.         if ($this->getAcompteUtilise()) {
  1063.             $paiements['acompteUtilise'] = $this->getAcompteUtilise();
  1064.         }
  1065.         return $paiements;
  1066.     }
  1067.     public function getRabaisTotal($withEscompte false)
  1068.     {
  1069.         $total 0;
  1070.         /** @var FacturesDetail $detail */
  1071.         foreach ($this->getDetails() as $detail) {
  1072.             $total += $detail->getRabaisTotal();
  1073.             if ($withEscompte) {
  1074.                 $total += $detail->getEscm();
  1075.             }
  1076.         }
  1077.         return $total;
  1078.     }
  1079.     /**
  1080.      * get all quantity on all details
  1081.      * @return array
  1082.      */
  1083.     public function getTotalsQuantity() {
  1084.         $livre $commande 0;
  1085.         /** @var FacturesDetail $detail */
  1086.         foreach ($this->getDetails() as $detail) {
  1087.             $livre += $detail->getQuantiteeLivree();
  1088.             $commande += $detail->getQuantiteeCommandee();
  1089.         }
  1090.         return [$livre$commande];
  1091.     }
  1092. }