def get(self):
        Guser = users.get_current_user()

        try:

            if Guser:
                strPolicyNum = self.request.get('vstrPolicyNumber')
                strPolicyNum = str(strPolicyNum)
                logging.info("Policy Number on Create Family Handler : " +
                             strPolicyNum)

                strFamilyPlanChoice = self.request.get('vstrFamilyPlanChoice')
                strFamilyPlanChoice = str(strFamilyPlanChoice)
                strFamilyPlanChoice = strFamilyPlanChoice.strip()
                strPaymentDay = self.request.get('vstrPaymentDay')
                strPaymentDay = str(strPaymentDay).strip()
                strClientSignature = self.request.get('vstrClientSignature')
                strClientSignature = strClientSignature.strip()
                strEmployeeSignature = self.request.get(
                    'vstrEmployeeSignature')
                strEmployeeSignature = strEmployeeSignature.strip()

                today = datetime.datetime.today()
                today = today.date()

                thisMonth = today.month
                thisYear = today.year

                if (thisMonth == 12):
                    thisMonth = 1
                    thisYear = today.year + 1
                else:
                    thisMonth = thisMonth + 1

                thisDay = int(strPaymentDay)

                strFirstPremiumDate = datetime.date(year=thisYear,
                                                    month=thisMonth,
                                                    day=thisDay)

                strPremium = 0
                if (strFamilyPlanChoice == "A"):
                    strPremium = 50
                elif (strFamilyPlanChoice == "B"):
                    strPremium = 60
                elif (strFamilyPlanChoice == "C"):
                    strPremium = 85
                elif (strFamilyPlanChoice == "D"):
                    strPremium = 95

                thisPolicy = Policy()
                findRequest = Covers.query(Covers.strCoverType == "Family")
                thisCover = findRequest.fetch()

                if len(thisCover) > 0:
                    thisCover = thisCover[0]
                else:
                    thisCover = Covers()

                findRequest = Policy.query(Policy.strPolicyNum == strPolicyNum)
                thisPolicyList = findRequest.fetch()

                if len(thisPolicyList) > 0:
                    thisPolicy = thisPolicyList[0]

                try:
                    thisPolicy.writeCoverCode(
                        strinput=thisCover.readCoverCode())

                    thisPolicy.writeFirstPremiumDate(
                        strinput=strFirstPremiumDate)

                    thisPolicy.writePaymentCode(
                        strinput=strPolicyNum)  # Payment Transactions Code
                    thisPolicy.writeReference(strinput=Guser.user_id())

                    thisPolicy.writePolicyNum(strinput=strPolicyNum)
                    thisPolicy.writePlanChoice(strinput=strFamilyPlanChoice)
                    thisPolicy.writeTotalPremiums(strinput=strPremium)

                    thisPolicy.writePaymentDay(strinput=strPaymentDay)
                    thisPolicy.writeClientSignature(
                        strinput=strClientSignature)

                    thisPolicy.writeEmployeeSignature(
                        strinput=strEmployeeSignature)

                    thisPolicy.put()
                except:
                    self.response.write("""<strong>ERROR :</strong>""")

                self.response.write("""
                <strong>Policy Created and Saved---Please Add Payment Details if you have not done so yet and then activate the Policy</h3>

                """)
            else:
                self.response.write("""
                 <strong>Policy not Saved</strong>
                 """)
        except:
            self.response.write("""

            <strong>Error Saving Policy</strong>

            """)
    def get(self):

        Guser = users.get_current_user()

        if Guser:
            strPolicyNum = self.request.get('vstrPolicyNumber')
            strPolicyNum = str(strPolicyNum)
            strPolicyNum = strPolicyNum.strip()
            strFamilyPlanChoice = self.request.get('vstrFamilyPlanChoice')
            strFamilyPlanChoice = str(strFamilyPlanChoice)
            strFamilyPlanChoice = strFamilyPlanChoice.strip()
            strExtendedPlanChoice = self.request.get('vstrExtendedPlanChoice')
            strExtendedPlanChoice = strExtendedPlanChoice.strip()

            strPaymentDay = self.request.get('vstrPaymentDay')
            strPaymentDay = str(strPaymentDay).strip()

            strClientSignature = self.request.get('vstrClientSignature')
            strClientSignature = strClientSignature.strip()

            strEmployeeSignature = self.request.get('vstrEmployeeSignature')
            strEmployeeSignature = strEmployeeSignature.strip()

            strPremiumCalculated = self.request.get('vstrTotalPremium')

            today = datetime.datetime.today()
            today = today.date()

            thisMonth = today.month
            thisYear = today.year

            if thisMonth == 12:
                thisMonth = 1
                thisYear = today.year + 1
            else:
                thisMonth = thisMonth + 1

            thisDay = int(strPaymentDay)

            strFirstPremiumDate = datetime.date(year=thisYear,
                                                month=thisMonth,
                                                day=thisDay)

            thisPolicy = Policy()
            findRequest = Covers.query(Covers.strCoverType == "Extended")
            thisCover = findRequest.fetch()

            if len(thisCover) > 0:
                thisCover = thisCover[0]
            else:
                thisCover = Covers()

            findRequest = Policy.query(Policy.strPolicyNum == strPolicyNum)
            thisPolicyList = findRequest.fetch()

            if len(thisPolicyList) > 0:
                thisPolicy = thisPolicyList[0]

            thisPolicy.writeCoverCode(strinput=thisCover.readCoverCode())
            thisPolicy.writeFirstPremiumDate(strinput=strFirstPremiumDate)
            thisPolicy.writePaymentCode(
                strinput=strPolicyNum)  # Payment Transactions Code
            thisPolicy.writeReference(strinput=Guser.user_id())
            thisPolicy.writePolicyNum(strinput=strPolicyNum)
            thisPolicy.writePlanChoice(strinput=strFamilyPlanChoice)
            thisPolicy.writeExtendedPlanChoice(strinput=strExtendedPlanChoice)
            thisPolicy.writeTotalPremiums(strinput=strPremiumCalculated)
            thisPolicy.writePaymentDay(strinput=strPaymentDay)
            thisPolicy.writeClientSignature(strinput=strClientSignature)
            thisPolicy.writeEmployeeSignature(strinput=strEmployeeSignature)
            thisPolicy.put()

            self.response.write("Policy Created and SAVED")
        else:
            self.response.write("Policy not Saved")