Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@savanik
Copy link
Contributor

@savanik savanik commented May 18, 2025

Needs heavy review. Would like assistance writing units tests for (at least some) parts of it.

Design document can be found here: https://tinyurl.com/4erz5r9y

savanik added 19 commits May 14, 2025 16:39
…priately and add leased units to your hanger.
…priately and add leased units to your hanger.
…priately and add leased units to your hanger.
…priately and add leased units to your hanger.
@savanik savanik requested a review from a team as a code owner May 18, 2025 03:16
@HammerGS HammerGS requested a review from Copilot May 18, 2025 03:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds leasing support for large craft (dropships and jumpships), integrating lease creation in the UI and handling monthly lease payments in the campaign’s finance system.

  • Introduces Lease and LeaseOrder to represent and serialize leases.
  • Adds UI controls for leasing in UnitViewPanel and the unit selector dialog, plus cancel-lease in the right-click menu.
  • Updates Finances, Accountant, and Quartermaster to charge, record, and cancel lease payments, and adds the campaign option to track leases.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
gui/view/UnitViewPanel.java Show monthly lease cost when a unit has an active lease
gui/dialog/MekHQUnitSelectorDialog.java Add Lease/LeaseGM buttons and handler
gui/campaignOptions/contents/FinancesTab.java Add “Track Leases” checkbox in Finance options tab
gui/adapter/UnitTableMouseAdapter.java Add “Cancel Lease” popup-menu command
campaign/finances/Lease.java & LeaseOrder.java Implement lease cost calculations and XML I/O
campaign/Quartermaster.java Provide leaseUnit and cancelUnitLease operations
campaign/finances/Finances.java & Accountant.java Charge monthly lease payments during finance cycle
campaign/CampaignOptions.java Add trackLeases option with XML persistence
resources/*.properties Add localization strings for lease transactions
Comments suppressed due to low confidence (1)

MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java:113

  • If selectedUnit is null, this call can NPE. It would be safer to check selectedUnit before dereferencing or use the already-checked getSelectedEntity().
Entity entity = selectedUnit.getEntity();

@codecov
Copy link

codecov bot commented May 18, 2025

Codecov Report

❌ Patch coverage is 21.71582% with 292 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@4bfdf5b). Learn more about missing BASE report.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/campaign/unit/UnitOrder.java 0.00% 49 Missing ⚠️
.../src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java 0.00% 45 Missing ⚠️
MekHQ/src/mekhq/campaign/finances/LeaseOrder.java 0.00% 32 Missing ⚠️
MekHQ/src/mekhq/campaign/finances/Lease.java 50.90% 23 Missing and 4 partials ⚠️
MekHQ/src/mekhq/campaign/Quartermaster.java 63.88% 25 Missing and 1 partial ⚠️
MekHQ/src/mekhq/campaign/market/ShoppingList.java 0.00% 21 Missing ⚠️
MekHQ/src/mekhq/campaign/Campaign.java 5.00% 18 Missing and 1 partial ⚠️
...Q/src/mekhq/gui/adapter/UnitTableMouseAdapter.java 0.00% 16 Missing ⚠️
MekHQ/src/mekhq/campaign/unit/Unit.java 23.07% 10 Missing ⚠️
MekHQ/src/mekhq/campaign/finances/Finances.java 0.00% 9 Missing ⚠️
... and 6 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7043   +/-   ##
=======================================
  Coverage        ?   12.49%           
  Complexity      ?     7390           
=======================================
  Files           ?     1140           
  Lines           ?   146648           
  Branches        ?    22489           
=======================================
  Hits            ?    18328           
  Misses          ?   126435           
  Partials        ?     1885           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@savanik savanik marked this pull request as draft May 18, 2025 04:14
Copy link
Collaborator

@Scoppio Scoppio left a comment

Choose a reason for hiding this comment

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

I have not finished reviewing, but there are lots of stuff to fix, others to change, and alot of redundancy you add.

Copy link
Collaborator

@IllianiBird IllianiBird left a comment

Choose a reason for hiding this comment

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

So I know this is still WIP but I thought I'd take a nosey around. I'm going to leave quite a bit of feedback, some minor some not so minor. I am fully onboard with this feature, but we need to be making sure we're doing it right.

savanik added 7 commits May 19, 2025 23:15
…rder as well, XML cleanup in ShoppingList, and marking nullable functions as nullable
# Conflicts:
#	MekHQ/src/mekhq/campaign/CampaignOptions.java
#	MekHQ/src/mekhq/campaign/finances/Finances.java
#	MekHQ/src/mekhq/campaign/unit/Unit.java
#	MekHQ/src/mekhq/campaign/unit/UnitOrder.java
#	MekHQ/src/mekhq/gui/adapter/ProcurementTableMouseAdapter.java
#	MekHQ/src/mekhq/gui/adapter/UnitTableMouseAdapter.java
#	MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
#	MekHQ/src/mekhq/gui/view/UnitViewPanel.java
@savanik savanik marked this pull request as ready for review June 1, 2025 00:27
Comment on lines 69 to 85
//Act
Money testCost = mockUnit.getUnitLease().getLeaseCost();

//Assert
assertEquals(Money.of(3000), testCost);
}

@Test
void getLeaseCostNow_WhenFullMonthCost_CalculatesBaseLeaseCostCorrectly() {
//Arrange
LocalDate testDate = LocalDate.parse("3025-05-01");

//Act
Money testCost = mockUnit.getUnitLease().getLeaseCostNow(testDate);

//Assert
assertEquals(Money.of(3000), testCost);
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove the comments

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the comments are fine. They're helpful in making tests clearer and also encouraging developers to write well constructed tests.

@IllianiBird
Copy link
Collaborator

This has been in development for a while and I don't want it to die on the vine. What still needs to be done to bring it across the finish line? :)

@HammerGS HammerGS marked this pull request as draft October 12, 2025 17:35
@HammerGS HammerGS added Unofficial Anything that is not an official BT rule, outside of AtB Draft Work in Progress labels Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Draft Work in Progress Unofficial Anything that is not an official BT rule, outside of AtB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants