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 : Add new structure for invoice situation - GIF Situation #23994

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions htdocs/install/mysql/migration/17.0.0-18.0.0.sql
Expand Up @@ -82,4 +82,13 @@ ALTER TABLE llx_supplier_proposal ADD INDEX idx_supplier_proposal_fk_user_valid
ALTER TABLE llx_supplier_proposal ADD INDEX idx_supplier_proposal_fk_projet (fk_projet);
ALTER TABLE llx_supplier_proposal ADD INDEX idx_supplier_proposal_fk_account(fk_account);

ALTER TABLE llx_facturedet ADD COLUMN situation_percent_cumulated real DEFAULT 100 AFTER fk_prev_id;
ALTER TABLE llx_facturedet ADD COLUMN situation_total_ht_cumulated double(24,8) AFTER situation_percent_cumulated;
Copy link
Member

@eldy eldy Feb 22, 2023

Choose a reason for hiding this comment

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

We don't need this information : We already have a chain between each situation invoice. The chain is build with existing fields
situation_cycle_ref and situation_counter

And the "cumulated amount" is the sum of each invoice into the same chain (with situation_counter lower). Adding a field to store is a duplication of info and will generate troubles.

To make usage easy to use in code, we may have to introduce a method
getCumulatedAmountForPreviousSituation() on invoice

Note: Having to go back on other invoice (with a loop) make coding more difficult, but this is the only way to guarantee that data will be correct.

In a future, in a second step, adding a "denormalized field" situation_percent_cumulated may be done in a future for performance purpose but this must be done only once the code without duplication of data is working.

I think the only thing we miss for situation invoice management is in llx_facture, we miss
final_total_ht
final_situation_total_ttc
final_situation_total_vat
final_situation_total_localtax1
final_situation_total_localtax2
To store on the first situation invoice, the final amount we plan to have.

ALTER TABLE llx_facturedet ADD COLUMN situation_total_tva_cumulated double(24,8) AFTER situation_total_ht_cumulated;
ALTER TABLE llx_facturedet ADD COLUMN situation_total_ttc_cumulated double(24,8) AFTER situation_total_tva_cumulated;
ALTER TABLE llx_facturedet ADD COLUMN situation_retained_warranty double(24,8) DEFAULT NULL AFTER situation_total_ttc_cumulated;





8 changes: 7 additions & 1 deletion htdocs/install/mysql/tables/llx_facturedet.sql
Expand Up @@ -65,8 +65,14 @@ create table llx_facturedet

situation_percent real DEFAULT 100, -- % progression of lines invoicing
fk_prev_id integer, -- id of the line in the previous situation
situation_percent_cumulated real DEFAULT 100, -- Invoice situation percent cumulated
Copy link
Member

@eldy eldy Feb 22, 2023

Choose a reason for hiding this comment

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

Same remark than for invoice.
On invoice line we have a field
fk_prev_id
It is the link to the previous invoice line. total cumulated is sum of all lines.
getCumulatedAmountForPreviousSituationLine() on invoice line

I am not sure the field is used today, but this is the one to use to retreive the cumulated amount.

situation_total_ht_cumulated double(24,8), -- Invoice situation total without taxes cumulated
situation_total_tva_cumulated double(24,8), -- Invoice situation total vat cumulated
situation_total_ttc_cumulated double(24,8), -- Invoice situation total with taxes cumulated
situation_retained_warranty double(24,8), -- Invoice situation amount retained warranty not cumulated

fk_user_author integer, -- user making creation

fk_user_author integer, -- user making creation
fk_user_modif integer, -- user making last change

fk_multicurrency integer,
Expand Down