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

NEW Adds payment terms and procentual discount to the creation of an invoice from time entries in projects #29694

Merged
merged 6 commits into from
May 21, 2024

Conversation

lumb2019
Copy link
Contributor

@lumb2019 lumb2019 commented May 15, 2024

NEW Adds payment terms and procentual discount to the creation of an invoice from time entries in projects

when an invoice is created from time entries in projects, a payment term is only transferred if the customer has a customer-specific payment term. If the customer does not have this, the invoice is created without a payment term.
This code inserts two additional lines in the pre-diagram for invoice creation. These lines show the payment terms and the percentage discount - pre-filled with the customer's values if available otherwise the first payment term and 0% discount.
It is possible to customize the values here. The invoice is then created with the specified payment terms and each invoice line with the specified percentage discount.
If an existing invoice is selected instead of a new one, the line for the payment term is hidden.

Greenshot 2024-05-15 16 37 30

@@ -418,7 +418,8 @@
$tmptimespent = new Task($db);
$tmpproduct = new Product($db);
$fuser = new User($db);

$remiseproject = GETPOST('remiseproject', 'int');
$condidproject = GETPOST('condidproject', 'int');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GETPOSTINT here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thank you

@@ -418,7 +418,8 @@
$tmptimespent = new Task($db);
$tmpproduct = new Product($db);
$fuser = new User($db);

$remiseproject = GETPOST('remiseproject', 'int');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data is a string used by user to enter a numeric value;
So you must use here
$remiseproject = price2num(GETPOST('remiseproject', 'int'));

Copy link
Contributor Author

@lumb2019 lumb2019 May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Is it possible to combine both of your comments and change this to:
$remiseproject = price2num(GETPOSTINT('remiseproject'));?
Or
price2num(GETPOST('remiseproject'));
because it is not only INT

Thanks for your answers. It is my first Request. :-)

Copy link
Member

@eldy eldy May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question !
GETPOSTINT will always return an int, so no need to use price2num.
But an amount or rate is not an int, it is a float with a possible thousand or decimal separator (depending on user language). So you must use GETPOST( , 'alphanohtml') that return a string must some special chars (that is the decimal separator that is different for each country) and then convert it into a float according to the currency format of the user with price2num(). Price2num convert a text entered by a user into a PHP float variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Done. Thanks a lot

@@ -418,7 +418,8 @@
$tmptimespent = new Task($db);
$tmpproduct = new Product($db);
$fuser = new User($db);

$remiseproject = price2num(GETPOST('remiseproject', 'int'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must use GETPOST('remiseprojet', 'alphanohtml') (see my answer to your question)

@eldy eldy added the PR OK to merge (but suggested fix required) PR was analyzed by PR merger and seems ok to be merged as soon as a fix has been published label May 16, 2024
@lumb2019 lumb2019 changed the title NEW Adds payment terms and procedural discount to the creation of an invoice from time entries in projects NEW Adds payment terms and procentual discount to the creation of an invoice from time entries in projects May 16, 2024
@eldy eldy merged commit 60ab439 into Dolibarr:develop May 21, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR OK to merge (but suggested fix required) PR was analyzed by PR merger and seems ok to be merged as soon as a fix has been published
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants