| 1368 | def getBillingCodeFromBackend(self, label) : |
| 1369 | """Extracts billing code information given its label : returns first matching billing code.""" |
| 1370 | code = StorageBillingCode(self, label) |
| 1371 | result = self.doSearch("(&(objectClass=pykotaBilling)(pykotaBillingCode=%s))" % label), ["pykotaBillingCode", "pykotaBalance", "pykotaPageCounter", "description"], base=self.info["billingcodebase"]) |
| 1372 | if result : |
| 1373 | fields = result[0][1] # take only first matching code, ignore the rest |
| 1374 | code.ident = result[0][0] |
| 1375 | code.BillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [self.userCharsetToDatabase(label)])[0]) |
| 1376 | code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) |
| 1377 | code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) |
| 1378 | code.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) |
| 1379 | code.Exists = 1 |
| 1380 | return code |