<?php
namespace App\Entity;
use App\Repository\ProjectOrdersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ProjectOrdersRepository::class)
*/
class ProjectOrders
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "order.base",
* "project.orders",
* "worker.manage.base.timesheet",
* "worker.manage.base.timesheet.payments",
* "customer.selected.project",
*
* "project.details.orders",
* "order.detail",
*
* "order.moveable",
*
* "project.orders.expense.assigned.order.base",
*
* "project.order.expense.need",
*
* "order.core", "order@core",
*
* "order.minify.core", "order_minify@core"
*
*
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Projects::class, inversedBy="project_orders" )
* @ORM\JoinColumn(nullable=false)
* @Groups({
* "order.assigned.project",
* "project.order.project"
* })
*/
#
private $project;
/**
* A manipulated or simulated column is used to prevent circular references.
* It is used for retrieving the necessary information related to an project in expenses positions to generate
* a list of minified project for the associated spending
* @Groups({
* "project.orders.expense.position.base",
* })
*/
private array $required_project_details_of_order_for_expense_position;
/**
* @return array
*/
public function getRequiredProjectDetailsOfOrderForExpensePosition(): array
{
return [
"id" => $this->getProject()->getId(),
"project_id" => $this->getProject()->getProjectId(),
"name" => $this->getProject()->getName()
];
}
/**
* @ORM\Column(type="string", length=64)
* @Groups({
* "project.orders",
* "worker.manage.base.timesheet",
* "worker.manage.base.timesheet.payments",
* "customer.selected.project",
*
* "project.details.orders",
* "order.detail",
*
* "order.moveable",
* "order.base",
* "project.orders.expense.assigned.order.base",
*
* "project.order.expense.need",
*
* "order.core", "order@core"
*
* })
*/
private $order_nr;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "project.orders",
* "worker.manage.base.timesheet",
*
* "project.details.orders",
* "order.detail"
*
*
*
* })
*/
private $order_description;
/**
* @ORM\Column(type="float")
* @Groups({
* "project.orders",
* "worker.manage.base.timesheet",
*
* "project.details.orders",
* "order.detail",
* "project.order.core"
*
* })
*/
// TODO This should be replace with order_price
private $order_prise;
/**
* @deprecated
* @ORM\OneToMany(targetEntity=WorkerTimesheetPayments::class, mappedBy="project_order")
*/
private $workerTimesheetPayments;
/**
* @deprecated use status inside feedback
* @ORM\Column(type="integer", nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $order_status;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $should_end_at;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $is_end_at;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $hourly_rate;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderFeedback::class, mappedBy="project_order", orphanRemoval=true, cascade={"persist", "remove"})
* @Groups({
* "project.details.orders",
* "order.detail"
* })
* @ORM\OrderBy({"created_at": "DESC"})
*/
private $project_order_feedback;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderInvoices::class, mappedBy="project_order", orphanRemoval=true, cascade={"persist", "remove"})
* @Groups({
* "project.details.orders",
* "order.detail"
* })
* @ORM\OrderBy({"created_at": "DESC"})
*/
private $project_order_invoices;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $order_at;
/**
* @ORM\ManyToOne(targetEntity=ProjectOwnerContactPersons::class, inversedBy="projectOrders")
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $contact_person;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="projectOrders")
*/
private $author;
/**
* @deprecated use $projectOrderExpenses
* @ORM\OneToMany(targetEntity=ProjectOrderExtraCosts::class, mappedBy="project_order")
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $project_order_extra_costs;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail",
* "order.base"
* })
*/
private $project_owner_order_nr;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $hours_spent;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $cost_spent;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderUndertakings::class, mappedBy="project_order")
* @Groups({
* "project.details.orders",
* "order.detail"
* })
* @ORM\OrderBy({"created_at": "DESC"})
*/
private $project_order_undertakings;
/**
* @ORM\ManyToOne(targetEntity=InvoiceType::class, inversedBy="projectOrders")
* ORM\Column(options={"comment": "Type of invoice, this order is standard or Undertaking via (Gutschrift) use as default Customer Invoice type"})
* @Groups({
* "project.details.orders",
* "order.detail"
* })
*/
private $invoice_type;
/**
* TODO this should be move to worker_activity
* @ORM\ManyToOne(targetEntity=Worker::class, inversedBy="projectOrders")
* @Groups({
* "project.details.orders",
* "order.detail",
* "project.orders.core",
*
* "project.order.lead"
* })
*/
private $order_lead;
/**
* TODO this should be move to worker_activity
* @ORM\ManyToOne(targetEntity=WorkerActivities::class, inversedBy="projectOrders")
* @ORM\JoinColumn(options={"comment": "This relation-ship from merged 'worker' over worker_activities table"})
* @Groups({*
* "order.lead.worker.activity"
* })
*/
private $order_primary_lead;
/**
* @ORM\ManyToMany(targetEntity=WorkerActivities::class)
* @ORM\JoinTable(
* name="project_order_alternate_leads",
* joinColumns={@ORM\JoinColumn(name="project_order_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="worker_activity_id", referencedColumnName="id")})
* @Groups({
* "worker.alternate.leads",
* })
*/
private $order_alternate_leads;
/**
* @deprecated
* @ORM\OneToMany(targetEntity=ProjectOrderExpenses::class, mappedBy="project_order")
* @Groups({
* "project.details.orders.expenses"
* })
*/
private $project_order_expenses;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderExpensePositions::class, mappedBy="project_order")
* @Groups({
*
* "project.orders.expense.positions",
*
* "project.orders.expense.minify.version",
* })
*/
private $project_order_expense_positions;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "order.detail",
* "project.details.orders",
* "project.order.core"
* })
*/
private $material_budget_as_percent;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "order.detail",
* "project.details.orders"
* })
*/
private $timesheet_budget_as_percent;
/**
* Prise 10.000 %20 gewinn ziel 2.000
* Materialkosten: %30 10.000 => 3.300
* Timesheetkosten: %50 10.000 => 5000
* 10000 - (3.300 + 5000) => 8.300
* 10 2000
* ? 1700
*/
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "order.detail",
* "project.details.orders"
* })
*/
private $target_profit_as_percent;
/**
* @ORM\ManyToOne(targetEntity=Branches::class, inversedBy="projectOrders")
* @Groups({
* "branch",
* "project.order.branch",
* "order.base"
* })
*/
private $order_branch;
/**
* @ORM\ManyToOne(targetEntity=BranchDepartements::class, inversedBy="projectOrders")
* @Groups({
* "branch.departement",
* "project.order.branch.departement"
* })
*/
private $branch_departement;
/**
* @ORM\ManyToMany(targetEntity=WorkerActivities::class, inversedBy="assigned_orders")
*/
private $assigned_workers;
/**
* @ORM\OneToMany(targetEntity=StockIssue::class, mappedBy="project_order")
* @Groups({
* "project_order@stock_issues"
* })
*/
private $stock_issues;
/**
* @ORM\OneToMany(targetEntity=StockTransactions::class, mappedBy="project_order_id")
*/
private $stock_transactions;
public function __construct()
{
$this->workerTimesheetPayments = new ArrayCollection();
$this->project_order_feedback = new ArrayCollection();
$this->project_order_invoices = new ArrayCollection();
$this->project_order_extra_costs = new ArrayCollection();
$this->project_order_undertakings = new ArrayCollection();
$this->project_order_expenses = new ArrayCollection();
$this->project_order_expense_positions = new ArrayCollection();
$this->order_alternate_leads = new ArrayCollection();
$this->assigned_workers = new ArrayCollection();
$this->stock_issues = new ArrayCollection();
$this->stock_transactions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getProject(): ?Projects
{
return $this->project;
}
public function setProject(?Projects $project): self
{
$this->project = $project;
return $this;
}
public function getOrderNr(): ?string
{
return $this->order_nr;
}
public function setOrderNr(string $order_nr): self
{
$this->order_nr = $order_nr;
return $this;
}
public function getOrderDescription(): ?string
{
return $this->order_description;
}
public function setOrderDescription(?string $order_description): self
{
$this->order_description = $order_description;
return $this;
}
public function getOrderPrise(): ?float
{
return $this->order_prise;
}
public function setOrderPrise(float $order_prise): self
{
$this->order_prise = $order_prise;
return $this;
}
/**
* @return Collection<int, WorkerTimesheetPayments>
*/
public function getWorkerTimesheetPayments(): Collection
{
return $this->workerTimesheetPayments;
}
public function addWorkerTimesheetPayment(WorkerTimesheetPayments $workerTimesheetPayment): self
{
if (!$this->workerTimesheetPayments->contains($workerTimesheetPayment)) {
$this->workerTimesheetPayments[] = $workerTimesheetPayment;
$workerTimesheetPayment->setProjectOrder($this);
}
return $this;
}
public function removeWorkerTimesheetPayment(WorkerTimesheetPayments $workerTimesheetPayment): self
{
if ($this->workerTimesheetPayments->removeElement($workerTimesheetPayment)) {
// set the owning side to null (unless already changed)
if ($workerTimesheetPayment->getProjectOrder() === $this) {
$workerTimesheetPayment->setProjectOrder(null);
}
}
return $this;
}
/**
* @deprecated since 1.27 (to be removed in 2.0). Use getOrderStatus() instead feedback.
*/
public function getOrderStatus(): ?int
{
return $this->order_status;
}
/**
* @deprecated since 1.27 (to be removed in 2.0). Use getOrderStatus() instead feedback.
*/
public function setOrderStatus(?int $order_status): self
{
$this->order_status = $order_status;
return $this;
}
public function getShouldEndAt(): ?\DateTimeImmutable
{
return $this->should_end_at;
}
public function setShouldEndAt(?\DateTimeImmutable $should_end_at): self
{
$this->should_end_at = $should_end_at;
return $this;
}
public function getIsEndAt(): ?\DateTimeImmutable
{
return $this->is_end_at;
}
public function setIsEndAt(?\DateTimeImmutable $is_end_at): self
{
$this->is_end_at = $is_end_at;
return $this;
}
public function getHourlyRate(): ?float
{
return $this->hourly_rate;
}
public function setHourlyRate(?float $hourly_rate): self
{
$this->hourly_rate = $hourly_rate;
return $this;
}
/**
* @return Collection<int, ProjectOrderFeedback>
*/
public function getProjectOrderFeedback(): Collection
{
return $this->project_order_feedback;
}
public function addProjectOrderFeedback(ProjectOrderFeedback $projectOrderFeedback): self
{
if (!$this->project_order_feedback->contains($projectOrderFeedback)) {
$this->project_order_feedback[] = $projectOrderFeedback;
$projectOrderFeedback->setProjectOrder($this);
}
return $this;
}
public function removeProjectOrderFeedback(ProjectOrderFeedback $projectOrderFeedback): self
{
if ($this->project_order_feedback->removeElement($projectOrderFeedback)) {
// set the owning side to null (unless already changed)
if ($projectOrderFeedback->getProjectOrder() === $this) {
$projectOrderFeedback->setProjectOrder(null);
}
}
return $this;
}
/**
* @return Collection<int, ProjectOrderInvoices>
*/
public function getProjectOrderInvoices(): Collection
{
return $this->project_order_invoices;
}
public function addProjectOrderInvoice(ProjectOrderInvoices $projectOrderInvoice): self
{
if (!$this->project_order_invoices->contains($projectOrderInvoice)) {
$this->project_order_invoices[] = $projectOrderInvoice;
$projectOrderInvoice->setProjectOrder($this);
}
return $this;
}
public function removeProjectOrderInvoice(ProjectOrderInvoices $projectOrderInvoice): self
{
if ($this->project_order_invoices->removeElement($projectOrderInvoice)) {
// set the owning side to null (unless already changed)
if ($projectOrderInvoice->getProjectOrder() === $this) {
$projectOrderInvoice->setProjectOrder(null);
}
}
return $this;
}
public function getOrderAt(): ?\DateTimeImmutable
{
return $this->order_at;
}
public function setOrderAt(?\DateTimeImmutable $order_at): self
{
$this->order_at = $order_at;
return $this;
}
public function getContactPerson(): ?ProjectOwnerContactPersons
{
return $this->contact_person;
}
public function setContactPerson(?ProjectOwnerContactPersons $contact_person): self
{
$this->contact_person = $contact_person;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
/**
* @return Collection<int, ProjectOrderExtraCosts>
*/
public function getProjectOrderExtraCosts(): Collection
{
return $this->project_order_extra_costs;
}
public function addProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
{
if (!$this->project_order_extra_costs->contains($projectOrderExtraCost)) {
$this->project_order_extra_costs[] = $projectOrderExtraCost;
$projectOrderExtraCost->setProjectOrder($this);
}
return $this;
}
public function removeProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
{
if ($this->project_order_extra_costs->removeElement($projectOrderExtraCost)) {
// set the owning side to null (unless already changed)
if ($projectOrderExtraCost->getProjectOrder() === $this) {
$projectOrderExtraCost->setProjectOrder(null);
}
}
return $this;
}
public function getProjectOwnerOrderNr(): ?string
{
return $this->project_owner_order_nr;
}
public function setProjectOwnerOrderNr(?string $project_owner_order_nr): self
{
$this->project_owner_order_nr = $project_owner_order_nr;
return $this;
}
public function getHoursSpent(): ?float
{
return $this->hours_spent;
}
public function setHoursSpent(?float $hours_spent): self
{
$this->hours_spent = $hours_spent;
return $this;
}
public function getCostSpent(): ?float
{
return $this->cost_spent;
}
public function setCostSpent(?float $cost_spent): self
{
$this->cost_spent = $cost_spent;
return $this;
}
/**
* @return Collection<int, ProjectOrderUndertakings>
*/
public function getProjectOrderUndertakings(): Collection
{
return $this->project_order_undertakings;
}
public function addProjectOrderUndertaking(ProjectOrderUndertakings $project_order_undertaking): self
{
if (!$this->project_order_undertakings->contains($project_order_undertaking)) {
$this->project_order_undertakings[] = $project_order_undertaking;
$project_order_undertaking->setProjectOrder($this);
}
return $this;
}
public function removeProjectOrderUndetaking(ProjectOrderUndertakings $project_order_undertaking): self
{
if ($this->project_order_undertakings->removeElement($project_order_undertaking)) {
// set the owning side to null (unless already changed)
if ($project_order_undertaking->getProjectOrder() === $this) {
$project_order_undertaking->setProjectOrder(null);
}
}
return $this;
}
public function getInvoiceType(): ?InvoiceType
{
return $this->invoice_type;
}
public function setInvoiceType(?InvoiceType $invoice_type): self
{
$this->invoice_type = $invoice_type;
return $this;
}
public function getOrderLead(): ?Worker
{
return $this->order_lead;
}
public function setOrderLead(?Worker $order_lead): self
{
$this->order_lead = $order_lead;
return $this;
}
public function getOrderPrimaryLead(): ?WorkerActivities
{
return $this->order_primary_lead;
}
public function setOrderPrimaryLead(?WorkerActivities $order_lead): self
{
$this->order_primary_lead = $order_lead;
return $this;
}
/**
* @return Collection<int, ProjectOrderExpenses>
*/
public function getProjectOrderExpenses(): Collection
{
return $this->project_order_expenses;
}
public function addProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
{
if (!$this->project_order_expenses->contains($projectOrderExpense)) {
$this->project_order_expenses[] = $projectOrderExpense;
$projectOrderExpense->setProjectOrder($this);
}
return $this;
}
public function removeProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
{
if ($this->project_order_expenses->removeElement($projectOrderExpense)) {
// set the owning side to null (unless already changed)
if ($projectOrderExpense->getProjectOrder() === $this) {
$projectOrderExpense->setProjectOrder(null);
}
}
return $this;
}
/**
* @return Collection<int, ProjectOrderExpensePositions>
*/
public function getProjectOrderExpensePositions(): Collection
{
return $this->project_order_expense_positions;
}
public function addProjectOrderExpensePosition(ProjectOrderExpensePositions $projectOrderExpensePosition): self
{
if (!$this->project_order_expense_positions->contains($projectOrderExpensePosition)) {
$this->project_order_expense_positions[] = $projectOrderExpensePosition;
$projectOrderExpensePosition->setProjectOrder($this);
}
return $this;
}
public function removeProjectOrderExpensePosition(ProjectOrderExpensePositions $projectOrderExpensePosition): self
{
if ($this->project_order_expense_positions->removeElement($projectOrderExpensePosition)) {
// set the owning side to null (unless already changed)
if ($projectOrderExpensePosition->getProjectOrder() === $this) {
$projectOrderExpensePosition->setProjectOrder(null);
}
}
return $this;
}
public function getMaterialBudgetAsPercent(): ?float
{
return $this->material_budget_as_percent;
}
public function setMaterialBudgetAsPercent(?float $material_budget_as_percent): self
{
$this->material_budget_as_percent = $material_budget_as_percent;
return $this;
}
public function getTimesheetBudgetAsPercent(): ?float
{
return $this->timesheet_budget_as_percent;
}
public function setTimesheetBudgetAsPercent(?float $timesheet_budget_as_percent): self
{
$this->timesheet_budget_as_percent = $timesheet_budget_as_percent;
return $this;
}
public function getTargetProfitAsPercent(): ?float
{
return $this->target_profit_as_percent;
}
public function setTargetProfitAsPercent(?float $target_profit_as_percent): self
{
$this->target_profit_as_percent = $target_profit_as_percent;
return $this;
}
/**
* @return Collection<int, WorkerActivities>
*/
public function getOrderAlternateLeads(): Collection
{
return $this->order_alternate_leads;
}
public function addOrderAlternateLead(WorkerActivities $orderAlternateLead): self
{
if (!$this->order_alternate_leads->contains($orderAlternateLead)) {
$this->order_alternate_leads[] = $orderAlternateLead;
}
return $this;
}
public function removeOrderAlternateLead(WorkerActivities $orderAlternateLead): self
{
$this->order_alternate_leads->removeElement($orderAlternateLead);
return $this;
}
public function getOrderBranch(): ?Branches
{
return $this->order_branch;
}
public function setOrderBranch(?Branches $order_branch): self
{
$this->order_branch = $order_branch;
return $this;
}
public function getBranchDepartement(): ?BranchDepartements
{
return $this->branch_departement;
}
public function setBranchDepartement(?BranchDepartements $branch_departement): self
{
$this->branch_departement = $branch_departement;
return $this;
}
/**
* @return Collection<int, WorkerActivities>
*/
public function getAssignedWorkers(): Collection
{
return $this->assigned_workers;
}
public function addAssignedWorker(WorkerActivities $assignedWorker): self
{
if (!$this->assigned_workers->contains($assignedWorker)) {
$this->assigned_workers[] = $assignedWorker;
}
return $this;
}
public function removeAssignedWorker(WorkerActivities $assignedWorker): self
{
$this->assigned_workers->removeElement($assignedWorker);
return $this;
}
/**
* @return Collection<int, StockIssue>
*/
public function getStockIssues(): Collection
{
return $this->stock_issues;
}
public function addStockIssue(StockIssue $stockIssue): self
{
if (!$this->stock_issues->contains($stockIssue)) {
$this->stock_issues[] = $stockIssue;
$stockIssue->setProjectOrder($this);
}
return $this;
}
public function removeStockIssue(StockIssue $stockIssue): self
{
if ($this->stock_issues->removeElement($stockIssue)) {
// set the owning side to null (unless already changed)
if ($stockIssue->getProjectOrder() === $this) {
$stockIssue->setProjectOrder(null);
}
}
return $this;
}
/**
* @return Collection<int, StockTransactions>
*/
public function getStockTransactions(): Collection
{
return $this->stock_transactions;
}
public function addStockTransaction(StockTransactions $stockTransaction): self
{
if (!$this->stock_transactions->contains($stockTransaction)) {
$this->stock_transactions[] = $stockTransaction;
$stockTransaction->setProjectOrder($this);
}
return $this;
}
public function removeStockTransaction(StockTransactions $stockTransaction): self
{
if ($this->stock_transactions->removeElement($stockTransaction)) {
// set the owning side to null (unless already changed)
if ($stockTransaction->getProjectOrder() === $this) {
$stockTransaction->setProjectOrder(null);
}
}
return $this;
}
}