In the case of BigLittle Micro Finance, when a borrower makes a loan payment, the status field for that payment needs to be updated to reflect payments being received. However, given our example document structure, we also need to update the amountDue and amountPaid fields in the user document. This is referred to as a secondary update.Â
This is a step easily overlooked when developing financial applications. What can often happen is that the total amount paid as recorded in the users collection could fall out of sync with the sum of the amount field values in the loans collection. Accordingly, it's not a bad idea when performing secondary updates to either provide an immediate double-check and note any discrepancies in a log, or alternatively, provide management with a discrepancies report allowing administrators to perform the double-check themselves. Let's first look at the process of accepting a loan payment in our sample scenario.
...