b-b-a / bba-power

1 stars 0 forks source link

Prevent creation of duplicate meters (MPAN13) #161

Closed paulmallett closed 12 years ago

paulmallett commented 12 years ago

Users should be prevented from creating a meter with the same MPAN13. They should be presented with a message that says something like "A meter with this MPAN already exists. Please edit the existing meter".

We do need to start generating 'soft' and 'hard' errors and have a method of handling them.

shaunfreeman commented 12 years ago

I think a hard error would be better for this. ie user cannot create a new meter if it exits already. could have the error message with a link to the meter that already exits on the system

ghost commented 12 years ago

error text is "A meter with "1234" MPAN already exists, please edit the existing meter." Need to change this - MPAN is only for Electric and editting the existing meter may not be appropriate. Suggest "This meter cannot be added as the meter Main No. already exists." (Note: We may need to adjust the comparison check to include numberTop - please see email discussion first) (Note-update: numberMain is unique so "as you were"). Also - Same hard check on Serial Number - "This meter cannot be added as the meter Serial No. already exists."

ghost commented 12 years ago

Summary and update (adding Water changes the rules a bit): The meter_numberMain is NO LONGER a required field. Hard error on duplicate meter_numberMain Hard error on duplicate meter_numberSerial Messages change: "This meter cannot be added as the meter Main No. already exists." (and Serial No.) Zero is not allowed in Top, Main, Serial Soft error if: Elec & Gas - meter_numberMain is empty; Water - meter_numberSerial is empty. e.g. "A Main No. has not been entered. Are you sure you want to continue?" Hard error if: Water - meter_numberMain & Top not empty; Gas - meter_numberTop not empty. "This meter cannot be added as a Main No. has been entered. (Main No. is not allowed for Water meters.)"

paulmallett commented 12 years ago

Just some notes of caution:

meter_numberMain must be allowed to be empty/blank, or entered as 0000000000000 with no duplication check, as we often start in a situtaion where we don't know meter_numberMain.

Stopping meter_numberMain being a required field is my preference.

shaunfreeman commented 12 years ago

I'm allowing for electric meters:

electric meters have a check digit and so can be validated as to a real meter number using this digit. the check digit is the last digit in the mpan number and validates the previous 12 digits, the algorithm is worked out thus:

  1. Multiply the first digit by 3
  2. Multiply the second digit by the next prime number (5)
  3. Repeat this for each digit (missing 11 out on the list of prime numbers for the purposes of this algorithm.)
  4. Add up all these numbers.
  5. The check digit is the sum modulo 11 modulo 10.
ghost commented 12 years ago

We don't need the 0 thank you (I will remove them all from the DB). Just empty/blank and a real number. Having that check digit checked will be a real help.

Eddie

ghost commented 12 years ago

Excelent. Re: "Soft error if: Elec & Gas - meter_numberMain is empty; Water - meter_numberSerial is empty." Is it easy to split this check so the Elec & Gas only checks meter_numberMain and Water on;y check meter_numberSerial? (and have different messages?)

shaunfreeman commented 12 years ago

done a quick fix, hope it's what you are looking for.

ghost commented 12 years ago

Thats it - Thanks. Small problem with Gas - it always says a MainNo is not entered even if it is!!