Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 2665)
+++ pykota/trunk/pykota/storages/sql.py (revision 2676)
@@ -592,11 +592,11 @@
         self.doModify("UPDATE userpquota SET pagecounter=%s, lifepagecounter=%s, warncount=0, datelimit=NULL WHERE id=%s" % (self.doQuote(newpagecounter), self.doQuote(newlifepagecounter), self.doQuote(userpquota.ident)))
        
-    def writeBillingCodeDescription(self, code) :
-        """Sets the new description for a billing code."""
-        self.doModify("UPDATE billingcodes SET description=%s WHERE id=%s" % (self.doQuote(self.userCharsetToDatabase(code.Description or "")), self.doQuote(code.ident)))
-       
-    def setBillingCodeValues(self, code, newpagecounter, newbalance) :    
-        """Sets the new page counter and balance for a billing code."""
-        self.doModify("UPDATE billingcodes SET balance=%s, pagecounter=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(newpagecounter), self.doQuote(code.ident)))
+    def saveBillingCode(self, code) :    
+        """Saves the billing code to the database."""
+        self.doModify("UPDATE billingcodes SET balance=%s, pagecounter=%s, description=%s WHERE id=%s" \
+                            % (self.doQuote(code.Balance), \
+                               self.doQuote(code.PageCounter), \
+                               self.doQuote(self.userCharsetToDatabase(code.Description)), \
+                               self.doQuote(code.ident)))
        
     def consumeBillingCode(self, code, pagecounter, balance) :
Index: pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- pykota/trunk/pykota/storages/ldapstorage.py (revision 2657)
+++ pykota/trunk/pykota/storages/ldapstorage.py (revision 2676)
@@ -1615,11 +1615,12 @@
         return self.getBillingCode(label)
         
-    def writeBillingCodeDescription(self, code) :
+    def saveBillingCode(self, code) :
         """Sets the new description for a billing code."""
         fields = {
                    "description" : self.userCharsetToDatabase(code.Description or ""), 
-                 }
-        if fields["description"] :
-            self.doModify(code.ident, fields)
+                   "pykotaPageCounter" : str(code.PageCounter),
+                   "pykotaBalance" : str(code.Balance),
+                 }
+        self.doModify(code.ident, fields)
             
     def getMatchingBillingCodes(self, billingcodepattern) :
@@ -1645,12 +1646,4 @@
         return codes        
         
-    def setBillingCodeValues(self, code, newpagecounter, newbalance) :
-        """Sets the new page counter and balance for a billing code."""
-        fields = {
-                   "pykotaPageCounter" : str(newpagecounter),
-                   "pykotaBalance" : str(newbalance),
-                 }  
-        return self.doModify(code.ident, fields)         
-       
     def consumeBillingCode(self, code, pagecounter, balance) :
         """Consumes from a billing code."""
Index: pykota/trunk/pykota/storage.py
===================================================================
--- pykota/trunk/pykota/storage.py (revision 2665)
+++ pykota/trunk/pykota/storage.py (revision 2676)
@@ -40,5 +40,6 @@
         self.parent = parent
         self.ident = None
-        self.Exists = 0
+        self.isDirty = False
+        self.Exists = False
         
 class StorageUser(StorageObject) :        
@@ -452,11 +453,15 @@
         self.parent.deleteBillingCode(self)
         self.parent.flushEntry("BILLINGCODES", self.BillingCode)
-        self.Exists = 0
+        self.Exists = False
+        self.isDirty = False
         
     def reset(self, balance=0.0, pagecounter=0) :    
         """Resets the pagecounter and balance for this billing code."""
-        self.parent.setBillingCodeValues(self, pagecounter, balance)
-        self.Balance = balance
-        self.PageCounter = pagecounter
+        if self.Balance != balance :
+            self.Balance = balance
+            self.isDirty = True
+        if self.PageCounter != pagecounter :
+            self.PageCounter = pagecounter
+            self.isDirty = True
         
     def setDescription(self, description=None) :
@@ -466,5 +471,11 @@
         else :    
             self.Description = str(description)
-        self.parent.writeBillingCodeDescription(self)
+        self.isDirty = True    
+        
+    def save(self) :    
+        """Saves the billing code to disk in a single operation."""
+        if self.isDirty :
+            self.parent.saveBillingCode(self)
+            self.isDirty = False
         
     def consume(self, pages, price) :
