stats sales with mago
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Tabelle locali (copia in sola lettura) dei dati Mago4 per le statistiche ordini cliente.
|
||||
*
|
||||
* - mago_sale_ord : testate ordini cliente (MA_SaleOrd)
|
||||
* - mago_cust_supp : anagrafica clienti (MA_CustSupp, solo clienti)
|
||||
* - mago_sync_state : stato dell'ultima sincronizzazione per ogni entità
|
||||
*/
|
||||
final class CreateMagoSalesTables extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
// ---------- ORDINI CLIENTE (testate) ----------
|
||||
$this->table('mago_sale_ord', [
|
||||
'id' => false,
|
||||
'primary_key' => ['sale_ord_id'],
|
||||
'comment' => 'Copia locale MA_SaleOrd (Mago4) - sola lettura',
|
||||
])
|
||||
->addColumn('sale_ord_id', 'integer', ['signed' => false])
|
||||
->addColumn('internal_ord_no', 'string', ['limit' => 30, 'default' => ''])
|
||||
->addColumn('external_ord_no', 'string', ['limit' => 60, 'default' => ''])
|
||||
->addColumn('order_date', 'date', ['null' => true])
|
||||
->addColumn('expected_delivery_date', 'date', ['null' => true])
|
||||
->addColumn('confirmed_delivery_date', 'date', ['null' => true])
|
||||
->addColumn('compulsory_delivery_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_manager', 'string', ['limit' => 20, 'default' => ''])
|
||||
->addColumn('area', 'string', ['limit' => 20, 'default' => ''])
|
||||
->addColumn('payment', 'string', ['limit' => 20, 'default' => ''])
|
||||
->addColumn('currency', 'string', ['limit' => 8, 'default' => ''])
|
||||
->addColumn('our_reference', 'string', ['limit' => 150, 'default' => ''])
|
||||
->addColumn('your_reference', 'string', ['limit' => 150, 'default' => ''])
|
||||
->addColumn('transport', 'string', ['limit' => 20, 'default' => ''])
|
||||
->addColumn('port', 'string', ['limit' => 20, 'default' => ''])
|
||||
->addColumn('package', 'string', ['limit' => 40, 'default' => ''])
|
||||
->addColumn('storage', 'string', ['limit' => 30, 'default' => ''])
|
||||
->addColumn('job', 'string', ['limit' => 30, 'default' => ''])
|
||||
->addColumn('delivered', 'boolean', ['default' => false])
|
||||
->addColumn('invoiced', 'boolean', ['default' => false])
|
||||
->addColumn('cancelled', 'boolean', ['default' => false])
|
||||
->addColumn('is_blocked', 'boolean', ['default' => false])
|
||||
->addColumn('printed', 'boolean', ['default' => false])
|
||||
->addColumn('archived', 'boolean', ['default' => false])
|
||||
->addColumn('open_order', 'boolean', ['default' => false])
|
||||
->addColumn('priority', 'integer', ['default' => 0])
|
||||
->addColumn('notes', 'text', ['null' => true])
|
||||
->addColumn('tb_created', 'datetime', ['null' => true])
|
||||
->addColumn('tb_modified', 'datetime', ['null' => true])
|
||||
->addColumn('raw_json', 'text', ['null' => true, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::TEXT_LONG])
|
||||
->addColumn('synced_at', 'datetime', ['null' => true])
|
||||
->addIndex(['order_date'])
|
||||
->addIndex(['customer'])
|
||||
->addIndex(['salesperson'])
|
||||
->addIndex(['area'])
|
||||
->addIndex(['tb_modified'])
|
||||
->addIndex(['internal_ord_no'])
|
||||
->create();
|
||||
|
||||
// ---------- ANAGRAFICA CLIENTI ----------
|
||||
$this->table('mago_cust_supp', [
|
||||
'id' => false,
|
||||
'primary_key' => ['cust_supp_type', 'cust_supp'],
|
||||
'comment' => 'Copia locale MA_CustSupp (Mago4) - sola lettura',
|
||||
])
|
||||
->addColumn('cust_supp_type', 'integer')
|
||||
->addColumn('cust_supp', 'string', ['limit' => 20])
|
||||
->addColumn('company_name', 'string', ['limit' => 200, 'default' => ''])
|
||||
->addColumn('city', 'string', ['limit' => 100, 'default' => ''])
|
||||
->addColumn('county', 'string', ['limit' => 10, 'default' => ''])
|
||||
->addColumn('region', 'string', ['limit' => 60, 'default' => ''])
|
||||
->addColumn('country', 'string', ['limit' => 60, 'default' => ''])
|
||||
->addColumn('iso_country_code', 'string', ['limit' => 4, 'default' => ''])
|
||||
->addColumn('disabled', 'boolean', ['default' => false])
|
||||
->addColumn('tb_modified', 'datetime', ['null' => true])
|
||||
->addColumn('synced_at', 'datetime', ['null' => true])
|
||||
->addIndex(['company_name'])
|
||||
->create();
|
||||
|
||||
// ---------- STATO SINCRONIZZAZIONE ----------
|
||||
$this->table('mago_sync_state', [
|
||||
'id' => false,
|
||||
'primary_key' => ['entity'],
|
||||
])
|
||||
->addColumn('entity', 'string', ['limit' => 50])
|
||||
->addColumn('last_tb_modified', 'datetime', ['null' => true])
|
||||
->addColumn('last_run_at', 'datetime', ['null' => true])
|
||||
->addColumn('last_status', 'string', ['limit' => 20, 'default' => ''])
|
||||
->addColumn('last_message', 'text', ['null' => true])
|
||||
->addColumn('records_last_run', 'integer', ['default' => 0])
|
||||
->addColumn('duration_ms', 'integer', ['default' => 0])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Importi degli ordini cliente da MA_SaleOrdSummary (Mago4).
|
||||
*/
|
||||
final class AddAmountsToMagoSaleOrd extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('mago_sale_ord')
|
||||
->addColumn('taxable_amount', 'decimal', ['precision' => 15, 'scale' => 2, 'default' => 0, 'after' => 'notes', 'comment' => 'Imponibile'])
|
||||
->addColumn('tax_amount', 'decimal', ['precision' => 15, 'scale' => 2, 'default' => 0, 'after' => 'taxable_amount', 'comment' => 'IVA'])
|
||||
->addColumn('total_amount', 'decimal', ['precision' => 15, 'scale' => 2, 'default' => 0, 'after' => 'tax_amount', 'comment' => 'Totale documento'])
|
||||
->addColumn('goods_amount', 'decimal', ['precision' => 15, 'scale' => 2, 'default' => 0, 'after' => 'total_amount', 'comment' => 'Valore merce'])
|
||||
->addColumn('discounts', 'decimal', ['precision' => 15, 'scale' => 2, 'default' => 0, 'after' => 'goods_amount', 'comment' => 'Sconti'])
|
||||
->addColumn('charges', 'decimal', ['precision' => 15, 'scale' => 2, 'default' => 0, 'after' => 'discounts', 'comment' => 'Spese (trasporto, imballo, incasso, bolli, varie)'])
|
||||
->addColumn('summary_tb_modified', 'datetime', ['null' => true, 'after' => 'charges', 'comment' => 'NULL = totali non ancora letti'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user