<?php
namespace Diplix\KMGBundle\Entity\Accounting;
use Diplix\KMGBundle\Entity\Address;
use Diplix\KMGBundle\Entity\BasicEntity;
use Diplix\KMGBundle\Entity\Customer;
use Diplix\KMGBundle\Entity\Order;
use Diplix\KMGBundle\Repository\JobRepository;
use Diplix\KMGBundle\Service\Accounting\PaymentCalculator;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="acc_jobs", indexes={@ORM\Index(name="be_deleted",columns={"be_deleted"})})
* @ORM\Entity(repositoryClass="Diplix\KMGBundle\Repository\JobRepository")
*/
class Job extends BasicEntity
{
const GENERATED = 'generated';
const IMPORTED = 'imported';
const UNKNOWN = 'unknown';
public static $sourceMap = [
self::GENERATED => 'automatisch angelegt',
self::IMPORTED => 'importiert',
self::UNKNOWN => 'unbekannt'
];
public const RS_MIETWAGEN = 'm';
public const RS_TAXI = 't';
public static $rsMap = [
self::RS_MIETWAGEN => "Mietwagen",
self::RS_TAXI => "Taxi"
];
/**
* @ORM\Column(type="integer",name="id")
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* the tami order number
* @ORM\Column(type="string")
*/
protected $orderNumber;
/**
* @ORM\Column(type="datetime")
*/
protected $orderTime;
/**
* @ORM\Column(type="string")
*/
protected $customerName;
/**
* @ORM\Column(type="string")
*/
protected $originQuick;
/**
* @ORM\Column(type="string")
*/
protected $originStreet;
/**
* @ORM\Column(type="string")
*/
protected $originNumber;
/**
* @ORM\Column(type="string")
*/
protected $originZip;
/**
* @ORM\Column(type="string")
*/
protected $originCity;
/**
* @ORM\Column(type="string")
*/
protected $destinationQuick;
/**
* @ORM\Column(type="string")
*/
protected $destinationStreet;
/**
* @ORM\Column(type="string")
*/
protected $destinationNumber;
/**
* @ORM\Column(type="string")
*/
protected $destinationZip;
/**
* @ORM\Column(type="string")
*/
protected $destinationCity;
/**
* @ORM\Column(type="integer")
*/
protected $personCount;
/**
* @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":true})
*/
protected $distanceKm;
/**
* @ORM\Column(type="decimal", precision=12, scale=2,options={"unsigned":true})
*/
protected $waitTime;
/**
* @ORM\Column(type="string")
*/
protected $paymentType;
/**
* @ORM\Column(type="decimal", nullable=false, precision=12, scale=2,options={"unsigned":false})
*/
protected $price;
/**
* @ORM\Column(type="integer")
*/
protected $carId;
/**
* @ORM\Column(type="integer")
*/
protected $driverId;
/**
* @ORM\Column(type="text")
*/
protected $info;
/**
* @ORM\Column(type="string")
*/
protected $costCenter;
/**
* @ORM\Column(type="datetime",nullable=true)
*/
protected $jobReceivedTime;
/**
* @ORM\Column(type="datetime",nullable=true)
*/
protected $jobStartTime;
/**
* @ORM\Column(type="datetime",nullable=true)
*/
protected $jobDoneTime;
/**
* @ORM\Column(type="integer")
*/
protected $jobDuration;
/**
* @ORM\Column(type="integer")
*/
protected $relType;
/**
* @ORM\Column(type="string")
*/
protected $relId='';
/**
* @ORM\Column(type="string")
*/
protected $options = '';
/**
* @ORM\Column(type="json")
*/
protected $waypoints = [];
/**
* @ORM\Column(type="string")
*/
protected $source = self::UNKNOWN;
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* @ORM\Column(type="boolean")
*/
protected $approvedByDriver = false;
/**
* @ORM\Column(type="boolean")
*/
protected $approvedByPassenger = false;
/**
* @ORM\Column(type="boolean")
*/
protected $approvedByAccounting = false;
/**
* @ORM\Column(type="string")
*/
protected $confirmationPin = '';
/**
* @ORM\Column(type="boolean")
*/
protected $readyForBilling = false;
/**
* @ORM\Column(type="json")
*/
protected $lastReadyForBillingCheckResult = [];
/**
* @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\Accounting\BillingForMember", inversedBy="jobList", fetch="EAGER")
* @ORM\JoinColumn(nullable=true)
*/
protected $billingForMember;
/**
* @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\Accounting\BillingForCustomer", inversedBy="jobList", fetch="EAGER")
* @ORM\JoinColumn(nullable=true)
*/
protected $billingForCustomer;
/**
* @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\Accounting\CoopMember")
* @ORM\JoinColumn(nullable=true)
*/
protected $member;
/**
* @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\Customer")
* @ORM\JoinColumn(nullable=true)
*/
protected $customer;
/**
* @ORM\Column(type="time",nullable=true)
*/
protected $flightOnPositionTime;
/**
* @ORM\Column(type="time", nullable=true)
*/
protected $departureAtOriginTime;
/**
* @ORM\Column(type="time", nullable=true)
*/
protected $arrivalAtDestinationTime;
/**
* @ORM\Column(type="text")
*/
protected $extraCostName = '';
/**
* @ORM\Column(type="decimal",precision=6, scale=2)
*/
protected $extraCostPrice = 0.0;
/**
* @ORM\Column(type="json")
*/
protected $accMemberRates = [];
/**
* @ORM\Column(type="decimal",precision=6, scale=2)
*/
protected $accMemberManualRate = 0.0;
/**
* @ORM\Column(type="json")
*/
protected $accCustomerRates = [];
/**
* @ORM\Column(type="decimal",precision=6, scale=2)
*/
protected $accCustomerManualRate = 0.0;
/**
* @ORM\OneToOne(targetEntity="Diplix\KMGBundle\Entity\Order", inversedBy="job")
* @ORM\JoinColumn(nullable=true)
* @var Order
*/
protected $knownOrder;
/**
* @ORM\Column(type="string")
*/
protected $detectedFFL = PaymentCalculator::NONE;
/**
* @ORM\Column(type="integer")
*/
protected $actualKm = 0;
/**
* @ORM\Column(type="decimal", nullable=false, precision=7, scale=2,options={"unsigned":false})
*/
protected $totalCustomerNet = 0.0;
/**
* @ORM\Column(type="decimal", nullable=false, precision=7, scale=2,options={"unsigned":false})
*/
protected $totalMemberNet = 0.0;
/**
* @ORM\Column(type="json")
*/
protected $customerCalculationItems = [];
/**
* @ORM\Column(type="json")
*/
protected $memberCalculationItems = [];
/**
* @ORM\Column(type="decimal", nullable=true, precision=3, scale=2,options={"unsigned":false})
*/
protected $memberCalcForceTaxRate = null;
/**
* @ORM\Column(type="decimal", nullable=false, precision=7, scale=2,options={"unsigned":false})
*/
protected $taxameter = 0.0;
/**
* @ORM\Column(type="decimal", nullable=false, precision=3, scale=2,options={"unsigned":false})
*/
protected $taxameterVat = 0.07; // 1 = 100%
/**
* @ORM\Column(type="boolean")
*/
protected $passengerNotMet = false;
/**
* @ORM\Column(type="boolean")
*/
protected $fflCombinationRide = false;
/**
* @ORM\Column(type="boolean")
*/
protected $werksRundfahrt = false;
/**
* @ORM\Column(type="boolean")
*/
protected $discarded = false;
/**
* @ORM\Column(type="boolean")
*/
protected $extraWaitingTimeRide = false;
/**
* @ORM\Column(type="integer")
* in minutes
*/
protected $extraWaitingTime = 0;
/**
* @ORM\Column(type="boolean")
*/
protected $applicantTimeRide = false;
/**
* @ORM\Column(type="integer")
* in minutes
*/
protected $applicantTime = 0;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $disablePricelistCalculation = false;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $disableTaxameterForCustomer = false;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $hasMemberExtraKm = false;
/**
* @ORM\Column(type="integer")
*/
protected $memberExtraKm = 0;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $lastChangeByMember = null;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $instantRide = false;
/**
* @ORM\Column(type="integer", options={"default":"0"})
*/
protected $instantRideAdditionalWaitingTime = 0;
/**
* @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\File", fetch="EAGER")
* @ORM\JoinColumn(referencedColumnName="id",nullable=true)
*/
protected $customerSignature;
/**
* @ORM\Column(type="integer",options={"default":"0"})
* @see Order::CM_xxxxxxx
*/
protected $confirmedByCustomerThrough = 0;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $ignoreForCustomer = false;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $ignoreForMember = false;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $recalculateCustomerPrice = false;
/**
* @ORM\Column(type="string", options={"length":"1","default":"m"})
*/
protected $rideStyle = self::RS_MIETWAGEN;
/**
* @ORM\Column(type="json")
* @var array|string[]
*/
protected $controlling = [];
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $customerStorno = false;
/**
* @ORM\Column(type="integer", options={"default":"0"})
*/
protected $SLC = 0; // SoLei Chauffeur Serv
/**
* @ORM\Column(type="integer", options={"default":"0"})
*/
protected $VVC = 0; // Vertrg Vorst Chauff
/**
* @ORM\OneToOne(targetEntity="Job", inversedBy="combiRideChild")
*/
protected $combiRideParent; // parent = ride which took place before self
/**
* @ORM\OneToOne(targetEntity="Job", mappedBy="combiRideParent")
*/
protected $combiRideChild; // child = ride which took place after self
public const CAS_NEW = 0;
public const CAS_AUTO = 1;
public const CAS_MANUAL = 2;
/**
* @ORM\Column(type="integer", options={"default":"0"})
*/
protected $combiAssignmentState = self::CAS_NEW;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $optSubCustomerNet = false;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $optNoExtrasForCustomer = false;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
*/
protected $optAddChargeForCustomer = false;
//////////////////////////////////////////////////////////////////////////////////////
/*
* convert from array[] to JobCalcItem[]
*/
public static function toJciArray(array $list)
{
$ro = [];
foreach ( $list as $row)
{
$ro[]= JobCalcItem::fromArray($row);
}
return $ro;
}
/**
* convert from JobCalcItem[] / Waypoint[] to array[]
* Note: fails with non-utf8 data
*/
public static function fromObjectArray(array $list)
{
return json_decode(json_encode($list), true); // ugly way to convert array of object to array of assoc-array
}
/*
* convert from array[] to Waypoint[]
*/
public static function toWaypointArray(array $list)
{
$ro = [];
foreach ( $list as $row)
{
$ro[]= Waypoint::fromArray($row);
}
return $ro;
}
/**
* @param $date \DateTime|null
* @param $master \DateTime|null
* @return \DateTime|null
* @throws \Exception
* @deprecated
*/
public static function ensureTimeWindow($date,$master)
{
if (($date===null)||($master===null)) return $date;
// a very plain way to ensure the right time window (time-only is initialized with 1.1.1970), we can safely ignore offsets/timezone
$diff = abs($date->getTimestamp() - $master->getTimestamp());
if ($diff > 86400) // if date differs more then one day, fix it to same day
{
$date = new \DateTime($master->format('Y-m-d ') .' '. $date->format('H:i:s') );
}
return $date;
}
public function updateFromOrder(Order $order)
{
if ( ($this->knownOrder!==null)&& ($order->getId() !== $this->knownOrder->getId()) )
throw new \RuntimeException('Logic error');
// copy data
$job = $this;
$job->setConfirmationPin($order->getConfirmationPin());
$job->setOrderNumber($order->getRemoteOrderId()); // the Job::orderNumber is the one from tami which is the same as Order::remoteOrderId
$job->setOrderTime($order->getOrderTime());
$job->setCustomer($order->getCustomer());
$job->setCustomerName($order->getCustomer() !== null ? $order->getCustomer()->getName() : '???' );
$adr = $order->getAddressList()->toArray();
$adr = array_filter($adr, function(Address $a) {
return !$a->getBeDeleted();
});
/** @var Address $origin */
$origin = reset($adr);
/** @var Address $destination */
if (count($adr)<2)
throw new \Exception('Destination missing');
$destination = end($adr);
$job->setWaypoints( array_values( array_map( function( Address $a) { return Waypoint::fromAddress($a); } , $adr) ) ); // need array_values for force re-indexing in correct order
$job->setOriginQuick($origin->getName());
$job->setOriginStreet($origin->getStreet());
$job->setOriginNumber($origin->getNumber());
$job->setOriginZip($origin->getZipCode());
$job->setOriginCity($origin->getCity());
$job->setDestinationQuick($destination->getName());
$job->setDestinationStreet($destination->getStreet());
$job->setDestinationNumber($destination->getNumber());
$job->setDestinationZip($destination->getZipCode());
$job->setDestinationCity($destination->getCity());
$job->setPersonCount($order->getPersonCount());
$job->setDistanceKm($order->getLastEstimatedDistance());
$job->setPrice($order->getLastEstimatedPrice());
$job->setPaymentType( $order->getPaymentType()!==null ? $order->getPaymentType()->getName() : '');
$job->setInfo($order->getComment());
$job->setCostCenter($order->getCostCenter());
// ->setMember() is handled via OrderHandler::syncMemberFromOrderToJobIfRequired
// post-process
$job->setDetectedFFL( PaymentCalculator::detectFFL($job) );
$job->setActualKm( $job->getDistanceKm() );
$wrapper = [ $job ];
JobRepository::setupAssumptions( $wrapper );
}
public static function createForOrder(Order $order)
{
$job = new Job(self::GENERATED);
$job->setCarId(0);
$job->setDriverId(0);
$job->setRelType(0);
$job->setJobDuration(0);
$job->setWaitTime(0);
$job->setKnownOrder($order);
$job->updateFromOrder($order);
return $job;
}
public function getTotalFor($audience)
{
if ($audience===Billing::TYPE_MEMBER)
return $this->getTotalMemberNet();
if ($audience===Billing::TYPE_CUSTOMER)
return $this->getTotalCustomerNet();
throw new \RuntimeException('Unknown audience');
}
/**
* Return net/vat parts as array [ vat*100 => [ 'net' => x, 'vat' => y ] ]
* @param $audience
* @return array
*/
public function getVatPartsFor($audience)
{
$items = $this->getCalcItemsFor($audience);
$parts = [];
$empty = ['net' => 0, 'vat' => 0];
/** @var JobCalcItem $it */
foreach ($items as $it)
{
$v = (int)($it->vat * 100); // float array keys get truncated to int
if (!array_key_exists($v,$parts)) $parts[$v] = $empty;
$parts[$v] ['vat'] += $it->vat * $it->totalNet;
$parts[$v] ['net'] += $it->totalNet;
}
return $parts;
}
/**
* @param $audience
* @return array|JobCalcItem[]
*/
public function getCalcItemsFor($audience)
{
if ($audience===Billing::TYPE_MEMBER)
return $this->getMemberCalculationItems();
if ($audience===Billing::TYPE_CUSTOMER)
return $this->getCustomerCalculationItems();
throw new \RuntimeException('Unknown audience');
}
public function __construct($source = self::UNKNOWN)
{
$this->confirmationPin = Order::generatePin();
$this->source = $source;
}
/*
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getOrderNumber()
{
return $this->orderNumber;
}
/**
* @param mixed $orderNumber
*/
public function setOrderNumber($orderNumber)
{
$this->orderNumber = $orderNumber;
}
/**
* @return \DateTime
*/
public function getOrderTime()
{
return $this->orderTime;
}
/**
* @param mixed $orderTime
*/
public function setOrderTime($orderTime)
{
/** @noinspection TypeUnsafeComparisonInspection */
if ($orderTime != $this->orderTime)
$this->orderTime = $orderTime;
}
/**
* @return mixed
*/
public function getOriginQuick()
{
return $this->originQuick;
}
/**
* @param mixed $originQuick
*/
public function setOriginQuick($originQuick)
{
$this->originQuick = $originQuick;
}
/**
* @return mixed
*/
public function getOriginStreet()
{
return $this->originStreet;
}
/**
* @param mixed $originStreet
*/
public function setOriginStreet($originStreet)
{
$this->originStreet = $originStreet;
}
/**
* @return mixed
*/
public function getOriginNumber()
{
return $this->originNumber;
}
/**
* @param mixed $originNumber
*/
public function setOriginNumber($originNumber)
{
$this->originNumber = $originNumber;
}
/**
* @return mixed
*/
public function getOriginZip()
{
return $this->originZip;
}
/**
* @param mixed $originZip
*/
public function setOriginZip($originZip)
{
$this->originZip = $originZip;
}
/**
* @return mixed
*/
public function getOriginCity()
{
return $this->originCity;
}
/**
* @param mixed $originCity
*/
public function setOriginCity($originCity)
{
$this->originCity = $originCity;
}
/**
* @return mixed
*/
public function getDestinationQuick()
{
return $this->destinationQuick;
}
/**
* @param mixed $destinationQuick
*/
public function setDestinationQuick($destinationQuick)
{
$this->destinationQuick = $destinationQuick;
}
/**
* @return mixed
*/
public function getDestinationStreet()
{
return $this->destinationStreet;
}
/**
* @param mixed $destinationStreet
*/
public function setDestinationStreet($destinationStreet)
{
$this->destinationStreet = $destinationStreet;
}
/**
* @return mixed
*/
public function getDestinationNumber()
{
return $this->destinationNumber;
}
/**
* @param mixed $destinationNumber
*/
public function setDestinationNumber($destinationNumber)
{
$this->destinationNumber = $destinationNumber;
}
/**
* @return mixed
*/
public function getDestinationZip()
{
return $this->destinationZip;
}
/**
* @param mixed $destinationZip
*/
public function setDestinationZip($destinationZip)
{
$this->destinationZip = $destinationZip;
}
/**
* @return mixed
*/
public function getDestinationCity()
{
return $this->destinationCity;
}
/**
* @param mixed $destinationCity
*/
public function setDestinationCity($destinationCity)
{
$this->destinationCity = $destinationCity;
}
/**
* @return mixed
*/
public function getPersonCount()
{
return $this->personCount;
}
/**
* @param mixed $personCount
*/
public function setPersonCount($personCount)
{
$this->personCount = $personCount;
}
/**
* @return mixed
*/
public function getDistanceKm()
{
return $this->distanceKm;
}
/**
* @param mixed $distanceKm
*/
public function setDistanceKm($distanceKm)
{
$this->distanceKm = $distanceKm;
}
/**
* @return mixed
*/
public function getWaitTime()
{
return $this->waitTime;
}
/**
* @param mixed $waitTime
*/
public function setWaitTime($waitTime)
{
$this->waitTime = $waitTime;
}
/**
* @return mixed
*/
public function getPaymentType()
{
return $this->paymentType;
}
/**
* @param mixed $paymentType
*/
public function setPaymentType($paymentType)
{
$this->paymentType = $paymentType;
}
/**
* @return mixed
*/
public function getPrice()
{
return $this->price;
}
/**
* @param mixed $price
*/
public function setPrice($price)
{
$this->price = $price;
}
/**
* @return mixed
*/
public function getCarId()
{
return $this->carId;
}
/**
* @param mixed $carId
*/
public function setCarId($carId)
{
$this->carId = $carId;
}
/**
* @return mixed
*/
public function getDriverId()
{
return $this->driverId;
}
/**
* @param mixed $driverId
*/
public function setDriverId($driverId)
{
$this->driverId = $driverId;
}
/**
* @return mixed
*/
public function getInfo()
{
return $this->info;
}
/**
* @param mixed $info
*/
public function setInfo($info)
{
$this->info = $info;
}
/**
* @return mixed
*/
public function getCostCenter()
{
return $this->costCenter;
}
/**
* @param mixed $costCenter
*/
public function setCostCenter($costCenter)
{
$this->costCenter = $costCenter;
}
/**
* @return mixed
*/
public function getJobReceivedTime()
{
return $this->jobReceivedTime;
}
/**
* @param mixed $jobReceivedTime
*/
public function setJobReceivedTime($jobReceivedTime)
{
/** @noinspection TypeUnsafeComparisonInspection */
if ($jobReceivedTime != $this->jobReceivedTime) // to prevent doctrine from updating when the date is the same but in a new instance
$this->jobReceivedTime = $jobReceivedTime;
}
/**
* @return mixed
*/
public function getJobStartTime()
{
return $this->jobStartTime;
}
/**
* @param mixed $jobStartTime
*/
public function setJobStartTime($jobStartTime)
{
/** @noinspection TypeUnsafeComparisonInspection */
if ($jobStartTime != $this->jobStartTime)
$this->jobStartTime = $jobStartTime;
}
/**
* @return mixed
*/
public function getJobDoneTime()
{
return $this->jobDoneTime;
}
/**
* @param mixed $jobDoneTime
*/
public function setJobDoneTime($jobDoneTime)
{
/** @noinspection TypeUnsafeComparisonInspection */
if ($jobDoneTime != $this->jobDoneTime)
$this->jobDoneTime = $jobDoneTime;
}
/**
* @return mixed
*/
public function getJobDuration()
{
return $this->jobDuration;
}
/**
* @param mixed $jobDuration
*/
public function setJobDuration($jobDuration)
{
$this->jobDuration = $jobDuration;
}
/**
* @return mixed
*/
public function getRelType()
{
return $this->relType;
}
/**
* @param mixed $relType
*/
public function setRelType($relType)
{
$this->relType = $relType;
}
/**
* @return mixed
*/
public function getRelId()
{
return $this->relId;
}
/**
* @param mixed $relId
*/
public function setRelId($relId)
{
$this->relId = $relId;
}
/**
* @return mixed
*/
public function getCustomerName()
{
return $this->customerName;
}
/**
* @param mixed $customerName
*/
public function setCustomerName($customerName)
{
$this->customerName = $customerName;
}
/**
* @return mixed
*/
public function getFlightOnPositionTime()
{
return $this->flightOnPositionTime;
}
/**
* @param mixed $flightOnPositionTime
*/
public function setFlightOnPositionTime($flightOnPositionTime)
{
$this->flightOnPositionTime = $flightOnPositionTime;
}
/**
* @return \DateTime|null
*/
public function getDepartureAtOriginTime()
{
return $this->departureAtOriginTime;
}
/**
* @param mixed $departureAtOriginTime
*/
public function setDepartureAtOriginTime($departureAtOriginTime)
{
$this->departureAtOriginTime = $departureAtOriginTime;
}
/**
* @return mixed
*/
public function getExtraCostName()
{
return $this->extraCostName;
}
/**
* @param mixed $extraCostName
*/
public function setExtraCostName($extraCostName)
{
$this->extraCostName = $extraCostName;
}
/**
* @return mixed
*/
public function getExtraCostPrice()
{
return $this->extraCostPrice;
}
/**
* @param mixed $extraCostPrice
*/
public function setExtraCostPrice($extraCostPrice)
{
$this->extraCostPrice = $extraCostPrice;
}
/**
* @param $audience string Billing::TYPE_CUSTOMER or Billing::TYPE_MEMBER
* @return mixed
*/
public function isBilled($audience)
{
if ($audience===Billing::TYPE_MEMBER)
return ($this->billingForMember !== null);
else
if ($audience===Billing::TYPE_CUSTOMER)
return ($this->billingForCustomer !== null);
else
throw new \RuntimeException('Unknown audience. has to be TYPE_MEMBER or TYPE_CUSTOMER');
}
/**
* @return CoopMember|null
*/
public function getMember()
{
return $this->member;
}
/**
* @param mixed $member
*/
public function setMember($member)
{
$this->member = $member;
}
/**
* @return \DateTime|null
*/
public function getArrivalAtDestinationTime()
{
return $this->arrivalAtDestinationTime;
}
/**
* @param mixed $arrivalAtDestinationTime
*/
public function setArrivalAtDestinationTime($arrivalAtDestinationTime)
{
$this->arrivalAtDestinationTime = $arrivalAtDestinationTime;
}
/**
* @return Customer|null
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param mixed $customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}
/**
* @return array
*/
public function getAccMemberRates()
{
if ($this->accMemberRates===null) return [];
return $this->accMemberRates;
}
/**
* @param array $accMemberRates
*/
public function setAccMemberRates($accMemberRates)
{
$this->accMemberRates = $accMemberRates;
}
/**
* @return array
*/
public function getAccCustomerRates()
{
if ($this->accCustomerRates===null) return [];
return $this->accCustomerRates;
}
/**
* @param array $accCustomerRates
*/
public function setAccCustomerRates($accCustomerRates)
{
$this->accCustomerRates = $accCustomerRates;
}
/**
* @return string
*/
public function getOptions()
{
return $this->options;
}
/**
* @param string $options
*/
public function setOptions($options)
{
$this->options = $options;
}
/**
* @return float
*/
public function getAccMemberManualRate()
{
return $this->accMemberManualRate;
}
/**
* @param float $accMemberManualRate
*/
public function setAccMemberManualRate($accMemberManualRate)
{
$this->accMemberManualRate = $accMemberManualRate;
}
/**
* @return float
*/
public function getAccCustomerManualRate()
{
return $this->accCustomerManualRate;
}
/**
* @param float $accCustomerManualRate
*/
public function setAccCustomerManualRate($accCustomerManualRate)
{
$this->accCustomerManualRate = $accCustomerManualRate;
}
/**
* @return null|Order
*/
public function getKnownOrder()
{
return $this->knownOrder;
}
public function getKnownOrderId()
{
if ($this->knownOrder !== null)
return $this->knownOrder->getOrderId();
return null;
}
/**
* @param Order|null $knownOrder
*/
public function setKnownOrder($knownOrder)
{
$this->knownOrder = $knownOrder;
if ($knownOrder!==null) $knownOrder->setJob($this);
}
/**
* @return bool
*/
public function isReadyForBilling()
{
return $this->readyForBilling;
}
/**
* @param bool $readyForBilling
*/
public function setReadyForBilling($readyForBilling)
{
$this->readyForBilling = $readyForBilling;
}
/**
* @return array
*/
public function getLastReadyForBillingCheckResult(): array
{
if ($this->lastReadyForBillingCheckResult === null) return [];
return $this->lastReadyForBillingCheckResult;
}
/**
* @param array $lastReadyForBillingCheckResult
*/
public function setLastReadyForBillingCheckResult(array $lastReadyForBillingCheckResult): void
{
$this->lastReadyForBillingCheckResult = $lastReadyForBillingCheckResult;
}
/**
* @return string
*/
public function getDetectedFFL()
{
return $this->detectedFFL;
}
/**
* @param string $detectedFFL
*/
public function setDetectedFFL($detectedFFL)
{
$this->detectedFFL = $detectedFFL;
}
/**
* @return int
*/
public function getActualKm()
{
return $this->actualKm;
}
/**
* @param int $actualKm
*/
public function setActualKm($actualKm)
{
$this->actualKm = $actualKm;
}
/**
* @param $audience
* @return Billing
*/
public function getBillingFor($audience)
{
if ($audience===Billing::TYPE_MEMBER)
return $this->getBillingForMember();
if ($audience===Billing::TYPE_CUSTOMER)
return $this->getBillingForCustomer();
throw new \RuntimeException('Unknown audience');
}
/**
* @return BillingForMember
*/
public function getBillingForMember()
{
return $this->billingForMember;
}
/**
* @param mixed $billingForMember
*/
public function setBillingForMember($billingForMember)
{
$this->billingForMember = $billingForMember;
}
/**
* @return BillingForCustomer
*/
public function getBillingForCustomer()
{
return $this->billingForCustomer;
}
/**
* @param mixed $billingForCustomer
*/
public function setBillingForCustomer($billingForCustomer)
{
$this->billingForCustomer = $billingForCustomer;
}
/**
* @return float
*/
public function getTotalCustomerNet()
{
return $this->totalCustomerNet;
}
/**
* // called from setCustomerCalculationItems()
* @param float $totalCustomerNet
*/
private function setTotalCustomerNet($totalCustomerNet)
{
$this->totalCustomerNet = $totalCustomerNet;
}
/**
* @return float
*/
public function getTotalMemberNet()
{
return $this->totalMemberNet;
}
/**
* // called from setMemberCalculationItems()
* @param float $totalMemberNet
*/
private function setTotalMemberNet($totalMemberNet)
{
$this->totalMemberNet = $totalMemberNet;
}
/**
* @return array|JobCalcItem[]
*/
public function getCustomerCalculationItems()
{
return self::toJciArray($this->customerCalculationItems);
}
/**
* @param array $customerCalculationItems
*/
public function setCustomerCalculationItems($customerCalculationItems)
{
$this->setTotalCustomerNet( array_sum(array_map(static function($e) { return $e->totalNet; }, $customerCalculationItems)) );
$this->customerCalculationItems = self::fromObjectArray($customerCalculationItems);
}
/**
* @return array|JobCalcItem[]
*/
public function getMemberCalculationItems()
{
return self::toJciArray($this->memberCalculationItems);
}
/**
* @param array $memberCalculationItems
*/
public function setMemberCalculationItems($memberCalculationItems)
{
$this->setTotalMemberNet( array_sum(array_map(static function($e) { return $e->totalNet; }, $memberCalculationItems)) );
$this->memberCalculationItems = self::fromObjectArray($memberCalculationItems);
}
/**
* @return float
*/
public function getTaxameter()
{
return $this->taxameter;
}
/**
* @param float $taxameter
*/
public function setTaxameter($taxameter)
{
$this->taxameter = $taxameter;
}
/**
* @return float
*/
public function getTaxameterVat()
{
return $this->taxameterVat;
}
/**
* @param float $taxameterVat
*/
public function setTaxameterVat($taxameterVat)
{
$this->taxameterVat = $taxameterVat;
}
/**
* @return bool
*/
public function getPassengerNotMet()
{
return $this->passengerNotMet;
}
/**
* @param bool $passengerNotMet
*/
public function setPassengerNotMet($passengerNotMet)
{
$this->passengerNotMet = $passengerNotMet;
}
/**
* @return bool
*/
public function isFflCombinationRide()
{
return $this->fflCombinationRide;
}
/**
* @param bool $fflCombinationRide
*/
public function setFflCombinationRide($fflCombinationRide)
{
$this->fflCombinationRide = $fflCombinationRide;
}
/**
* @return bool
*/
public function isDiscarded()
{
return $this->discarded;
}
/**
* @param bool $discarded
*/
public function setDiscarded($discarded)
{
$this->discarded = $discarded;
}
/**
* @return array|Waypoint[]
*/
public function getWaypoints()
{
if ($this->waypoints === null) return [];
return self::toWaypointArray($this->waypoints);
}
/**
* @param array|Waypoint[] $waypoints
*/
public function setWaypoints($waypoints)
{
$new = self::fromObjectArray($waypoints);
if ($new!=$this->waypoints) // basic change detection
$this->waypoints = $new;
}
/**
* @return bool
*/
public function isExtraWaitingTimeRide()
{
return $this->extraWaitingTimeRide;
}
/**
* @param bool $extraWaitingTimeRide
*/
public function setExtraWaitingTimeRide($extraWaitingTimeRide)
{
$this->extraWaitingTimeRide = $extraWaitingTimeRide;
}
/**
* @return int
*/
public function getExtraWaitingTime()
{
return $this->extraWaitingTime;
}
/**
* @param int $extraWaitingTime
*/
public function setExtraWaitingTime($extraWaitingTime)
{
$this->extraWaitingTime = $extraWaitingTime;
}
/**
* @return bool
*/
public function isDisablePricelistCalculation()
{
return $this->disablePricelistCalculation;
}
/**
* @param bool $disablePricelistCalculation
*/
public function setDisablePricelistCalculation($disablePricelistCalculation)
{
$this->disablePricelistCalculation = $disablePricelistCalculation;
}
/**
* @return bool
*/
public function isDisableTaxameterForCustomer(): bool
{
return $this->disableTaxameterForCustomer;
}
/**
* @param bool $disableTaxameterForCustomer
*/
public function setDisableTaxameterForCustomer(bool $disableTaxameterForCustomer): void
{
$this->disableTaxameterForCustomer = $disableTaxameterForCustomer;
}
/**
* @return bool
*/
public function getHasMemberExtraKm(): bool
{
return $this->hasMemberExtraKm;
}
/**
* @param bool $hasMemberExtraKm
*/
public function setHasMemberExtraKm(bool $hasMemberExtraKm): void
{
$this->hasMemberExtraKm = $hasMemberExtraKm;
}
/**
* @return int
*/
public function getMemberExtraKm(): int
{
return $this->memberExtraKm;
}
/**
* @param int $memberExtraKm
*/
public function setMemberExtraKm(int $memberExtraKm): void
{
$this->memberExtraKm = $memberExtraKm;
}
/**
* @return null|\DateTime
*/
public function getLastChangeByMember()
{
return $this->lastChangeByMember;
}
/**
* @param null|\DateTime $lastChangeByMember
*/
public function setLastChangeByMember($lastChangeByMember): void
{
$this->lastChangeByMember = $lastChangeByMember;
}
/**
* @return bool
*/
public function isInstantRide(): bool
{
return $this->instantRide;
}
/**
* @param bool $instantRide
*/
public function setInstantRide(bool $instantRide): void
{
$this->instantRide = $instantRide;
}
/**
* @return bool
*/
public function isApprovedByDriver(): bool
{
return $this->approvedByDriver;
}
/**
* @param bool $approvedByDriver
*/
public function setApprovedByDriver(bool $approvedByDriver): void
{
$this->approvedByDriver = $approvedByDriver;
}
/**
* @return bool
*/
public function isApprovedByPassenger(): bool
{
return $this->approvedByPassenger;
}
/**
* @param bool $approvedByPassenger
*/
public function setApprovedByPassenger(bool $approvedByPassenger): void
{
$this->approvedByPassenger = $approvedByPassenger;
}
/**
* @return bool
*/
public function isApprovedByAccounting(): bool
{
return $this->approvedByAccounting;
}
/**
* @param bool $approvedByAccounting
*/
public function setApprovedByAccounting(bool $approvedByAccounting): void
{
$this->approvedByAccounting = $approvedByAccounting;
}
public function getApprovalStatus()
{
$ret = 0;
if ($this->isReadyForBilling()) $ret += 0x1;
if ($this->isApprovedByDriver()) $ret += 0x2;
if ($this->isApprovedByPassenger()) $ret += 0x4;
if ($this->isApprovedByAccounting()) $ret += 0x8;
return $ret;
}
/**
* @return string
*/
public function getConfirmationPin(): string
{
return $this->confirmationPin;
}
/**
* @param string $confirmationPin
*/
public function setConfirmationPin(string $confirmationPin): void
{
$this->confirmationPin = $confirmationPin;
}
/**
* @return mixed
*/
public function getCustomerSignature()
{
return $this->customerSignature;
}
/**
* @param mixed $customerSignature
*/
public function setCustomerSignature($customerSignature): void
{
$this->customerSignature = $customerSignature;
}
/**
* @return string
*/
public function getSource(): string
{
return $this->source;
}
/**
* @param string $source
*/
public function setSource(string $source): void
{
$this->source = $source;
}
/**
* @return int
*/
public function getInstantRideAdditionalWaitingTime(): int
{
return $this->instantRideAdditionalWaitingTime;
}
/**
* @param int $instantRideAdditionalWaitingTime
*/
public function setInstantRideAdditionalWaitingTime(int $instantRideAdditionalWaitingTime): void
{
$this->instantRideAdditionalWaitingTime = $instantRideAdditionalWaitingTime;
}
/**
* @return mixed
*/
public function getConfirmedByCustomerThrough()
{
return $this->confirmedByCustomerThrough;
}
/**
* @param mixed $confirmedByCustomerThrough
*/
public function setConfirmedByCustomerThrough($confirmedByCustomerThrough): void
{
$this->confirmedByCustomerThrough = $confirmedByCustomerThrough;
}
/**
* @return bool
*/
public function isIgnoreForCustomer(): bool
{
return $this->ignoreForCustomer;
}
/**
* @param bool $ignoreForCustomer
*/
public function setIgnoreForCustomer(bool $ignoreForCustomer): void
{
$this->ignoreForCustomer = $ignoreForCustomer;
}
/**
* @return mixed
*/
public function getRecalculateCustomerPrice()
{
return $this->recalculateCustomerPrice;
}
/**
* @param mixed $recalculateCustomerPrice
*/
public function setRecalculateCustomerPrice($recalculateCustomerPrice): void
{
$this->recalculateCustomerPrice = $recalculateCustomerPrice;
}
/**
* @return bool
*/
public function isIgnoreForMember(): bool
{
return $this->ignoreForMember;
}
/**
* @param bool $ignoreForMember
*/
public function setIgnoreForMember(bool $ignoreForMember): void
{
$this->ignoreForMember = $ignoreForMember;
}
/**
* @return string
*/
public function getRideStyle(): string
{
return $this->rideStyle;
}
/**
* @param string $rideStyle
*/
public function setRideStyle(string $rideStyle): void
{
$this->rideStyle = $rideStyle;
}
/**
* @return bool
*/
public function isWerksRundfahrt(): bool
{
return $this->werksRundfahrt;
}
/**
* @param bool $werksRundfahrt
*/
public function setWerksRundfahrt(bool $werksRundfahrt): void
{
$this->werksRundfahrt = $werksRundfahrt;
}
/**
* @return array|string[]
*/
public function getControlling(): array
{
if ($this->controlling===null)
return [];
return $this->controlling;
}
/**
* @param array|string[] $controlling
*/
public function setControlling(array $controlling): void
{
$this->controlling = array_values($controlling);
}
/**
* @return bool
*/
public function isCustomerStorno(): bool
{
return $this->customerStorno;
}
/**
* @param bool $customerStorno
*/
public function setCustomerStorno(bool $customerStorno): void
{
$this->customerStorno = $customerStorno;
}
/**
* @return int
*/
public function getSLC(): int
{
return $this->SLC;
}
/**
* @param int $SLC
*/
public function setSLC(int $SLC): void
{
$this->SLC = $SLC;
}
/**
* @return int
*/
public function getVVC(): int
{
return $this->VVC;
}
/**
* @param int $VVC
*/
public function setVVC(int $VVC): void
{
$this->VVC = $VVC;
}
/**
* @return ?float
*/
public function getMemberCalcForceTaxRate(): ?float
{
return $this->memberCalcForceTaxRate;
}
/**
* @param ?float $memberCalcForceTaxRate
*/
public function setMemberCalcForceTaxRate(?float $memberCalcForceTaxRate): void
{
$this->memberCalcForceTaxRate = $memberCalcForceTaxRate;
}
/**
* @return Job|null
*/
public function getCombiRideParent()
{
return $this->combiRideParent;
}
/**
* @param Job|null $combiRideParent
*/
public function setCombiRideParent($combiRideParent): void
{
$this->combiRideParent = $combiRideParent;
}
/**
* @return Job|null
*/
public function getCombiRideChild()
{
return $this->combiRideChild;
}
/**
* @param Job|null $combiRideChild
*/
public function setCombiRideChild($combiRideChild): void
{
$this->combiRideChild = $combiRideChild;
}
/**
* @return int
*/
public function getCombiAssignmentState(): int
{
return $this->combiAssignmentState;
}
/**
* @param int $combiAssignmentState
*/
public function setCombiAssignmentState(int $combiAssignmentState): void
{
$this->combiAssignmentState = $combiAssignmentState;
}
/**
* @return bool
*/
public function isOptSubCustomerNet(): bool
{
return $this->optSubCustomerNet;
}
/**
* @param bool $optSubCustomerNet
*/
public function setOptSubCustomerNet(bool $optSubCustomerNet): void
{
$this->optSubCustomerNet = $optSubCustomerNet;
}
/**
* @return bool
*/
public function isOptNoExtrasForCustomer(): bool
{
return $this->optNoExtrasForCustomer;
}
/**
* @param bool $optNoExtrasForCustomer
*/
public function setOptNoExtrasForCustomer(bool $optNoExtrasForCustomer): void
{
$this->optNoExtrasForCustomer = $optNoExtrasForCustomer;
}
/**
* @return bool
*/
public function isOptAddChargeForCustomer(): bool
{
return $this->optAddChargeForCustomer;
}
/**
* @param bool $optAddChargeForCustomer
*/
public function setOptAddChargeForCustomer(bool $optAddChargeForCustomer): void
{
$this->optAddChargeForCustomer = $optAddChargeForCustomer;
}
/**
* @return bool
*/
public function isApplicantTimeRide(): bool
{
return $this->applicantTimeRide;
}
/**
* @param bool $applicantTimeRide
*/
public function setApplicantTimeRide(bool $applicantTimeRide): void
{
$this->applicantTimeRide = $applicantTimeRide;
}
/**
* @return int
*/
public function getApplicantTime(): int
{
return $this->applicantTime;
}
/**
* @param int $applicantTime
*/
public function setApplicantTime(int $applicantTime): void
{
$this->applicantTime = $applicantTime;
}
}