a way to proceed may be to add a rule to be applied when creating and when updating the documents, in order to calculate the result given the fields values. This proposal assumes that the content model defines field1, field2 and field3, and total as properties for each document (an invoice with amount and vat given by user, and total automatically calculated)
Or you can register behaviour for your content type.The behaviour calculate value for the total property.Your behaviour should implements NodeServicePolicies.OnUpdatePropertiesPolicy and NodeServicePolicies.OnUpdateNodePolicy and so on.