added basic invoice rendering #97 #93 (#99)

This commit is contained in:
Kevin Papst
2018-01-21 22:50:46 +01:00
committed by GitHub
parent 9a161b8fd9
commit 4cbc5391c0
73 changed files with 2986 additions and 918 deletions

View File

@@ -44,6 +44,14 @@ class Customer
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="number", type="string", length=50, nullable=false)
* @Assert\NotBlank()
*/
private $number;
/**
* @var string
*
@@ -73,15 +81,6 @@ class Customer
*/
private $company;
/**
* @var integer
*
* @ORM\Column(name="vat", type="integer", length=2, nullable=true)
* @Assert\Range(min = 0, max = 99)
*
*/
private $vat;
/**
* @var string
*
@@ -92,7 +91,7 @@ class Customer
/**
* @var string
*
* @ORM\Column(name="street", type="text", length=65535, nullable=true)
* @ORM\Column(name="address", type="text", length=65535, nullable=true)
*/
private $address;
@@ -167,13 +166,11 @@ class Customer
* Set name
*
* @param string $name
*
* @return Customer
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
@@ -182,22 +179,38 @@ class Customer
*
* @return string
*/
public function getName()
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $number
* @return Customer
*/
public function setNumber(string $number)
{
$this->number = $number;
return $this;
}
/**
* @return string
*/
public function getNumber(): ?string
{
return $this->number;
}
/**
* Set comment
*
* @param string $comment
*
* @return Customer
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
@@ -215,13 +228,11 @@ class Customer
* Set visible
*
* @param boolean $visible
*
* @return Customer
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
@@ -239,13 +250,11 @@ class Customer
* Set company
*
* @param string $company
*
* @return Customer
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
@@ -259,41 +268,15 @@ class Customer
return $this->company;
}
/**
* Set vat
*
* @param integer $vat
*
* @return Customer
*/
public function setVat($vat)
{
$this->vat = $vat;
return $this;
}
/**
* Get vat
*
* @return integer
*/
public function getVat()
{
return $this->vat;
}
/**
* Set contact
*
* @param string $contact
*
* @return Customer
*/
public function setContact($contact)
{
$this->contact = $contact;
return $this;
}
@@ -307,6 +290,16 @@ class Customer
return $this->contact;
}
/**
* @param string $address
* @return Customer
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* @return string
*/
@@ -315,29 +308,15 @@ class Customer
return $this->address;
}
/**
* @param string $address
*
* @return Customer
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Set country
*
* @param string $country
*
* @return Customer
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
@@ -351,6 +330,16 @@ class Customer
return $this->country;
}
/**
* @param string $currency
* @return Customer
*/
public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}
/**
* @return string
*/
@@ -359,28 +348,15 @@ class Customer
return $this->currency;
}
/**
* @param string $currency
* @return $this
*/
public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}
/**
* Set phone
*
* @param string $phone
*
* @return Customer
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
@@ -398,13 +374,11 @@ class Customer
* Set fax
*
* @param string $fax
*
* @return Customer
*/
public function setFax($fax)
{
$this->fax = $fax;
return $this;
}
@@ -422,13 +396,11 @@ class Customer
* Set mobile
*
* @param string $mobile
*
* @return Customer
*/
public function setMobile($mobile)
{
$this->mobile = $mobile;
return $this;
}
@@ -446,13 +418,11 @@ class Customer
* Set mail
*
* @param string $mail
*
* @return Customer
*/
public function setMail($mail)
{
$this->mail = $mail;
return $this;
}
@@ -470,13 +440,11 @@ class Customer
* Set homepage
*
* @param string $homepage
*
* @return Customer
*/
public function setHomepage($homepage)
{
$this->homepage = $homepage;
return $this;
}
@@ -494,13 +462,11 @@ class Customer
* Set timezone
*
* @param string $timezone
*
* @return Customer
*/
public function setTimezone($timezone)
{
$this->timezone = $timezone;
return $this;
}
@@ -516,12 +482,11 @@ class Customer
/**
* @param Project[] $projects
* @return $this
* @return Customer
*/
public function setProjects($projects)
{
$this->projects = $projects;
return $this;
}

View File

@@ -0,0 +1,317 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* InvoiceTemplate
*
* @ORM\Entity(repositoryClass="App\Repository\InvoiceTemplateRepository")
* @ORM\Table(
* name="invoice_templates",
* uniqueConstraints={
* @ORM\UniqueConstraint(columns={"name"})
* }
* )
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class InvoiceTemplate
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="company", type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $company;
/**
* @var string
*
* @ORM\Column(name="address", type="text", length=65535, nullable=true)
*/
private $address;
/**
* @var int
*
* @ORM\Column(name="due_days", type="integer", length=3, nullable=false)
* @Assert\Range(min = 0, max = 999)
*/
private $dueDays = 30;
/**
* @var float
*
* @ORM\Column(name="vat", type="integer", length=2, nullable=true)
* @Assert\Range(min = 0, max = 99)
*/
private $vat = 0.00;
/**
* @var string
*
* @ORM\Column(name="calculator", type="string", length=20, nullable=false)
* @Assert\NotBlank()
*/
private $calculator = 'default';
/**
* @var string
*
* @ORM\Column(name="number_generator", type="string", length=20, nullable=false)
* @Assert\NotBlank()
*/
private $numberGenerator = 'default';
/**
* @var string
*
* @ORM\Column(name="renderer", type="string", length=20, nullable=false)
* @Assert\NotBlank()
*/
private $renderer = 'default';
/**
* @var string
*
* @ORM\Column(name="payment_terms", type="text", length=65535, nullable=true)
*/
private $paymentTerms;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* @param string $title
* @return InvoiceTemplate
*/
public function setTitle(string $title)
{
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getAddress(): ?string
{
return $this->address;
}
/**
* @param string $address
* @return InvoiceTemplate
*/
public function setAddress(string $address)
{
$this->address = $address;
return $this;
}
/**
* @return string
*/
public function getNumberGenerator(): ?string
{
return $this->numberGenerator;
}
/**
* @param string $numberGenerator
* @return InvoiceTemplate
*/
public function setNumberGenerator(string $numberGenerator)
{
$this->numberGenerator = $numberGenerator;
return $this;
}
/**
* @return int
*/
public function getDueDays(): ?int
{
return $this->dueDays;
}
/**
* @param int $dueDays
* @return InvoiceTemplate
*/
public function setDueDays(int $dueDays)
{
$this->dueDays = $dueDays;
return $this;
}
/**
* @return float
*/
public function getVat(): ?float
{
return $this->vat;
}
/**
* @param float $vat
* @return InvoiceTemplate
*/
public function setVat(float $vat)
{
$this->vat = $vat;
return $this;
}
/**
* @return string
*/
public function getCompany(): ?string
{
return $this->company;
}
/**
* @param string $company
* @return InvoiceTemplate
*/
public function setCompany(string $company)
{
$this->company = $company;
return $this;
}
/**
* @return string
*/
public function getRenderer(): string
{
return $this->renderer;
}
/**
* @param string $renderer
* @return InvoiceTemplate
*/
public function setRenderer(string $renderer)
{
$this->renderer = $renderer;
return $this;
}
/**
* @return string
*/
public function getCalculator(): string
{
return $this->calculator;
}
/**
* @param string $calculator
* @return InvoiceTemplate
*/
public function setCalculator(string $calculator)
{
$this->calculator = $calculator;
return $this;
}
/**
* @return string
*/
public function getPaymentTerms(): ?string
{
return $this->paymentTerms;
}
/**
* @param string $paymentTerms
* @return InvoiceTemplate
*/
public function setPaymentTerms(string $paymentTerms)
{
$this->paymentTerms = $paymentTerms;
return $this;
}
/**
* @return string
*/
public function __toString()
{
return $this->getName();
}
}

View File

@@ -90,7 +90,7 @@ class Timesheet
private $description;
/**
* @var string
* @var float
*
* @ORM\Column(name="rate", type="decimal", precision=10, scale=2, nullable=false)
*/
@@ -150,7 +150,6 @@ class Timesheet
* Set duration
*
* @param integer $duration
*
* @return Timesheet
*/
public function setDuration($duration)
@@ -182,7 +181,6 @@ class Timesheet
* Set user
*
* @param User $user
*
* @return Timesheet
*/
public function setUser(User $user)
@@ -205,7 +203,6 @@ class Timesheet
* Set activity
*
* @param Activity $activity
*
* @return Timesheet
*/
public function setActivity($activity)
@@ -228,7 +225,6 @@ class Timesheet
* Set description
*
* @param string $description
*
* @return Timesheet
*/
public function setDescription($description)
@@ -250,8 +246,7 @@ class Timesheet
/**
* Set rate
*
* @param string $rate
*
* @param float $rate
* @return Timesheet
*/
public function setRate($rate)
@@ -263,7 +258,7 @@ class Timesheet
/**
* Get rate
*
* @return string
* @return float
*/
public function getRate()
{

View File

@@ -369,6 +369,35 @@ class User implements UserInterface, AdvancedUserInterface
return $this;
}
/**
* @param string $name
* @return UserPreference|null
*/
public function getPreference(string $name)
{
foreach ($this->preferences as $preference) {
if ($preference->getName() == $name) {
return $preference;
}
}
return null;
}
/**
* @param $name
* @param null $default
* @return bool|int|null|string
*/
public function getPreferenceValue($name, $default = null)
{
$preference = $this->getPreference($name);
if ($preference === null) {
return $default;
}
return $preference->getValue();
}
/**
* @param UserPreference $preference
* @return User