Fix send into ledger for expense report. Show accounted status.

This commit is contained in:
Laurent Destailleur 2018-01-22 03:07:11 +01:00
parent 3c3e02dbea
commit 273e88a599
10 changed files with 81 additions and 12 deletions

View File

@ -200,7 +200,7 @@ $sql.= " aa.rowid as aarowid";
$sql.= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
$sql.= " WHERE er.fk_statut > 4 AND erd.fk_code_ventilation <= 0";
// Add search filter like
if (strlen(trim($search_expensereport))) {

View File

@ -554,14 +554,15 @@ if (empty($action) || $action == 'view') {
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche form input[name=\"action\"]").val("exportcsv");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");
}
function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
console.log("click on writebookkeeping");
$("div.fiche form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");
}
</script>';

View File

@ -709,6 +709,7 @@ if (empty($action) || $action == 'view') {
$("div.fiche form input[name=\"action\"]").val("");
}
function writebookkeeping() {
console.log("click on writebookkeeping");
$("div.fiche form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");

View File

@ -643,6 +643,7 @@ if (empty($action) || $action == 'view') {
$("div.fiche form input[name=\"action\"]").val("");
}
function writebookkeeping() {
console.log("click on writebookkeeping");
$("div.fiche form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche form input[type=\"submit\"]").click();
$("div.fiche form input[name=\"action\"]").val("");

View File

@ -338,7 +338,7 @@ abstract class CommonInvoice extends CommonObject
*
* @return int <0 if KO, 0=no, 1=yes
*/
function getVentilExportCompta()
public function getVentilExportCompta()
{
$alreadydispatched = 0;

View File

@ -1494,7 +1494,20 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
$morehtmlstatus.=$tmptxt;
}
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
// Add if object was dispatched "into accountancy"
if (! empty($conf->accounting->enabled) && in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'expensereport')))
{
if (method_exists($object, 'getVentilExportCompta'))
{
$accounted = $object->getVentilExportCompta();
$langs->load("accountancy");
$morehtmlstatus.='</div><div class="statusref statusrefbis">'.($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted"));
}
}
// Add alias for thirdparty
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>';
// Add label
if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task')

View File

@ -2326,6 +2326,41 @@ class ExpenseReport extends CommonObject
else
return ($this->datevalid?$this->datevalid:$this->date_valid) < ($now - $conf->expensereport->payment->warning_delay);
}
/**
* Return if an expensereport was dispatched into bookkeeping
*
* @return int <0 if KO, 0=no, 1=yes
*/
public function getVentilExportCompta()
{
$alreadydispatched = 0;
$type = 'expense_report';
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$alreadydispatched = $obj->nb;
}
}
else
{
$this->error = $this->db->lasterror();
return -1;
}
if ($alreadydispatched)
{
return 1;
}
return 0;
}
}

View File

@ -25,8 +25,8 @@ Chartofaccounts=Chart of accounts
CurrentDedicatedAccountingAccount=Current dedicated account
AssignDedicatedAccountingAccount=New account to assign
InvoiceLabel=Invoice label
OverviewOfAmountOfLinesNotBound=Overview of amount of lines not bound to accounting account
OverviewOfAmountOfLinesBound=Overview of amount of lines already bound to accounting account
OverviewOfAmountOfLinesNotBound=Overview of amount of lines not bound to an accounting account
OverviewOfAmountOfLinesBound=Overview of amount of lines already bound to an accounting account
OtherInfo=Other information
DeleteCptCategory=Remove accounting account from group
ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account from the accounting account group ?
@ -173,7 +173,7 @@ DelBookKeeping=Delete record of the Ledger
FinanceJournal=Finance journal
ExpenseReportsJournal=Expense reports journal
DescFinanceJournal=Finance journal including all the types of payments by bank account
DescJournalOnlyBindedVisible=This is a view of record that are bound to accounting account and can be recorded into the Ledger.
DescJournalOnlyBindedVisible=This is a view of record that are bound to an accounting account and can be recorded into the Ledger.
VATAccountNotDefined=Account for VAT not defined
ThirdpartyAccountNotDefined=Account for third party not defined
ProductAccountNotDefined=Account for product not defined
@ -224,6 +224,8 @@ GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be disp
NoNewRecordSaved=No more record to journalize
ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account
ChangeBinding=Change the binding
Accounted=Accounted in ledger
NotYetAccounted=Not yet accounted in ledger
## Admin
ApplyMassCategories=Apply mass categories

View File

@ -1025,6 +1025,9 @@ select.selectarrowonleft option {
div.statusref img {
padding-right: 3px !important;
}
div.statusrefbis {
padding-right: 3px !important;
}
input.buttonpayment {
min-width: 300px;
@ -1332,6 +1335,11 @@ div.statusref img {
padding-right: 9px;
vertical-align: text-bottom;
}
div.statusrefbis {
padding-left: 8px;
padding-right: 9px;
vertical-align: text-bottom;
}
img.photoref, div.photoref {
border: 1px solid #CCC;
-webkit-box-shadow: 2px 2px 4px #ccc;

View File

@ -1015,6 +1015,9 @@ select.selectarrowonleft option {
div.statusref img {
padding-right: 3px !important;
}
div.statusrefbis {
padding-right: 3px !important;
}
input.buttonpayment {
min-width: 300px;
@ -1345,6 +1348,11 @@ div.statusref img {
padding-right: 9px;
vertical-align: text-bottom;
}
div.statusrefbis {
padding-left: 8px;
padding-right: 9px;
vertical-align: text-bottom;
}
img.photoref, div.photoref {
border: 1px solid #CCC;
-webkit-box-shadow: 3px 3px 4px #DDD;