<?php

namespace app\commands;

use yii\console\Controller;
use yii\console\ExitCode;

use app\models\Invoice;

class TestController extends Controller
{
    public function actionInvoice($buyer = 123123, $order = 0)
    {
        // Генерация счета
        Invoice::generate($order, $this->renderPartial('/invoice/order/pattern', [
            'buyer' => [
                'id' => $buyer,
                'info' => 'Неизвестно'
            ],
            'order' => [
                'id' => $order,
                'date' => time(),
                'entries' => [
                    [
                        'title' => 'Тестовое вхождение',
                        'amount' => [
                            'value' => 1,
                            'unit' => 'шт'
                        ],
                        'cost' => [
                            'value' => 1000,
                            'unit' => 'руб'
                        ],
                        'type' => 'supply'
                    ],
                    [
                        'title' => 'Тестовое вхождение',
                        'amount' => [
                            'value' => 1,
                            'unit' => 'шт'
                        ],
                        'cost' => [
                            'value' => 1000,
                            'unit' => 'руб'
                        ],
                        'type' => 'supply'
                    ],
                    [
                        'title' => 'Тестовое вхождение',
                        'amount' => [
                            'value' => 1,
                            'unit' => 'шт'
                        ],
                        'cost' => [
                            'value' => 1000,
                            'unit' => 'руб'
                        ],
                        'type' => 'supply'
                    ],
                    [
                        'title' => 'Тестовое вхождение',
                        'amount' => [
                            'value' => 5,
                            'unit' => 'шт'
                        ],
                        'cost' => [
                            'value' => 1000,
                            'unit' => 'руб'
                        ],
                        'type' => 'supply'
                    ]
                ]
            ]
        ]));

        return ExitCode::OK;
    }
}
