calculate reference number total automatically