crater-invoice / crater

Open Source Invoicing Solution for Individuals & Businesses
https://craterapp.com
GNU Affero General Public License v3.0
7.82k stars 1.56k forks source link

IRPF #1023

Open djchoyr opened 2 years ago

djchoyr commented 2 years ago

Hello. The first thing is to say thank you for the app.

It would be very good to be able to add and configure a tax that does not add up to the base. In Spain there is a tax called IRPF. This type of tax is not included in crater. For small businesses or businesses, an option that includes this fee is important. It is mandatory for both this tax and IVA to appear on invoices.

I am attaching an image that clarifies this type of rate.

image

Thank you in advance. Greeting

aluvare commented 2 years ago

@djchoyr, I've a workaround for that.

You can create a tax and after that go to the mysql and change the tax to a negative tax:

> select * from tax_types;
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
| id | name           | percent | compound_tax | collective_tax | description | company_id | created_at          | updated_at          | type    |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
|  1 | IVA            |   21.00 |            0 |              0 | IVA         |          1 | 2022-10-03 09:56:00 | 2022-10-03 09:56:00 | GENERAL |
|  2 | Retencion IRPF |   15.00 |            0 |              0 | NULL        |          1 | 2022-10-03 09:56:31 | 2022-10-03 10:00:49 | GENERAL |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
2 rows in set (0.000 sec)

SQL:

> update tax_types set percent = "-15.00" where id = 2;

Result:

> select * from tax_types;
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
| id | name           | percent | compound_tax | collective_tax | description | company_id | created_at          | updated_at          | type    |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
|  1 | IVA            |   21.00 |            0 |              0 | IVA         |          1 | 2022-10-03 09:56:00 | 2022-10-03 09:56:00 | GENERAL |
|  2 | Retencion IRPF |  -15.00 |            0 |              0 | NULL        |          1 | 2022-10-03 09:56:31 | 2022-10-03 10:00:49 | GENERAL |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
2 rows in set (0.001 sec)
djchoyr commented 2 years ago

@djchoyr, I've a workaround for that.

You can create a tax and after that go to the mysql and change the tax to a negative tax:

> select * from tax_types;
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
| id | name           | percent | compound_tax | collective_tax | description | company_id | created_at          | updated_at          | type    |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
|  1 | IVA            |   21.00 |            0 |              0 | IVA         |          1 | 2022-10-03 09:56:00 | 2022-10-03 09:56:00 | GENERAL |
|  2 | Retencion IRPF |   15.00 |            0 |              0 | NULL        |          1 | 2022-10-03 09:56:31 | 2022-10-03 10:00:49 | GENERAL |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
2 rows in set (0.000 sec)

SQL:

> update tax_types set percent = "-15.00" where id = 2;

Result:

> select * from tax_types;
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
| id | name           | percent | compound_tax | collective_tax | description | company_id | created_at          | updated_at          | type    |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
|  1 | IVA            |   21.00 |            0 |              0 | IVA         |          1 | 2022-10-03 09:56:00 | 2022-10-03 09:56:00 | GENERAL |
|  2 | Retencion IRPF |  -15.00 |            0 |              0 | NULL        |          1 | 2022-10-03 09:56:31 | 2022-10-03 10:00:49 | GENERAL |
+----+----------------+---------+--------------+----------------+-------------+------------+---------------------+---------------------+---------+
2 rows in set (0.001 sec)

I will try to access the database to change the tax rate. I don't know very well how to do it, but I will look for some information and try to solve the problem.

I tried to enter a negative value in the menu, but it is not possible.

Thanks a lot

djchoyr commented 2 years ago

I have tried to search for information but I can't find how to enter the database to be able to edit an item.

I have a crater installed in Docker. The database is postgres:14

I access the database container console. But I don't know the commands to be able to access it.

@aluvare You can help me with this? 😉

ghost commented 2 years ago

You can create a tax and after that go to the mysql and change the tax to a negative tax:

I did that and it´s working but in the PDF file view the tax is 0.

image

Any ideas, @aluvare ?

aluvare commented 2 years ago

You can create a tax and after that go to the mysql and change the tax to a negative tax:

I did that and it´s working but in the PDF file view the tax is 0.

image

Any ideas, @aluvare ?

I think that is because of the cast of the Tax value (integer)… https://github.com/crater-invoice/crater/blob/946c7efab44ee4840e176234246d2e8b9ad4b18e/app/Models/Invoice.php i think changing here the cast from integer to float need to be enough, but i need to do some tests.

aluvare commented 2 years ago

I have tried to search for information but I can't find how to enter the database to be able to edit an item.

I have a crater installed in Docker. The database is postgres:14

I access the database container console. But I don't know the commands to be able to access it.

@aluvare You can help me with this? 😉

Maybe this link can help you: https://dev.to/shree_j/how-to-install-and-run-psql-using-docker-41j2

ghost commented 2 years ago

i think changing here the cast from integer to float need to be enough, but i need to do some tests.

I changed that on my installation and it didnt solve it. @aluvare

djchoyr commented 2 years ago

I have tried to search for information but I can't find how to enter the database to be able to edit an item. I have a crater installed in Docker. The database is postgres:14 I access the database container console. But I don't know the commands to be able to access it. @aluvare You can help me with this? 😉

Maybe this link can help you: https://dev.to/shree_j/how-to-install-and-run-psql-using-docker-41j2

Thank you very much. I will carry out tests. Let's see if I'm lucky 🙏

acobrerosf commented 1 year ago

i think changing here the cast from integer to float need to be enough, but i need to do some tests.

I changed that on my installation and it didnt solve it. @aluvare

I am having the same issue with the PDF, did you manage to fix it?

acobrerosf commented 1 year ago

Never mind, fixed the problem. So basically in order to be able to use IRPF (negative taxes), you have to do two things.

1- Create a tax type in the admin with a positive value and then go to the database and change it to negative manually.

2- Modify the structure of the taxes table and remove the "unsigned" attribute from the amount field. When you add a new invoice (or estimate, payment...) a new row is added to the "taxes" table. If the amount has a negative value, since the field is marked as unsigned (it only accepts positive numbers), the value is saved as 0, therefore the PDF shows 0 in the amount of the taxes.