Whenever an action shall be commenced for the foreclosure of a mortgage upon which there shall be due any interest or any portion or installment of the principal, and there shall be other portions or installments to become due subsequently, the complaint shall be dismissed upon the defendant bringing into court at any time before entry of judgment the principal and interest due, with costs and disbursements.
SDCL 21-47-8