<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>notes_for_saasu.txt</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,6 +2,10 @@
 
 NOT READY! So don't bother pulling unless you want to help out :P
 
+== TODO
+
+No way to pass in &quot;createAsAdjustmentNote&quot; to Invoice.update!
+
 == Note on Patches/Pull Requests
  
 * Fork the project.</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -36,6 +36,17 @@ module SaasuConnect
       @fields
     end
 
+    def self.attributes(*args)
+      @attributes ||= []
+
+      args.each do |a|
+        @attributes &lt;&lt; a
+        field_accessor a
+      end
+
+      @attributes
+    end
+
     def self.field_accessor(*args)
       # Create mutalators for all of the fields. This will also cast the variable if needed
       args.each do |a|
@@ -43,18 +54,21 @@ module SaasuConnect
         when(:integer)
           class_eval &lt;&lt;-END
             def #{a[0]}
+              return nil unless @#{a[0]}
               @#{a[0]}.to_i
             end
           END
         when(:float)
           class_eval &lt;&lt;-END
             def #{a[0]}
+              return nil unless @#{a[0]}
               @#{a[0]}.to_f
             end
           END
         when(:date)
           class_eval &lt;&lt;-END
             def #{a[0]}
+              return nil unless @#{a[0]}
               return @#{a[0]} if @#{a[0]}.is_a?(Date) || @#{a[0]}.to_s == &quot;&quot;
               Date.parse(@#{a[0]})
             end</diff>
      <filename>lib/saasu_connect/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 module SaasuConnect
   class Invoice &lt; Base
     fields [ :uid, :integer ], [ :lastUpdatedUid, :string ], [ :transactionType, :string ], [ :date, :date ], [ :contactUid, :integer ], [ :shipToContactUid, :integer ], [ :folderUid, :integer ], [ :tags, :string ], [ :reference, :string ], [ :summary, :string ], [ :notes, :string ], [ :requiresFollowUp, :boolean ], [ :dueOrExpiryDate, :date ], [ :layout, :string ], [ :status, :string ], [ :invoiceNumber, :string ], [ :purchaseOrderNumber, :string ], [ :invoiceItems, :array ], [ :quickPayment, :quick_payment ], [ :payments, :payment_list ], [ :isSent, :boolean ]
+    attributes [ :emailToContact, :boolean ]
+    
     include Writable
   end
 end</diff>
      <filename>lib/saasu_connect/invoice.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,13 +12,13 @@ module SaasuConnect
       end
     end
 
-    def delete!(uid, options = {})
-      delete({ :uid =&gt; uid }.merge(options))
+    def delete!(options = {})
+      self.class.delete({ :uid =&gt; uid }.merge(options))
     end
   
     def to_xml(&amp;block)
       klass = self.class.to_s.split('::').last
-      if uid != 0
+      if uid &amp;&amp; lastUpdatedUid
         action = XML::Node.new(&quot;update#{klass}&quot;)
         action &lt;&lt; parent = XML::Node.new(SaasuConnect::Rest.downcase_first(klass))
         parent['uid'] = uid.to_s
@@ -28,6 +28,10 @@ module SaasuConnect
         action &lt;&lt; parent = XML::Node.new(SaasuConnect::Rest.downcase_first(klass))
         parent['uid'] = '0'
       end
+        
+      self.class.attributes.each do |a|
+        action[a[0].to_s] = self.send(a[0]).to_s unless self.send(a[0]).nil?
+      end
 
       if block_given?
         yield(parent)
@@ -56,8 +60,13 @@ module SaasuConnect
     def cast_for_xml(field, value)
       value = value.strftime('%Y-%m-%d') if value.is_a?(Date)
      
-      if value.kind_of?(SaasuConnect)
-        value.build_xml
+      if SaasuConnect.constants.include?(klass = value.class.to_s.split('::').last)
+        # The value belongs to the SaasuConnect namespace
+        parent = XML::Node.new(SaasuConnect::Rest.downcase_first(klass))
+        value.build_xml do |n|
+          parent &lt;&lt; n
+        end
+        parent
       elsif value.is_a?(Array)
         node = XML::Node.new(field.to_s)
         value.each do |element|</diff>
      <filename>lib/saasu_connect/writable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -116,7 +116,8 @@ class TestSaasuConnect &lt; Test::Unit::TestCase
     invoice.status = 'I'
     invoice.invoice_number = &quot;&lt;Auto Number&gt;&quot;
     invoice.purchase_order_number = 'PO123456789'
-    
+    invoice.email_to_contact = false
+
     invoice.invoice_items = [
       SaasuConnect::ServiceInvoiceItem.new(
         :description =&gt; 'LINE 1 LINE 1 LINE 1',
@@ -142,13 +143,20 @@ class TestSaasuConnect &lt; Test::Unit::TestCase
       :date_paid =&gt; Date.parse('2001-01-01'),
       :date_cleared =&gt; Date.parse('2001-01-01'),
       :banked_to_account_uid =&gt; 0,
-      :amount =&gt; 0
+      :amount =&gt; 0.0
     )
 
     invoice.is_sent = false
     
     SaasuConnect::Tasks.expects(:post).with(load_xml_mock('update_invoice'), {})
-    invoice.update!(:create_as_adjustment_note =&gt; false)
+    invoice.update!
+  end
+
+  def test_invoice_delete
+    invoice = SaasuConnect::Invoice.new(:uid =&gt; 12345)
+    endpoint = SaasuConnect::Invoice.send(:endpoint, :uid =&gt; 12345)
+    SaasuConnect::Invoice.expects(:http_delete).with(endpoint)
+    invoice.delete!
   end
 
   def test_contact_update</diff>
      <filename>test/test_saasu_connect.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,11 @@
-&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
 &lt;tasks&gt;
   &lt;updateInvoice emailToContact=&quot;false&quot;&gt;
     &lt;invoice uid=&quot;256875&quot; lastUpdatedUid=&quot;AAAAAAAVBCc=&quot;&gt;
       &lt;transactionType&gt;S&lt;/transactionType&gt;
       &lt;date&gt;2005-09-15&lt;/date&gt;
       &lt;contactUid&gt;22738&lt;/contactUid&gt;
-      &lt;shipToContactUid&gt;22738&lt;/contactUid&gt;
+      &lt;shipToContactUid&gt;22738&lt;/shipToContactUid&gt;
       &lt;tags&gt;Online Sales&lt;/tags&gt;
       &lt;summary&gt;Service Sale 2&lt;/summary&gt;
       &lt;requiresFollowUp&gt;false&lt;/requiresFollowUp&gt;
@@ -35,13 +35,12 @@
         &lt;/serviceInvoiceItem&gt;
       &lt;/invoiceItems&gt;
       &lt;quickPayment&gt;
-        &lt;datePaid&gt;0001-01-01&lt;/datePaid&gt;
-        &lt;dateCleared&gt;0001-01-01&lt;/dateCleared&gt;
+        &lt;datePaid&gt;2001-01-01&lt;/datePaid&gt;
+        &lt;dateCleared&gt;2001-01-01&lt;/dateCleared&gt;
         &lt;bankedToAccountUid&gt;0&lt;/bankedToAccountUid&gt;
-        &lt;amount&gt;0&lt;/amount&gt;
+        &lt;amount&gt;0.0&lt;/amount&gt;
       &lt;/quickPayment&gt;
       &lt;isSent&gt;false&lt;/isSent&gt;
     &lt;/invoice&gt;
-    &lt;createAsAdjustmentNote&gt;false&lt;/createAsAdjustmentNote&gt;
   &lt;/updateInvoice&gt;
 &lt;/tasks&gt;</diff>
      <filename>test/xml_mock/update_invoice.xml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0611e7b1486fc68732fdb9832b21dc2bc5b13b14</id>
    </parent>
  </parents>
  <author>
    <name>Myles Eftos</name>
    <email>myles@myles-ubuntu.madpilot.hanger</email>
  </author>
  <url>http://github.com/madpilot/saasu_connect/commit/3a0b54935474ffb9e76199e23857b8303c601469</url>
  <id>3a0b54935474ffb9e76199e23857b8303c601469</id>
  <committed-date>2009-11-09T08:12:13-08:00</committed-date>
  <authored-date>2009-11-09T08:12:13-08:00</authored-date>
  <message>Finished mocked tests for invoices</message>
  <tree>f4eeb532d73ff3ec78019d0d2a35258603313fac</tree>
  <committer>
    <name>Myles Eftos</name>
    <email>myles@myles-ubuntu.madpilot.hanger</email>
  </committer>
</commit>
