X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=UpdateDatabase.php;h=91b91e56ac5fed240310d813e2e34b59c10add93;hb=HEAD;hp=9a5373d1b1c63c9bf7aa8adbba96854f7c804d9f;hpb=95348bfc1d4b21be8439621b22de6aeede167b4d;p=Pman.Xtuple diff --git a/UpdateDatabase.php b/UpdateDatabase.php index 9a5373d1..91b91e56 100644 --- a/UpdateDatabase.php +++ b/UpdateDatabase.php @@ -103,7 +103,7 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase } - function get($k = '',$opts) + function get($k = '',$opts=array()) { $k = strtolower($k); @@ -176,7 +176,8 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase HTML_FlexyFramework::get()->generateDataobjectsCache(true); $this->{$dirmethod}($dburl, $this->rootDir. "/Pman/$m/{$dbtype}.initdata"); - $this->{'fixSequences'. $dbtype}(); + // fixSequences does nto appar to work on postgres anymore + //$this->{'fixSequences'. $dbtype}(); } @@ -204,6 +205,11 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase 'taxzone', 'taxtype', 'expcat', + + 'custinfo', // create a base customer based on company. + 'location', // default warehouse. + 'period', // adds years and months -1 to +10 from now. + // accounts - fixme - we need a better 'base set' // 'costcat' -- fixme - we need to init this.. @@ -212,9 +218,11 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase // 'location', //?? just check hat one exists. ) : array($k); - - $core_opts = HTML_FlexyFramework::get()->page->opts; - if (!empty($core_opts['init'])) { + $core_opts = HTML_FlexyFramework::get()->page->opts; + + if (!empty($core_opts['base'])) { + DB_DataObject::DebugLevel(1); + DB_DataObject::factory('curr_symbol')->importFromArray($this, array($core_opts['base'])); DB_DataObject::factory('curr_symbol')->setBase($this, $core_opts['base']); } @@ -231,6 +239,10 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase $this->updateMetricValue(); + $this->addAccounts(); + + + } function updateMetricValue() @@ -273,66 +285,9 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase + - - - - - - - - - - - /* - - function updateData($k='') - { - - $this->addWarehouse(); - $this->addExtraYears(); - $this->addAccounts(); - $this->addBankAccounts(); - } - */ - - function addWarehouse() - { - $l = DB_DataObject::Factory('location'); - if ($l->count()) { - echo "location exists - SKIP\n"; - return; - } - $cust = DB_DataObject::Factory('custinfo'); - $cc =$cust->count() ; - if ($cc != 1) { - echo "location create - needs 1 custinfo - got $cc\n"; - return; - } - $cust->find(true); - - $l->setFrom(array( - 'location_name' => 'Warehouse', - 'location_descrip' => 'Warehouse', - 'location_cust_id' => $cust->pid() - )); - } - - - - function addExtraYears() - { - $p = DB_DataObject::Factory('period'); - if ($p->count()) { - echo "SKIP - already have periods\n"; - return; - } - $p->initPeriods($this); - $p->initPeriods($this); - $p->initPeriods($this); - $p->initPeriods($this); - - } + function addAccounts() { $ac = DB_DataObject::factory('accnt'); @@ -340,6 +295,7 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase return; } + // this might want to be configurable -- so that we could use different 'base files' for the accounts.. require_once 'File/Convert.php'; $cp = $this->tempName('xls'); copy(dirname(__FILE__).'/Setup/accounts_sample.xls', $cp); @@ -353,108 +309,6 @@ class Pman_Xtuple_UpdateDatabase extends Pman_Core_UpdateDatabase $ia->importCsv($csv); } - function addBankAccounts() { - - $accnt = DB_DataObject::factory('subaccnt'); - if (!$accnt->get('subaccnt_number', '01')) { - echo "SKIP Bank account creation - no subaccnt - 01\n"; - return; - } - - $bankaccnt = DB_DataObject::factory('bankaccnt'); - - $bankaccnt->whereAdd(" - bankaccnt_name != '' - "); - - if(!$bankaccnt->count()){ - $bankaccnt = DB_DataObject::factory('bankaccnt'); - - if(!$bankaccnt->get('bankaccnt_name', 'Current Account')){ - $accnt = DB_DataObject::factory('accnt'); - $accnt->setFrom(array( - 'accnt_number' => '131', - 'accnt_descrip' => 'Current Account', - 'accnt_comments' => '', - 'accnt_profit' => '01', - 'accnt_sub' => '01', - 'accnt_type' => 'A', - 'accnt_extref' => '', - 'accnt_closedpost' => false, - 'accnt_forwardupdate' => false, - 'accnt_subaccnttype_code' => 'CA', - 'accnt_curr_id' => $accnt->sqlValue("baseCurrId()"), - 'accnt_active' => true - )); - - if(!$accnt->find(true)){ - $accnt->insert(); - } - - $bankaccnt->setFrom(array( - 'bankaccnt_name' => 'Current Account', - 'bankaccnt_descrip' => 'Current Account', - 'bankaccnt_bankname' => 'Current Account', - 'bankaccnt_accntnumber' => 'N/A', - 'bankaccnt_ar' => true, - 'bankaccnt_ap' => true, - 'bankaccnt_nextchknum' => 5000, - 'bankaccnt_type' => 'K', - 'bankaccnt_accnt_id' => $accnt->pid(), - 'bankaccnt_curr_id' => $bankaccnt->sqlValue("baseCurrId()"), - 'bankaccnt_notes' => '', - 'bankaccnt_routing' => '', - 'bankaccnt_ach_enabled' => false, - 'bankaccnt_ach_origintype' => 'I' - )); - - $bankaccnt->insert(); - } - - $bankaccnt = DB_DataObject::factory('bankaccnt'); - - if(!$bankaccnt->get('bankaccnt_name', 'Savings Account')){ - $accnt = DB_DataObject::factory('accnt'); - $accnt->setFrom(array( - 'accnt_number' => '404', - 'accnt_descrip' => 'Savings Account', - 'accnt_comments' => '', - 'accnt_profit' => '01', - 'accnt_sub' => '01', - 'accnt_type' => 'A', - 'accnt_extref' => '', - 'accnt_closedpost' => false, - 'accnt_forwardupdate' => false, - 'accnt_subaccnttype_code' => 'CA', - 'accnt_curr_id' => $accnt->sqlValue("baseCurrId()"), - 'accnt_active' => true - )); - - if(!$accnt->find(true)){ - $accnt->insert(); - } - - $bankaccnt->setFrom(array( - 'bankaccnt_name' => 'Savings Account', - 'bankaccnt_descrip' => 'Savings Account', - 'bankaccnt_bankname' => 'Savings Account', - 'bankaccnt_accntnumber' => 'N/A', - 'bankaccnt_ar' => true, - 'bankaccnt_ap' => true, - 'bankaccnt_nextchknum' => 5000, - 'bankaccnt_type' => 'K', - 'bankaccnt_accnt_id' => $accnt->pid(), - 'bankaccnt_curr_id' => $bankaccnt->sqlValue("baseCurrId()"), - 'bankaccnt_notes' => '', - 'bankaccnt_routing' => '', - 'bankaccnt_ach_enabled' => false, - 'bankaccnt_ach_origintype' => 'I' - )); - - $bankaccnt->insert(); - } - } - - } + } \ No newline at end of file