public function load() { $order = new Order(); $json = file_get_contents($this->filename); $data = json_decode($json, true); $order->setRef($data['ref']); $order->setState($data['state']); foreach ($data['attributes'] as $attributedata) { $attribute = new Attribute(); $attribute->setKey($attributedata['key']); $attribute->setValue($attributedata['value']); $order->addAttribute($attribute); } foreach ($data['lines'] as $linedata) { $orderline = new OrderLine(); $orderline->setQuantity($linedata['quantity']); $orderline->setUnitPrice($linedata['unitprice']); $orderline->setTitle($linedata['title']); $vat = new Vat(); $vat->setValue($linedata['vatvalue']); $orderline->setVat($vat); foreach ($linedata['attributes'] as $attributedata) { $attribute = new Attribute(); $attribute->setKey($attributedata['key']); $attribute->setValue($attributedata['value']); $orderline->addAttribute($attribute); } $order->addLine($orderline); } return $order; }
public function it_is_correct_when_calculating_total() { $vat = new Vat(); $vat->setValue(21.5); $this->setQuantity(3)->setUnitPrice(4323)->setVat($vat)->shouldReturn($this); $this->getTotalPrice()->shouldReturn(15692); }
protected function execute(InputInterface $input, OutputInterface $output) { $vat = new Vat(); $vat->setValue(21); $line = new InvoiceLine(); $line->setVat($vat)->setQuantity(3)->setUnitPrice(200); $output->writeLn('Unit total: ' . $line->getUnitPriceTotal()); $output->writeLn('Total: ' . $line->getTotalPrice()); }