<commit_before><?php

require_once 'xml_utils.php';
require_once 'product.php';
require_once 'tax.php';

class InvoiceLine
{
    public function initFromDbLine($db, $line)
    {
        $taxId = $line['tax_id'];

        $this->_tax = new Tax();
        $this->_tax->queryDbById($taxId, $db);

        $this->_number      =   (int)$line['line_number'];
        $this->_quantity    =   (int)$line['quantity'];
        $this->_unitPrice   =   (float)$line['unit_price'];

        $this->_creditAmount = $this->_quantity * $this->_unitPrice;

        $this->_product = new Product;
        $error = $this->_product->queryDbById((int)$line['product_id'], $db);
        if ($error)
            return $error;

        return 0;
    }

    public function getTaxPercentage()
    {
        return $this->_tax->getPercentage();
    }

    public function getCreditAmount()
    {
        return $this->_creditAmount;
    }

    public function toArray()
    {
        return [
            'LineNumber'    => $this->_number,
            'ProductCode'   => $this->_product->getCode(),
            'ProductDescription' => $this->_product->getDescription(),
            'Quantity'      => $this->_quantity,
            'UnitOfMeasure' => 'Euro',
            'UnitPrice'     => $this->_unitPrice,
            'TaxPointDate'  => 'N/A', // set in toArray() of Invoice
            'Description'   => $this->_quantity . 'x ' . $this->_product->getDescription(),
            'CreditAmount'  => $this->_creditAmount,
            'Tax'           => $this->_tax->toArray()<commit_msg>UnitOfMeasure is not coin, change to 'Unit'<commit_after><?php

require_once 'xml_utils.php';
require_once 'product.php';
require_once 'tax.php';

class InvoiceLine
{
    public function initFromDbLine($db, $line)
    {
        $taxId = $line['tax_id'];

        $this->_tax = new Tax();
        $this->_tax->queryDbById($taxId, $db);

        $this->_number      =   (int)$line['line_number'];
        $this->_quantity    =   (int)$line['quantity'];
        $this->_unitPrice   =   (float)$line['unit_price'];

        $this->_creditAmount = $this->_quantity * $this->_unitPrice;

        $this->_product = new Product;
        $error = $this->_product->queryDbById((int)$line['product_id'], $db);
        if ($error)
            return $error;

        return 0;
    }

    public function getTaxPercentage()
    {
        return $this->_tax->getPercentage();
    }

    public function getCreditAmount()
    {
        return $this->_creditAmount;
    }

    public function toArray()
    {
        return [
            'LineNumber'    => $this->_number,
            'ProductCode'   => $this->_product->getCode(),
            'ProductDescription' => $this->_product->getDescription(),
            'Quantity'      => $this->_quantity,
            'UnitOfMeasure' => 'Unit',
            'UnitPrice'     => $this->_unitPrice,
            'TaxPointDate'  => 'N/A', // set in toArray() of Invoice
            'Description'   => $this->_quantity . 'x ' . $this->_product->getDescription(),
            'CreditAmount'  => $this->_creditAmount,
            'Tax'           => $this->_tax->toArray()
{'fraction_non_alphanumeric': 0.16455294863665187, 'fraction_numerical': 0.0006341154090044388, 'mean_word_length': 2.1900910010111225, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6778607', 'n_tokens_mistral': 957, 'n_tokens_neox': 913, 'n_words': 169}