/** Create a new tax category. It must have taxes defined. */
 static function createCat($cat)
 {
     if (count($cat->taxes) == 0) {
         return false;
     }
     $pdo = PDOBuilder::getPDO();
     $newTransaction = !$pdo->inTransaction();
     if ($newTransaction) {
         $pdo->beginTransaction();
     }
     $id = md5(time() . rand());
     $stmt = $pdo->prepare('INSERT INTO TAXCATEGORIES (ID, NAME) VALUES ' . '(:id, :name)');
     $stmt->bindParam(':id', $id);
     $stmt->bindParam(':name', $cat->label);
     if (!$stmt->execute()) {
         return false;
     } else {
         foreach ($cat->taxes as $tax) {
             $tax->taxCatId = $id;
             $taxId = TaxesService::createTax($tax);
             if ($taxId === false) {
                 if ($newTransaction) {
                     $pdo->rollback();
                 }
                 return false;
             }
             $tax->id = $taxId;
         }
         if ($newTransaction) {
             $pdo->commit();
         }
         return $id;
     }
 }