diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index bf28e6a3db6..7572e0d2030 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -117,17 +117,33 @@ CREATE TABLE llx_product_attribute_combination entity INT DEFAULT 1 NOT NULL ); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Journal des ventes', 1, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Journal des achats', 2, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Journal de banque', 3, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Journal des opérations diverses', 0, 1); -INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Journal des à-nouveaux', 9, 1); -ALTER TABLE llx_accounting_journal ADD COLUMN entity integer DEFAULT 1; +ALTER TABLE llx_bank_account drop foreign key bank_fk_accountancy_journal; + +-- Add journal entries +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Sale journal', 2, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Purchase journal', 3, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (3,'BQ', 'Bank journal', 4, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (4,'OD', 'Other journal', 1, 1); +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Has new journal', 9, 1); +-- Fix old entries +UPDATE llx_accounting_journal SET nature = 1 where code = 'OD' and nature = 0; +UPDATE llx_accounting_journal SET nature = 2 where code = 'VT' and nature = 1; +UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2; +UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3; + +UPDATE llx_bank_account as ba set accountancy_journal = 'BQ' where accountancy_journal = 'BK'; +UPDATE llx_bank_account as ba set accountancy_journal = 'OD' where accountancy_journal IS NULL; + +ALTER TABLE llx_bank_account ADD COLUMN fk_accountancy_journal integer; +ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal); + +UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal as aj where ba.accountancy_journal = aj.code) where accountancy_journal not in ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); +ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); + ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255); - insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); @@ -262,14 +278,6 @@ insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); -UPDATE llx_accounting_journal SET nature = 1 where code = 'OD' and nature = 0; -UPDATE llx_accounting_journal SET nature = 2 where code = 'VT' and nature = 1; -UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2; -UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3; - - -ALTER TABLE llx_bank_account CHANGE COLUMN accountancy_journal fk_accountancy_journal integer; ---ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); diff --git a/htdocs/install/mysql/tables/llx_bank_account.key.sql b/htdocs/install/mysql/tables/llx_bank_account.key.sql index 986ca7ea550..c5f2786fd24 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.key.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.key.sql @@ -19,5 +19,6 @@ ALTER TABLE llx_bank_account ADD UNIQUE uk_bank_account_label (label,entity); +ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal); --- ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); +ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index 95f0f9f2134..7578be73745 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -537,14 +537,14 @@ if (GETPOST("source") == 'invoice') { $result=$invoice->fetch_thirdparty($invoice->socid); } - + if ($action != 'dopayment') // Do not change amount if we just click on first dopayment { $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); $amount=price2num($amount); } - + $fulltag='INV='.$invoice->ref.'.CUS='.$invoice->thirdparty->id; //$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," "); if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; }