feat: plot sales lifecycle v2 close/terminate, payment sync, cost tracking, TCB v0.6#39
Merged
Merged
Conversation
…fixes Sales Order & Contract: - Add Close Sales Order button with forfeiture JE, credit note, TCB decline - Fix _cancel_unpaid_plot_sales_invoice: throw → return on partial payments - Fix contract termination: SO set to Closed (not Cancelled) to preserve audit trail - Fix credit note update_outstanding_for_self=0 to zero SI outstanding - Fix _persist_payment_sync_state: use db.set_value for draft contracts to prevent validate() resetting total_paid to 0 - Remove advance row zeroing from _sync_contract_after_payment - Add overpayment detection via pe.unallocated_amount on contract - Handle TimestampMismatchError on contract auto-submit Payment Sync: - Move from background job to synchronous execution - Pass pe_name through sync chain for overpayment detection - Add _sync_si_schedule_for_so to sync SI payment schedule rows - Auto-fill cost_center on JE rows when land_acquisition is set Government Share JE: - Auto-post per payment at government_share_percent - Cancel JE when linked Payment Entry is cancelled TCB v0.6: - Wire paymentOption, expireDate, amount fields to Sales Order - Add relatedRef support via related_control_number Land Acquisition Cost Tracking: - Add JE cost sync via hooks.py and _fetch_billed_from_je - Add je_billed_tzs field on LA form with drill-down table - Add Recalculate Plot Costs background job button - Fix cost_per_sqm update for unchanged plots on re-run - Add one-time migration patch for LA cost backfill Reports & UI: - Rebuild Government Payable report for per-payment JE model - Fold Title Closed into Delivered in plot inventory report and chart - Add Sales Invoice before_save hook: clear deferred revenue, restore Balance row - Add Journal Entry before_save hook: enforce LA cost center - Fix SI Balance row restoration: reverse-lookup SO via plot_sales_invoice Schema: - New fields: je_billed_tzs, je_summary_html on Land Acquisition - New fields: last_recalculation_cost/date/log/in_progress on Land Acquisition - New fields: recalculation_section on Land Acquisition - New custom fields: paymentOption, include_expire_date, include_amount on Sales Order (cherry picked from commit 2fe579d)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #38 to
version-15.Summary
This PR completes the core plot sales lifecycle and fixes several accounting
issues discovered during testing.
Sales Order Close & Contract Termination
forfeiture JE, credit note, TCB decline, plot release, PA cancellation
accounting entries are preserved as audit trail
update_outstanding_for_self=0total_paidpersistence —_persist_payment_sync_statenow uses
db.set_valueinstead ofsave()to prevent validate() resetting values_sync_contract_after_paymentPayment Sync
TimestampMismatchError from concurrent syncs and worker dependency
pe.unallocated_amountand shown on Plot Contractcost_centerauto-enforced on all JE rows whereland_acquisitionis setGovernment Share JE
government_share_percentTCB v0.6
paymentOption(Partial/Exact),expireDate,amountwired to Sales Order fieldsLand Acquisition Cost Tracking
acquisition_cost_tzsvia_fetch_billed_from_jeje_billed_tzsfield added to LA form with drill-down table showing each JEfor unsold plots when late PIs arrive; skips delivered/Title Closed plots
cost_per_sqmnow updated on all plots including unchanged-cost onesReports & UI
before_savehook: clears deferred revenue fields, restoresBalance payment schedule row if ERPNext collapsed it
before_savehook: enforces LandMS cost center on LA rows