Common/View/ViewBuilder.php
public function buildSaleView(Model\SaleInterface $sale, array $options = [])
    {
        $this->initialize($sale, $options);

        $this->amountCalculator->calculateSale($sale);

        // Gross total view
        $grossResult = $sale->getGrossResult();
        $this->view->setGross(new TotalView(
            $this->formatter->currency($grossResult->getGross($this->view->isAti())),
            $this->formatter->currency($grossResult->getDiscount($this->view->isAti())),
            $this->formatter->currency($grossResult->getBase($this->view->isAti()))
        ));

        // Final total view
        $finalResult = $sale->getFinalResult();
        $this->view->setFinal(new TotalView(
            $this->formatter->currency($finalResult->getBase()),
            $this->formatter->currency($finalResult->getTax()),
            $this->formatter->currency($finalResult->getTotal())
        ));

        if ($this->options['private'] && null !== $margin = $this->marginCalculator->calculateSale($sale)) {
            $prefix = $margin->isAverage() ? '~' : '';
            $this->view->setMargin(new MarginView(
                $prefix . $this->formatter->currency($margin->getAmount()),
                $prefix . $this->formatter->percent($margin->getPercent())
            ));
            $this->view->vars['show_margin'] = true;
        }

        // Items lines
        $this->buildSaleItemsLinesViews($sale);
        // Discounts lines
        $this->buildSaleDiscountsLinesViews($sale);
        // Shipment line
        $this->buildShipmentLine($sale);
        // Taxes views
        $this->buildSaleTaxesViews($sale);

        // Extends
        foreach ($this->types as $type) {
            $type->buildSaleView($sale, $this->view, $this->options);
        }

        $columnsCount = 6;
        if ($this->view->vars['show_availability']) {
            $columnsCount++;
        }
        if ($this->view->vars['show_discounts'] = 0 < count($grossResult->getDiscountAdjustments())) {
            $columnsCount += 3;
        }
        if ($this->view->vars['show_taxes'] = 1 < count($finalResult->getTaxAdjustments())) {
            $columnsCount++;
        }
        if ($this->view->vars['show_margin']) {
            $columnsCount++;
        }
        if ($this->options['editable']) {
            $columnsCount++;
        }
        $this->view->vars['columns_count'] = $columnsCount;

        return $this->view;
    }
public function buildSaleView(Model\SaleInterface $sale, array $options = [])
    {
        $this->initialize($sale, $options);

        $this->amountCalculator->calculateSale($sale);

        // Gross total view
        $grossResult = $sale->getGrossResult();
        $this->view->setGross(new TotalView(
            $this->formatter->currency($grossResult->getGross($this->view->isAti())),
            $this->formatter->currency($grossResult->getDiscount($this->view->isAti())),
            $this->formatter->currency($grossResult->getBase($this->view->isAti()))
        ));

        // Final total view
        $finalResult = $sale->getFinalResult();
        $this->view->setFinal(new TotalView(
            $this->formatter->currency($finalResult->getBase()),
            $this->formatter->currency($finalResult->getTax()),
            $this->formatter->currency($finalResult->getTotal())
        ));

        if ($this->options['private'] && null !== $margin = $this->marginCalculator->calculateSale($sale)) {
            $prefix = $margin->isAverage() ? '~' : '';
            $this->view->setMargin(new MarginView(
                $prefix . $this->formatter->currency($margin->getAmount()),
                $prefix . $this->formatter->percent($margin->getPercent())
            ));
            $this->view->vars['show_margin'] = true;
        }

        // Items lines
        $this->buildSaleItemsLinesViews($sale);
        // Discounts lines
        $this->buildSaleDiscountsLinesViews($sale);
        // Shipment line
        $this->buildShipmentLine($sale);
        // Taxes views
        $this->buildSaleTaxesViews($sale);

        // Extends
        foreach ($this->types as $type) {
            $type->buildSaleView($sale, $this->view, $this->options);
        }

        $columnsCount = 6;
        if ($this->view->vars['show_availability']) {
            $columnsCount++;
        }
        if ($this->view->vars['show_discounts'] = 0 < count($grossResult->getDiscountAdjustments())) {
            $columnsCount += 3;
        }
        if ($this->view->vars['show_taxes'] = 1 < count($finalResult->getTaxAdjustments())) {
            $columnsCount++;
        }
        if ($this->view->vars['show_margin']) {
            $columnsCount++;
        }
        if ($this->options['editable']) {
            $columnsCount++;
        }
        $this->view->vars['columns_count'] = $columnsCount;

        return $this->view;
    }
Builds the sale view.

@param Model\SaleInterface $sale
@param array               $options

@return SaleView