50 lines
2.7 KiB
PHP
50 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
/**
|
|
* Documenti di vendita da MA_SaleDoc + importi da MA_SaleDocSummary (Mago4).
|
|
* Servono per il FATTURATO per data documento (fatture, fatture d'acconto, note di credito).
|
|
* Si salvano tutti i tipi (anche DDT): quali contano come fatturato si decide in MagoSalesStats.
|
|
*/
|
|
final class CreateMagoSaleDoc extends AbstractMigration
|
|
{
|
|
public function change(): void
|
|
{
|
|
$this->table('mago_sale_doc', [
|
|
'id' => false,
|
|
'primary_key' => ['sale_doc_id'],
|
|
'comment' => 'Copia locale MA_SaleDoc + MA_SaleDocSummary (Mago4) - sola lettura',
|
|
])
|
|
->addColumn('sale_doc_id', 'integer', ['signed' => false])
|
|
->addColumn('document_type', 'integer', ['default' => 0, 'comment' => '3407874 fattura, 3407883 acconto, 3407876 nota credito, 3407873 DDT...'])
|
|
->addColumn('doc_no', 'string', ['limit' => 30, 'default' => ''])
|
|
->addColumn('document_date', 'date', ['null' => true])
|
|
->addColumn('posting_date', 'date', ['null' => true])
|
|
->addColumn('customer', 'string', ['limit' => 20, 'default' => ''])
|
|
->addColumn('invoicing_customer', 'string', ['limit' => 20, 'default' => ''])
|
|
->addColumn('salesperson', 'string', ['limit' => 20, 'default' => ''])
|
|
->addColumn('area', 'string', ['limit' => 20, 'default' => ''])
|
|
->addColumn('currency', 'string', ['limit' => 8, 'default' => ''])
|
|
->addColumn('tax_journal', 'string', ['limit' => 20, 'default' => '', 'comment' => 'Registro IVA: vuoto per DDT/proforma'])
|
|
->addColumn('inv_rsn', 'string', ['limit' => 20, 'default' => ''])
|
|
->addColumn('ei_document_type', 'integer', ['default' => 0])
|
|
->addColumn('issued', 'boolean', ['default' => false])
|
|
->addColumn('cancelled', 'boolean', ['default' => false])
|
|
->addColumn('posted_to_accounting', 'boolean', ['default' => false])
|
|
->addColumn('taxable_amount', 'decimal', ['precision' => 15, 'scale' => 2, 'null' => true])
|
|
->addColumn('tax_amount', 'decimal', ['precision' => 15, 'scale' => 2, 'null' => true])
|
|
->addColumn('total_amount', 'decimal', ['precision' => 15, 'scale' => 2, 'null' => true])
|
|
->addColumn('summary_tb_modified', 'datetime', ['null' => true])
|
|
->addColumn('tb_created', 'datetime', ['null' => true])
|
|
->addColumn('tb_modified', 'datetime', ['null' => true])
|
|
->addColumn('synced_at', 'datetime', ['null' => true])
|
|
->addIndex(['document_date'])
|
|
->addIndex(['document_type', 'document_date'])
|
|
->addIndex(['customer'])
|
|
->create();
|
|
}
|
|
}
|