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(); } }