src/Entity/ExpenseRequest.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ExpenseRequestRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Entity(repositoryClassExpenseRequestRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class ExpenseRequest
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     #[Groups(['LogService'])]
  17.     private ?int $id null;
  18.     #[ORM\Column(length10nullabletrue)]
  19.     #[Groups(['LogService'])]
  20.     private ?string $generatedId null;
  21.     #[ORM\Column(length255)]
  22.     #[Groups(['LogService'])]
  23.     private ?string $title null;
  24.     #[ORM\ManyToOne(inversedBy'expenseRequests')]
  25.     private ?User $requester null;
  26.     #[ORM\Column(length255nullabletrue)]
  27.     #[Groups(['LogService'])]
  28.     private ?string $expenditureType null;
  29.     #[ORM\Column]
  30.     private ?\DateTimeImmutable $createdAt null;
  31.     #[ORM\Column(nullabletrue)]
  32.     private ?\DateTimeImmutable $updatedAt null;
  33.     #[ORM\Column(nullabletrue)]
  34.     private ?\DateTimeImmutable $deletedAt null;
  35.     #[ORM\Column(length10nullabletrue)]
  36.     private ?string $status null;
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $supplierName null;
  39.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  40.     private ?string $supplierUrl null;
  41.     #[ORM\ManyToOne(inversedBy'expenseRequests')]
  42.     #[Groups(['LogService'])]
  43.     private ?Currency $currency null;
  44.     #[ORM\Column(length255nullabletrue)]
  45.     #[Groups(['LogService'])]
  46.     private ?string $amount null;
  47.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  48.     private ?string $costJustification null;
  49.     #[ORM\ManyToOne(inversedBy'expenseRequests')]
  50.     private ?Client $client null;
  51.     #[ORM\ManyToOne(inversedBy'expenseRequests')]
  52.     private ?Project $project null;
  53.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  54.     private ?string $ProjectLink null;
  55.     #[ORM\Column(nullabletrue)]
  56.     private ?\DateTimeImmutable $paymentScheduled null;
  57.     #[ORM\Column(length255nullabletrue)]
  58.     private ?string $paymentMethod null;
  59.     #[ORM\Column(nullabletrue)]
  60.     private ?\DateTimeImmutable $paymentDate null;
  61.     #[ORM\Column(length255nullabletrue)]
  62.     private ?string $invoiceNo null;
  63.     #[ORM\Column(length255nullabletrue)]
  64.     private ?string $invoiceFile null;
  65.     #[ORM\Column(length255nullabletrue)]
  66.     #[Groups(['LogService'])]
  67.     private ?string $finalStep null;
  68.     #[ORM\ManyToOne(inversedBy'expenseRequests')]
  69.     private ?Vendor $supplier null;
  70.     #[ORM\Column(length255nullabletrue)]
  71.     private ?string $recurring null;
  72.     #[ORM\Column(nullabletrue)]
  73.     private ?\DateTimeImmutable $paymentEndDate null;
  74.     #[ORM\Column(nullabletrue)]
  75.     #[Groups(['LogService'])]
  76.     private ?bool $isApproved null;
  77.     #[ORM\Column(nullabletrue)]
  78.     private ?\DateTimeImmutable $draftedAt null;
  79.     #[ORM\Column(nullabletrue)]
  80.     private ?\DateTimeImmutable $submittedAt null;
  81.     #[ORM\Column(nullabletrue)]
  82.     private ?\DateTimeImmutable $approvedAt null;
  83.     #[ORM\Column(nullabletrue)]
  84.     private ?\DateTimeImmutable $rejectedAt null;
  85.     #[ORM\Column(nullabletrue)]
  86.     private ?\DateTimeImmutable $processedAt null;
  87.     #[ORM\Column(nullabletrue)]
  88.     private ?\DateTimeImmutable $archivedAt null;
  89.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  90.     private ?string $notes null;
  91.     #[ORM\OneToMany(mappedBy'expenseRequest'targetEntityExpenseRequestInvoice::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  92.     #[Groups(['LogService'])]
  93.     private Collection $expenseRequestInvoices;
  94.     #[ORM\Column(nullabletrue)]
  95.     private ?\DateTimeImmutable $lastReminder null;
  96.     #[ORM\OneToMany(mappedBy'expenseRequest'targetEntityExpenseRequestFile::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  97.     #[Groups(['LogService'])]
  98.     private Collection $expenseRequestFiles;
  99.     public function __construct()
  100.     {
  101.         $this->expenseRequestInvoices = new ArrayCollection();
  102.         $this->expenseRequestFiles = new ArrayCollection();
  103.     }
  104.     public function getId(): ?int
  105.     {
  106.         return $this->id;
  107.     }
  108.     public function getGeneratedId(): ?string
  109.     {
  110.         return $this->generatedId;
  111.     }
  112.     public function setGeneratedId(?string $generatedId): self
  113.     {
  114.         $this->generatedId $generatedId;
  115.         return $this;
  116.     }
  117.     public function getTitle(): ?string
  118.     {
  119.         return $this->title;
  120.     }
  121.     public function setTitle(string $title): self
  122.     {
  123.         $this->title $title;
  124.         return $this;
  125.     }
  126.     public function getRequester(): ?User
  127.     {
  128.         return $this->requester;
  129.     }
  130.     public function setRequester(?User $requester): self
  131.     {
  132.         $this->requester $requester;
  133.         return $this;
  134.     }
  135.     public function getExpenditureType(): ?string
  136.     {
  137.         return $this->expenditureType;
  138.     }
  139.     public function setExpenditureType(?string $expenditureType): self
  140.     {
  141.         $this->expenditureType $expenditureType;
  142.         return $this;
  143.     }
  144.     #[ORM\PrePersist]
  145.     public function setCreatedAtValue(): void
  146.     {
  147.         $this->createdAt = new \DateTimeImmutable();
  148.     }
  149.     public function getCreatedAt(): ?\DateTimeImmutable
  150.     {
  151.         return $this->createdAt;
  152.     }
  153.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  154.     {
  155.         $this->createdAt $createdAt;
  156.         return $this;
  157.     }
  158.     public function getUpdatedAt(): ?\DateTimeImmutable
  159.     {
  160.         return $this->updatedAt;
  161.     }
  162.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  163.     {
  164.         $this->updatedAt $updatedAt;
  165.         return $this;
  166.     }
  167.     public function getDeletedAt(): ?\DateTimeImmutable
  168.     {
  169.         return $this->deletedAt;
  170.     }
  171.     public function setDeletedAt(?\DateTimeImmutable $deletedAt): self
  172.     {
  173.         $this->deletedAt $deletedAt;
  174.         return $this;
  175.     }
  176.     public function getStatus(): ?string
  177.     {
  178.         return intval($this->status);
  179.     }
  180.     public function setStatus(?string $status): self
  181.     {
  182.         $this->status $status;
  183.         return $this;
  184.     }
  185.     public function getStatusChoices()
  186.     {
  187.         $processed 'processed';
  188.         if($this->recurring == NULL){
  189.             // if($this->expenseRequestInvoices){
  190.             //     foreach($this->expenseRequestInvoices as $invoice){
  191.             //         if($invoice->getXeroStatus()){
  192.             //             $status = $invoice->getXeroStatus();
  193.             //             $processed .= ' - [' . substr($status, 0, 1) . ']';
  194.             //         }
  195.             //     }
  196.             // }
  197.             if (count($this->expenseRequestInvoices) > 1) {
  198.                 $initials = [];
  199.                 foreach ($this->expenseRequestInvoices as $invoice) {
  200.                     if ($invoice->getXeroStatus() && $invoice->getXeroStatus() != 'DELETED') {
  201.                         $initials[] = substr($invoice->getXeroStatus(), 01);
  202.                     }
  203.                 }
  204.                 $processed .= ' - [' implode(', '$initials) . ']';
  205.             } else {
  206.                 foreach ($this->expenseRequestInvoices as $invoice) {
  207.                     if ($invoice->getXeroStatus()) {
  208.                         $processed .= ' - [' $invoice->getXeroStatus() . ']';
  209.                     }
  210.                 }
  211.             }
  212.         }
  213.         $approvalMade $this->isIsApproved() == true 'Approved' : ($this->isIsApproved() == false 'Rejected' 'Approval Made');
  214.         return [
  215.             'Draft' => 1,
  216.             'Pending Approval' => 2,
  217.             $approvalMade => 3,
  218.             'Finance to Process' => 4,
  219.             $processed => 5,
  220.             'Archived' => 6,
  221.         ];
  222.     }
  223.     public function getStatusBadgeClass()
  224.     {
  225.         $status $this->getStatus();
  226.         $isApproved $this->isIsApproved();
  227.         $badge 'badge badge-secondary';
  228.         switch ($status) {
  229.           case 1:
  230.               $badge 'badge badge-light';
  231.               break;
  232.           case 2:
  233.               $badge 'badge badge-warning';
  234.               break;
  235.           case 3:
  236.               if ($isApproved === true) {
  237.                   $badge 'badge badge-success';
  238.               } elseif ($isApproved === false) {
  239.                   $badge 'badge badge-danger';
  240.               }
  241.               break;
  242.           case 4:
  243.               $badge 'badge badge-info';
  244.               break;
  245.           case 5:
  246.               $badge 'badge badge-primary';
  247.               break;
  248.           case 6:
  249.               $badge 'badge badge-secondary';
  250.               break;
  251.           default:
  252.               $badge 'badge badge-secondary';
  253.         }
  254.         return $badge;
  255.     }
  256.     public function getStatusText()
  257.     {
  258.         $status $this->getStatus();
  259.         $isApproved $this->isIsApproved();
  260.         $statuses array_flip($this->getStatusChoices());
  261.         return isset($statuses[$status]) ? $statuses[$status] : null;
  262.     }
  263.     public function getStatusDesc()
  264.     {
  265.         $status $this->getStatus();
  266.         $isApproved $this->isIsApproved();
  267.         $desc '';
  268.         switch ($status) {
  269.             case 1:
  270.                 $desc 'User started completing the Expense request form but did not submit it for approval.';
  271.                 break;
  272.             case 2:
  273.                 $desc 'User completed the Expense request form and it is now pending management approval.';
  274.                 break;
  275.             case 3:
  276.                 if ($isApproved === true) {
  277.                     $desc 'Management approved the Expense request form. Requester needs to upload the Invoice and submit it to finance. It will be automatically saved as Draft in Xero.';
  278.                 } elseif ($isApproved === false) {
  279.                     $desc 'Management rejected the Expense request form.';
  280.                 }
  281.                 break;
  282.             case 4:
  283.                 $desc 'Finance needs to approve the invoice in Xero and ask Requester to input the invoice in the Vendor planning section of HRP’s project.';
  284.                 break;
  285.             case 5:
  286.                 $desc 'Finance has processed the payment or reimbursement of the invoice. Other invoices can be added to the project (especially for projects with recurring invoices). Expense request ID form is still active.';
  287.                 break;
  288.             case 6:
  289.                 $desc 'Finance has processed the payment or reimbursement of the invoice(s) and consider the Expense request ID form terminated.';
  290.                 break;
  291.             default:
  292.                 $desc '';
  293.           }
  294.         return $desc;
  295.     }
  296.     public function getSupplierName(): ?string
  297.     {
  298.         return $this->supplierName;
  299.     }
  300.     public function setSupplierName(?string $supplierName): self
  301.     {
  302.         $this->supplierName $supplierName;
  303.         return $this;
  304.     }
  305.     public function getSupplierUrl(): ?string
  306.     {
  307.         return $this->supplierUrl;
  308.     }
  309.     public function setSupplierUrl(?string $supplierUrl): self
  310.     {
  311.         $this->supplierUrl $supplierUrl;
  312.         return $this;
  313.     }
  314.     public function getCurrency(): ?Currency
  315.     {
  316.         return $this->currency;
  317.     }
  318.     public function setCurrency(?Currency $currency): self
  319.     {
  320.         $this->currency $currency;
  321.         return $this;
  322.     }
  323.     public function getAmount(): ?string
  324.     {
  325.         return $this->amount;
  326.     }
  327.     public function getAmountUsd()
  328.     {
  329.         global $kernel;
  330.         $currencyService $kernel->getContainer()->get('CurrencyService');
  331.         $amountUsd $currencyService->convertAtDate($this->createdAt$this->currency->getIso(), 'USD'$this->amount);
  332.         return round($amountUsd2PHP_ROUND_HALF_EVEN);
  333.     }
  334.     public function setAmount(?string $amount): self
  335.     {
  336.         $this->amount $amount;
  337.         return $this;
  338.     }
  339.     public function getSpentAmount(){
  340.         $result 0;
  341.         if($this->expenseRequestInvoices){
  342.            foreach( $this->expenseRequestInvoices as $invoice){
  343.             $result += floatval($invoice->getTotalAmount());
  344.            }
  345.         }
  346.         return $result;
  347.     }
  348.     public function getSpentAmountUsd()
  349.     {
  350.         global $kernel;
  351.         $currencyService $kernel->getContainer()->get('CurrencyService');
  352.         $spentAmountUsd 0;
  353.         if ($this->expenseRequestInvoices) {
  354.             foreach ($this->expenseRequestInvoices as $invoice) {
  355.                 $invoiceAmount floatval($invoice->getTotalAmount());
  356.                 $invoiceCurrency $invoice->getCurrency() ? $invoice->getCurrency()->getIso() : 'USD';
  357.                 $invoiceDate $invoice->getCreatedAt();
  358.                 $convertedAmount $currencyService->convertAtDate($invoiceDate$invoiceCurrency'USD'$invoiceAmount);
  359.                 $spentAmountUsd += floatval($convertedAmount);
  360.             }
  361.         }
  362.         return $spentAmountUsd;
  363.     }
  364.     public function getInvoicesCurrency()
  365.     {
  366.         $currency 'USD';
  367.         if ($this->expenseRequestInvoices) {
  368.             foreach ($this->expenseRequestInvoices as $invoice) {
  369.                 $currency $invoice->getCurrency() ? $invoice->getCurrency()->getIso() : 'USD';
  370.             }
  371.         }
  372.         return $currency;
  373.     }
  374.     public function getCostJustification(): ?string
  375.     {
  376.         return $this->costJustification;
  377.     }
  378.     public function setCostJustification(?string $costJustification): self
  379.     {
  380.         $this->costJustification $costJustification;
  381.         return $this;
  382.     }
  383.     public function getClient(): ?Client
  384.     {
  385.         return $this->client;
  386.     }
  387.     public function setClient(?Client $client): self
  388.     {
  389.         $this->client $client;
  390.         return $this;
  391.     }
  392.     public function getProject(): ?Project
  393.     {
  394.         return $this->project;
  395.     }
  396.     public function setProject(?Project $project): self
  397.     {
  398.         $this->project $project;
  399.         return $this;
  400.     }
  401.     public function getProjectLink(): ?string
  402.     {
  403.         return $this->ProjectLink;
  404.     }
  405.     public function setProjectLink(?string $ProjectLink): self
  406.     {
  407.         $this->ProjectLink $ProjectLink;
  408.         return $this;
  409.     }
  410.     public function getPaymentScheduled(): ?\DateTimeImmutable
  411.     {
  412.         return $this->paymentScheduled;
  413.     }
  414.     public function setPaymentScheduled(?\DateTimeImmutable $paymentScheduled): self
  415.     {
  416.         $this->paymentScheduled $paymentScheduled;
  417.         return $this;
  418.     }
  419.     public function getPaymentMethod(): ?string
  420.     {
  421.         return $this->paymentMethod;
  422.     }
  423.     public function setPaymentMethod(?string $paymentMethod): self
  424.     {
  425.         $this->paymentMethod $paymentMethod;
  426.         return $this;
  427.     }
  428.     public function getPaymentDate(): ?\DateTimeImmutable
  429.     {
  430.         return $this->paymentDate;
  431.     }
  432.     public function setPaymentDate(?\DateTimeImmutable $paymentDate): self
  433.     {
  434.         $this->paymentDate $paymentDate;
  435.         return $this;
  436.     }
  437.     public function getInvoiceNo(): ?string
  438.     {
  439.         return $this->invoiceNo;
  440.     }
  441.     public function setInvoiceNo(?string $invoiceNo): self
  442.     {
  443.         $this->invoiceNo $invoiceNo;
  444.         return $this;
  445.     }
  446.     public function getInvoiceFile(): ?string
  447.     {
  448.         return $this->invoiceFile;
  449.     }
  450.     public function setInvoiceFile(?string $invoiceFile): self
  451.     {
  452.         $this->invoiceFile $invoiceFile;
  453.         return $this;
  454.     }
  455.     public function getFinalStep(): ?string
  456.     {
  457.         return $this->finalStep;
  458.     }
  459.     public function setFinalStep(?string $finalStep): self
  460.     {
  461.         $this->finalStep $finalStep;
  462.         return $this;
  463.     }
  464.     public function getSupplier(): ?Vendor
  465.     {
  466.         return $this->supplier;
  467.     }
  468.     public function setSupplier(?Vendor $supplier): self
  469.     {
  470.         $this->supplier $supplier;
  471.         return $this;
  472.     }
  473.     public function getRecurring(): ?string
  474.     {
  475.         return $this->recurring;
  476.     }
  477.     public function isRecurring(): ?bool
  478.     {
  479.         return !empty($this->recurring) ? true false;
  480.     }
  481.     public function setRecurring(?string $recurring): self
  482.     {
  483.         $this->recurring $recurring;
  484.         return $this;
  485.     }
  486.     public function getPaymentEndDate(): ?\DateTimeImmutable
  487.     {
  488.         return $this->paymentEndDate;
  489.     }
  490.     public function setPaymentEndDate(?\DateTimeImmutable $paymentEndDate): self
  491.     {
  492.         $this->paymentEndDate $paymentEndDate;
  493.         return $this;
  494.     }
  495.     public function isIsApproved(): ?bool
  496.     {
  497.         return $this->isApproved;
  498.     }
  499.     public function setIsApproved(?bool $isApproved): self
  500.     {
  501.         $this->isApproved $isApproved;
  502.         return $this;
  503.     }
  504.     public function getDraftedAt(): ?\DateTimeImmutable
  505.     {
  506.         return $this->draftedAt;
  507.     }
  508.     public function setDraftedAt(?\DateTimeImmutable $draftedAt): self
  509.     {
  510.         $this->draftedAt $draftedAt;
  511.         return $this;
  512.     }
  513.     public function getSubmittedAt(): ?\DateTimeImmutable
  514.     {
  515.         return $this->submittedAt;
  516.     }
  517.     public function setSubmittedAt(?\DateTimeImmutable $submittedAt): self
  518.     {
  519.         $this->submittedAt $submittedAt;
  520.         return $this;
  521.     }
  522.     public function getApprovedAt(): ?\DateTimeImmutable
  523.     {
  524.         return $this->approvedAt;
  525.     }
  526.     public function setApprovedAt(?\DateTimeImmutable $approvedAt): self
  527.     {
  528.         $this->approvedAt $approvedAt;
  529.         return $this;
  530.     }
  531.     public function getRejectedAt(): ?\DateTimeImmutable
  532.     {
  533.         return $this->rejectedAt;
  534.     }
  535.     public function setRejectedAt(?\DateTimeImmutable $rejectedAt): self
  536.     {
  537.         $this->rejectedAt $rejectedAt;
  538.         return $this;
  539.     }
  540.     public function getProcessedAt(): ?\DateTimeImmutable
  541.     {
  542.         return $this->processedAt;
  543.     }
  544.     public function setProcessedAt(?\DateTimeImmutable $processedAt): self
  545.     {
  546.         $this->processedAt $processedAt;
  547.         return $this;
  548.     }
  549.     public function getArchivedAt(): ?\DateTimeImmutable
  550.     {
  551.         return $this->archivedAt;
  552.     }
  553.     public function setArchivedAt(?\DateTimeImmutable $archivedAt): self
  554.     {
  555.         $this->archivedAt $archivedAt;
  556.         return $this;
  557.     }
  558.     public function getNotes(): ?string
  559.     {
  560.         return $this->notes;
  561.     }
  562.     public function setNotes(?string $notes): self
  563.     {
  564.         $this->notes $notes;
  565.         return $this;
  566.     }
  567.     /**
  568.      * @return Collection<int, ExpenseRequestInvoice>
  569.      */
  570.     public function getExpenseRequestInvoices(): Collection
  571.     {
  572.         return $this->expenseRequestInvoices;
  573.     }
  574.     public function getExpenseRequestInvoiceByInvNo(string $invoiceNo): ?ExpenseRequestInvoice
  575.     {
  576.         foreach ($this->expenseRequestInvoices as $file) {
  577.             if ($file->getInvoiceNo() === $invoiceNo) {
  578.                 return $file;
  579.             }
  580.         }
  581.         return null;
  582.     }
  583.     public function addExpenseRequestInvoice(ExpenseRequestInvoice $expenseRequestInvoice): self
  584.     {
  585.         if (!$this->expenseRequestInvoices->contains($expenseRequestInvoice)) {
  586.             $this->expenseRequestInvoices->add($expenseRequestInvoice);
  587.             $expenseRequestInvoice->setExpenseRequest($this);
  588.         }
  589.         return $this;
  590.     }
  591.     public function removeExpenseRequestInvoice(ExpenseRequestInvoice $expenseRequestInvoice): self
  592.     {
  593.         if ($this->expenseRequestInvoices->removeElement($expenseRequestInvoice)) {
  594.             // set the owning side to null (unless already changed)
  595.             if ($expenseRequestInvoice->getExpenseRequest() === $this) {
  596.                 $expenseRequestInvoice->setExpenseRequest(null);
  597.             }
  598.         }
  599.         return $this;
  600.     }
  601.     public function getLastReminder(): ?\DateTimeImmutable
  602.     {
  603.         return $this->lastReminder;
  604.     }
  605.     public function setLastReminder(?\DateTimeImmutable $lastReminder): self
  606.     {
  607.         $this->lastReminder $lastReminder;
  608.         return $this;
  609.     }
  610.     public function isProcessed(){
  611.         if($this->expenseRequestInvoices->count() > 0){
  612.             foreach($this->expenseRequestInvoices as $expenseInv){
  613.                 if($expenseInv->getProcessedAt() == null){
  614.                     return false;
  615.                 }
  616.             }
  617.             return true;
  618.         }
  619.     }
  620.     public function checkInvoices(){
  621.         if($this->expenseRequestInvoices->count() > 0){
  622.             foreach($this->expenseRequestInvoices as $expenseInv){
  623.                 if(empty($expenseInv->getInvoiceFile())){
  624.                     return false;
  625.                 }
  626.             }
  627.             return true;
  628.         }
  629.     }
  630.     /**
  631.      * @return Collection<int, ExpenseRequestFile>
  632.      */
  633.     public function getExpenseRequestFiles(): Collection
  634.     {
  635.         return $this->expenseRequestFiles;
  636.     }
  637.     public function getExpenseRequestFileByUuid(string $uuid): ?ExpenseRequestFile
  638.     {
  639.         foreach ($this->expenseRequestFiles as $file) {
  640.             if ($file->getUuid() === $uuid) {
  641.                 return $file;
  642.             }
  643.         }
  644.         return null;
  645.     }
  646.     public function addExpenseRequestFile(ExpenseRequestFile $expenseRequestFile): self
  647.     {
  648.         if (!$this->expenseRequestFiles->contains($expenseRequestFile)) {
  649.             $this->expenseRequestFiles->add($expenseRequestFile);
  650.             $expenseRequestFile->setExpenseRequest($this);
  651.         }
  652.         return $this;
  653.     }
  654.     public function removeExpenseRequestFile(ExpenseRequestFile $expenseRequestFile): self
  655.     {
  656.         if ($this->expenseRequestFiles->removeElement($expenseRequestFile)) {
  657.             // set the owning side to null (unless already changed)
  658.             if ($expenseRequestFile->getExpenseRequest() === $this) {
  659.                 $expenseRequestFile->setExpenseRequest(null);
  660.             }
  661.         }
  662.         return $this;
  663.     }
  664. }