Designing a battery capacity monitoring system for AGM lead acid battery
Here are some typical discharge curves for AGM lead-acid, in this a case a 12V 60AH battery (40Ah should be similar but with all currents multiplied by 40/60):-



Note that the time scale on this graph is logarithmic so the curves are a bit deceptive. However you can see that as current increases voltage reduces, and capacity is reduced at high current (eg. at 60A it lasts 30 minutes which is only 30Ah). So you can use voltage to estimate remaining capacity, but to get reasonable accuracy the effect of current draw must be factored into your calculations.


  how can I continue using the voltage-capacity plot method while taking
  into account the changes caused by aging?


Capacity may be reduced due to shedding of active material from the plates, electrolyte loss, sulphation, impurities or contamination etc. Some of these things also increase internal resistance, causing greater voltage drop at higher current. 

Capacity loss may occur suddenly and cannot be reliably predicted, so to get the actual capacity you need to measure it. The obvious method is to fully charge the battery and then discharge it until empty. Alternatively you could just discharge until you reach the minimum working voltage in your system at normal current draw, as this is the effective capacity in your application. If only done occasionally this calibration cycle should not significantly affect lifespan.     

You can measure internal resistance by applying or waiting for a step change in current, then calculating resistance from the voltage difference. This figure can then be used in the calculations you do to estimate remaining capacity.