Bah I'm still learning and there's probably an easier way but lack of sleep = brain is goo so how about this:
Create a mod package that does the following:
Define a new faction called "CSEW" (or whatever, just thought 'Corvus Stellar Engineering Works' sounded cool) that has friendly standing to the player.faction
Define a hull and variant called "CSEW-0" using only a single pixel sprite
Define an inventory itemtype called "Invoice - Hull Refit - Hulk -> Hulk MK2 - Pending" with a value of what you want to pay
Define an inventory itemtype called "Invoice - Hull Refit - Hulk -> Hulk MK2 - In Progress" with a value of 0
Then using sectorgen:
Spawn an orbital station orbiting the star (or wherever) called "CSEW Admin Office" owned by the CSEW faction
Spawn another station called "CSEW Mooring Depot" that orbits nearby that is like the abandoned storage facility
Configure a resupply fleet using just CSEW-0 whose resupply call checks the Admin office has the 'Pending' invoice available and if not will restock 1 unit.
_______________________________________________
Disclaimer: This may not make any sense at all when I
next wake up even to me but here goes!
_______________________________________________
Verrius' Fleet control mod has the relevant code and I'm sure he would be able to explain what I'm going to describe here:
FCM Polls the contents of the storage hanger and sorts out appropriate addition/removal of items based on those results
IF there is a call that checks the Mooring depot for a 'Pending' invoice and obviously the ship to be upgraded (in this case the hulk) and if both are present will remove them both and add the upgraded hull type to stock ready to be picked up.
PLEASE tell me that made sense?