';
-print $langs->trans('From');
+print $langs->trans('From').' ';
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
@@ -411,7 +411,7 @@ else
}
print '
';
print '
';
-print $langs->trans('to');
+print $langs->trans('to').' ';
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 8ef93d5b842..132b02356d7 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -118,6 +118,7 @@ if ($in_bookkeeping == 'already')
if ($in_bookkeeping == 'notyet')
$sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
$sql .= " ORDER BY b.datev";
+//print $sql;
$object = new Account($db);
$paymentstatic = new Paiement($db);
@@ -158,10 +159,10 @@ if ($result) {
$tabtp = array ();
$tabtype = array ();
- // Loop on each line into bank account. For each line, we should get:
- // on line tabpay = line into bank
- // one line for bank jounral = tabbq
- // one line for thirdparty journal = tabtp
+ // Loop on each line into llx_bank table. For each line, we should get:
+ // one line tabpay = line into bank
+ // one line for bank record = tabbq
+ // one line for thirdparty record = tabtp
$i = 0;
while ( $i < $num )
{
@@ -202,11 +203,16 @@ if ($result) {
}
$links = $object->get_url($obj->rowid);
- /*var_dump($i);
- var_dump($links);*/
+ //var_dump($i);
+ //var_dump($tabpay);
+
+ // By default
+ $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or old record with no links in bank_url.
+ $tabtype[$obj->rowid] = 'unknown';
// get_url may return -1 which is not traversable
if (is_array($links) && count($links) > 0) {
+
// Now loop on each link of record in bank.
foreach ($links as $key => $val) {
@@ -218,6 +224,14 @@ if ($result) {
$tabpay[$obj->rowid]['type'] = $links[$key]['type'];
$tabtype[$obj->rowid] = $links[$key]['type'];
}
+ elseif (in_array($links[$key]['type'], array('company', 'user')))
+ {
+ if ($tabpay[$obj->rowid]['type'] == 'unknown')
+ {
+ // We can guess here it is a bank record for a company or a user.
+ // But we won't be able to record somewhere else than into a waiting account, because there is no other journal to record the contreparty.
+ }
+ }
if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
@@ -306,10 +320,6 @@ if ($result) {
}
}
}
- else
- {
- $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or old record with no links in bank_url.
- }
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
@@ -586,13 +596,16 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->label_compte = '';
$bookkeeping->doc_ref = '';
} else {
- // Temporary account
- $bookkeeping->label_operation = '';
- $bookkeeping->subledger_account = '';
- $bookkeeping->subledger_label = '';
- $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
- $bookkeeping->label_compte = '';
- $bookkeeping->doc_ref = $k;
+ if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty.
+ {
+ // Temporary account
+ $bookkeeping->label_operation = '';
+ $bookkeeping->subledger_account = '';
+ $bookkeeping->subledger_label = '';
+ $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
+ $bookkeeping->label_compte = '';
+ $bookkeeping->doc_ref = $k;
+ }
}
$result = $bookkeeping->create($user);
@@ -1054,12 +1067,21 @@ if (empty($action) || $action == 'view') {
$accounttoshow = length_accounta($account_ledger);
if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
{
- $errorstring='ThirdpartyDefaultAccountNotDefined';
- if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined';
- if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined';
- if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined';
- if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined';
- print ''.$langs->trans($errorstring).'';
+ if ($tabtype[$key] == 'unknown')
+ {
+ // We will accept writing, but into a waiting account
+ print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will a waiting account
+ }
+ else
+ {
+ // We will refuse writing
+ $errorstring='UnknownAccountForThirdpartyBlocking';
+ if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined';
+ if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined';
+ if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined';
+ if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined';
+ print ''.$langs->trans($errorstring).'';
+ }
}
else print $accounttoshow;
print "
";
diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql
index 1fc77301528..8e921a9964c 100644
--- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql
+++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql
@@ -20,3 +20,5 @@ ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal);
+
+-- TODO Add a key for unicity
\ No newline at end of file
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index 8cfdbed4728..72fa8d0c191 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -51,7 +51,7 @@ AccountancyAreaDescExpenseReport=STEP %s: Define default accounting accounts for
AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this, use the menu entry %s.
AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this, use the menu entry %s.
AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this, use the menu entry %s.
-AccountancyAreaDescMisc=STEP %s: Define default accounting accounts for miscellaneous transactions. For this, use the menu entry %s.
+AccountancyAreaDescMisc=STEP %s: Define mandatory default account and default accounting accounts for miscellaneous transactions. For this, use the menu entry %s.
AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this, use the menu entry %s.
AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s.
AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s.
@@ -176,6 +176,8 @@ AddCompteFromBK=Add accounting accounts to the group
ReportThirdParty=List third party account
DescThirdPartyReport=Consult here the list of the third party customers and suppliers and their accounting accounts
ListAccounts=List of the accounting accounts
+UnknownAccountForThirdparty=Unknown third party account. We will use %s.
+UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error.
Pcgtype=Class of account
Pcgsubtype=Subclass of account