Commit bdf4651d authored by Karamel's avatar Karamel
Browse files

Remove Order and OrderLine until something better is implemented.

parent 53acf176
<?php
// Pastèque API
//
// Copyright (C)
// 2012 Scil (http://scil.coop)
// 2017 Karamel, Association Pastèque (karamel@creativekara.fr, https://pasteque.org)
//
// This file is part of Pastèque.
//
// Pastèque is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pastèque is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pastèque. If not, see <http://www.gnu.org/licenses/>.
namespace Pasteque\Server\Model;
use \Pasteque\Server\System\DAO\DoctrineModel;
/**
* Class Order
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @Table(name="orders")
*/
class Order extends DoctrineModel
{
public function getDirectFieldNames() {
return ['id', 'name', 'custCount', 'discountRate'];
}
public function getAssociationFields() {
return [
[
'name' => 'lines',
'class' => '\Pasteque\Sevrer\Model\OrderLine',
'array' => true,
'embedded' => true
],
[
'name' =>'customer',
'class' => '\Pasteque\Server\Model\Customer',
'null' => true
],
[
'name' =>'place',
'class' => '\Pasteque\Server\Model\Place',
'null' => true
],
[
'name' => 'tariffArea',
'class' => '\Pasteque\Server\Model\TariffArea',
'null' => true
],
[
'name' => 'discountProfile',
'class' => '\Pasteque\Server\Model\DiscountProfile',
'null' => true
]
];
}
public function __construct() {
$this->lines = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* ID of the order
* @var integer
* @SWG\Property()
* @Id @Column(type="integer")
* @GeneratedValue
*/
protected $id;
public function getId() { return $this->id; }
/**
* Array of order lines
* @var \Pasteque\OrderLine[]
* @SWG\Property()
* @OneToMany(targetEntity="\Pasteque\Server\Model\OrderLine", mappedBy="order", cascade={"persist"}, orphanRemoval=true)
*/
protected $lines;
public function getLines() { return $this->lines; }
public function setLines($lines) {
$this->lines->clear();
foreach ($lines as $price) {
$this->addLine($price);
}
}
public function clearLines() {
$this->getLines()->clear();
}
public function addLine($line) {
$this->lines->add($line);
$line->setTicket($this);
}
/**
* Id of the customer
* @var string
* @SWG\Property()
* @ManyToOne(targetEntity="\Pasteque\Server\Model\Customer")
* @JoinColumn(name="customer_id", referencedColumnName="id")
*/
protected $customer;
public function getCustomer() { return $this->customer; }
public function setCustomer($customer) { $this->customer = $customer; }
/**
* Number of customers in the order.
* @var int
* @SWG\Property()
* @Column(type="integer", nullable=true)
*/
protected $custCount;
public function getCustCount() { return $this->custCount; }
public function setCustCount($custCount) { $this->custCount = $custCount; }
/**
* Id of the place
* @var string
* @SWG\Property()
* @ManyToOne(targetEntity="\Pasteque\Server\Model\Place")
* @JoinColumn(name="place_id", referencedColumnName="id")
*/
protected $place;
public function getPlace() { return $this->place; }
public function setPlace($place) { $this->place = $place; }
/**
*
* @var int
* @SWG\Property()
* @ManyToOne(targetEntity="\Pasteque\Server\Model\TariffArea")
* @JoinColumn(name="tariffarea_id", referencedColumnName="id")
*/
protected $tariffArea;
public function getTariffArea() { return $this->tariffArea; }
public function setTariffArea($tariffArea) {
$this->tariffArea = $tariffArea;
}
/**
* Rate of discount.
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $discountRate = 0.0;
public function getDiscountRate() { return $this->discountRate; }
public function setDiscountRate($discountRate) {
$this->discountRate = $discountRate;
}
/**
* Informative discount profile. The actual discount is set in discountRate.
* @var string
* @SWG\Property()
* @ManyToOne(targetEntity="\Pasteque\Server\Model\DiscountProfile")
* @JoinColumn(name="discountprofile_id", referencedColumnName="id")
*/
protected $discountProfile;
public function getDiscountProfile() { return $this->discountProfile; }
public function setDiscountProfile($discountProfile) {
$this->discountProfile = $discountProfile;
}
}
<?php
// Pastèque API
//
// Copyright (C)
// 2012 Scil (http://scil.coop)
// 2017 Karamel, Association Pastèque (karamel@creativekara.fr, https://pasteque.org)
//
// This file is part of Pastèque.
//
// Pastèque is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pastèque is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pastèque. If not, see <http://www.gnu.org/licenses/>.
namespace Pasteque\Server\Model;
use \Pasteque\Server\System\DAO\DAO;
use \Pasteque\Server\System\DAO\DoctrineModel;
/**
* Class OrderLine.
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @Table(name="orderlines")
*/
class OrderLine extends DoctrineModel // Embedded class
{
public function getDirectFieldNames() {
return ['dispOrder', 'productLabel', 'unitPrice', 'quantity', 'price',
'taxRate', 'taxAmount', 'totalAmount', 'discountRate',
'discountPrice', 'discountTax', 'discountTotal' ];
}
public function getAssociationFields() {
return [
[
'name' => 'order',
'class' => '\Pasteque\Server\Model\Order',
'null' => true // because embedded
],
[
'name' => 'product',
'class' => '\Pasteque\Server\Model\Product',
'null' => true
],
[
'name' => 'tax',
'class' => '\Pasteque\Server\Model\Tax',
]
];
}
public function getId() {
return array('order' => $this->getOrder()->getId(),
'dispOrder' => $this->getDispOrder());
}
/**
* @var integer
* @SWG\Property
* @ManyToOne(targetEntity="\Pasteque\Server\Model\Order", inversedBy="lines")
* @JoinColumn(name="order_id", referencedColumnName="id", nullable=false)
* @Id
*/
protected $order;
public function getOrder() { return $this->order; }
public function setOrder($order) { $this->order = $order; }
/**
* Display order or number of the line
* @var integer
* @SWG\Property()
* @Column(type="integer")
* @Id
*/
protected $dispOrder;
public function getDispOrder() { return $this->dispOrder; }
public function setDispOrder($dispOrder) { $this->dispOrder = $dispOrder; }
/**
* Id of the product
* @var integer
* @SWG\Property()
* @ManyToOne(targetEntity="\Pasteque\Server\Model\Product")
* @JoinColumn(name="product_id", referencedColumnName="id")
*/
protected $product;
public function getProduct() { return $this->product; }
/** Set the product. If productLabel is null, it will be set with
* the label of the product. */
public function setProduct($product) {
$this->product = $product;
if ($this->getProductLabel() === null) {
$this->setProductLabel($product->getLabel());
}
}
/**
* Label of product at the ticket time (or when product is null)
* @var string null
* @SWG\Property()
* @Column(type="string")
*/
protected $productLabel;
public function getProductLabel() { return $this->productLabel; }
public function setProductLabel($productLabel) {
$this->productLabel = $productLabel;
}
/**
* Unit price without tax and before applying discount
* Id of taxe on the ticket line
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $unitPrice;
public function getUnitPrice() { return round($this->unitPrice, 5); }
public function setUnitPrice($unitPrice) {
$this->unitPrice = round($unitPrice, 5);
}
/**
* Quantity of product on this ticket line
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $quantity = 1.0;
public function getQuantity() { return round($this->quantity, 5); }
public function setQuantity($quantity) {
$this->quantity = round($quantity, 5);
}
/**
* In quantity price without tax and before applying discount.
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $price;
public function getPrice() { return round($this->price, 5); }
public function setPrice($price) {
$this->price = round($price, 5);
}
/**
* Id of taxe on the ticket line
* @var float
* @SWG\Property()
* @ManyToOne(targetEntity="\Pasteque\Server\Model\Tax")
* @JoinColumn(name="tax_id", referencedColumnName="id", nullable=false)
*/
protected $tax;
public function getTax() { return $this->tax; }
public function setTax($tax) { $this->tax = $tax; }
/**
* Rate of the tax at the time of the ticket
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $taxRate;
public function getTaxRate() { return $this->taxRate; }
public function setTaxRate($taxRate) { $this->taxRate = $taxRate; }
/**
* Total amount of tax before discount.
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $taxAmount;
public function getTaxAmount() { return round($this->taxAmount, 5); }
public function setTaxAmount($taxAmount) {
$this->taxAmount = round($taxAmount, 5);
}
/**
* Total price with tax before discount.
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $totalAmount;
public function getTotalAmount() { return round($this->totalAmount, 5); }
public function setTotalAmount($totalAmount) {
$this->totalAmount = round($totalAmount, 5);
}
/**
* Rate of discount on this ticket line
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $discountRate = 0.0;
public function getDiscountRate() { return $this->discountRate; }
public function setDiscountRate($discountRate) { $this->discountRate = $discountRate; }
/**
* Total price without taxes with discount rate.
* Can be autocomputed when discountRate is 0.0
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $discountPrice;
public function getDiscountPrice() {
return round($this->discountPrice, 5);
}
public function setDiscountPrice($discountPrice) {
$this->discountPrice = round($discountPrice, 5);
}
/**
* Total taxes with discount rate.
* Can be autocomputed when discountRate is 0.0
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $discountTax;
public function getDiscountTax() {
return round($this->discountTax, 5);
}
public function setDiscountTax($discountTax) {
$this->discountTax = round($discountTax, 5);
}
/**
* Total price with taxes and discount rate.
* Can be autocomputed when discountRate is 0.0
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected $discountTotal;
public function getDiscountTotal() {
return round($this->discountTotal, 5);
}
public function setDiscountTotal($discountTotal) {
$this->discountTotal = round($discountTotal, 5);
}
/** Compute discount values when from original values and discount rate. */
public function autocompute() {
$rate = $this->getDiscountRate();
$this->setDiscountPrice($this->getPrice() * (1.0 - $rate));
$this->setDiscountTax($this->getTaxAmount() * (1.0 - $rate));
$this->setDiscountTotal($this->getTotalAmount() * (1.0 - $rate));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment