Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug : Expense reports #7839

Closed
dolibarr95 opened this issue Nov 20, 2017 · 4 comments
Closed

Bug : Expense reports #7839

dolibarr95 opened this issue Nov 20, 2017 · 4 comments

Comments

@dolibarr95
Copy link
Contributor

Environment

  • Version: 6.0.0
  • OS: Linux otos.planethoster.net
  • Web server: LiteSpeed
  • PHP: 5.6.28
  • Database: MySQL or MariaDB 10.1.19-MariaDB
  • URL(s): expensereport/card.php?action=create

Bug

...or misunderstanding from me.
Impossible to create several expense reports for the same date.

Expected and actual behavior

The 10 September a user create a expense reports for the 5 to 8 September 2017. These one is approved.

One month later the same user receive the bill of his telephone subscription. He want's to be refunded because he called from USA to France with his personal phone.

So he create an other expense reports for the 5 to 8 September 2017 but a message displays "You can't create a expense report in this date because you have already create on in this date".

The quick solution is to create at the date of the day (20 November 2017). But at this date he have an other expense for an other project....

Why an user can't create several expense reports at the same date ?

Other case

The user visit several customers at the same day. We want to create several expense reports to dispatch them to several projects (intervention, after sales service, prospecting....).
A user forgot an expense in a old expense reports and wants to be refunded.

Feature request

Can create expense report without regards of the date.

Tks for reading

@dolibarr95
Copy link
Contributor Author

dolibarr95 commented Nov 22, 2017

I don't understand the goal of

    /**
     * periode_existe
     *
     * @param   User    $fuser          User
     * @param   Date    $date_debut     Start date
     * @param   Date    $date_fin       End date
     * @return  int                     <0 if KO, >0 if OK
     */
    function periode_existe($fuser, $date_debut, $date_fin)
    {
        $sql = "SELECT rowid, date_debut, date_fin";
        $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
        $sql.= " WHERE fk_user_author = '{$fuser->id}'";

        dol_syslog(get_class($this)."::periode_existe sql=".$sql);
        $result = $this->db->query($sql);
        if($result)
        {
            $num_lignes = $this->db->num_rows($result); $i = 0;

            if ($num_lignes>0)
            {
                $date_d_form = $date_debut;
                $date_f_form = $date_fin;

                $existe = false;

                while ($i < $num_lignes)
                {
                    $objp = $this->db->fetch_object($result);

                    $date_d_req = $this->db->jdate($objp->date_debut); // 3
                    $date_f_req = $this->db->jdate($objp->date_fin);      // 4

                    if (!($date_f_form < $date_d_req || $date_d_form > $date_f_req)) $existe = true;

                    $i++;
                }

                if($existe) return 1;
                else return 0;
            }
            else
            {
                return 0;
            }
        }
        else
        {
            $this->error=$this->db->lasterror();
            dol_syslog(get_class($this)."::periode_existe  Error ".$this->error, LOG_ERR);
            return -1;
        }
    }

Is it illegal to declare several expense report at the same day ?
Tks for reading.

@aspangaro help !

@dolibarr95
Copy link
Contributor Author

@dolibarr95
Copy link
Contributor Author

dolibarr95 commented Dec 4, 2017

@eldy
Can you please give help?
Why we can't create several expenses reports in one month ?

This has been asked here too:
#5985
Tks.

@dolibarr95
Copy link
Contributor Author

GREAT !!!
8352aee
tks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant