Subversion Repositories SmartDukaan

Rev

Rev 17013 | Rev 17234 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17013 Rev 17179
Line 165... Line 165...
165
    
165
    
166
    def getCashbackAmount(self, productCode, amount):
166
    def getCashbackAmount(self, productCode, amount):
167
        alagvar = CASHBACK_URL % (productCode,self.store_id)
167
        alagvar = CASHBACK_URL % (productCode,self.store_id)
168
        filehandle = urllib2.Request(alagvar,headers=headers)
168
        filehandle = urllib2.Request(alagvar,headers=headers)
169
        x= urllib2.urlopen(filehandle)
169
        x= urllib2.urlopen(filehandle)
170
        rmap = json.loads(str(x.read()))
170
        cashBack = json.loads(str(x.read()))
171
        if len(rmap)==0:
171
        if len(cashBack)==0:
172
            return (0,0)
172
            return (0,0)
173
        else:
173
        else:
-
 
174
            maxCashBack = cashBack.get('maxCashBack') 
-
 
175
            if maxCashBack:
-
 
176
                if cashBack.get('cash_back_type') ==1 and (float(cashBack.get('cash_back'))*amount)/100 > maxCashBack:
-
 
177
                    cashBack['cash_back'] = cashBack['maxCashBack']
-
 
178
                    return (cashBack['cash_back'], 0)
-
 
179
                elif cashBack.get('cash_back_type') ==2 and cashBack.get('cash_back') > cashBack.get('maxCashBack'):
-
 
180
                    cashBack['cash_back'] = cashBack['maxCashBack']
-
 
181
                    return (cashBack['cash_back'], 0)
-
 
182
                else:
-
 
183
                    pass
174
            if rmap['cash_back_description'] == 'PERCENTAGE':
184
            if cashBack['cash_back_description'] == 'PERCENTAGE':
175
                return (math.floor((amount * rmap['cash_back'])/100), rmap['cash_back'])
185
                return (math.floor((amount * cashBack['cash_back'])/100), cashBack['cash_back'])
176
            else:
186
            else:
177
                return (rmap['cash_back'], 0)
187
                return (cashBack['cash_back'], 0)
178
            
188
            
179
    
189
    
180
    '''
190
    '''
181
    Parses the order for specific store
191
    Parses the order for specific store
182
    
192