def test_update_note(self):
        attachable = Attachable.all(max_results=1, qb=self.qb_client)[0]

        attachable.Note = "Note updated on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S"))
        attachable.save(qb=self.qb_client)

        query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)
        self.assertEquals(query_attachable.Note, "Note updated on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S")))
    def test_update_note(self):
        attachable = Attachable.all(max_results=1, qb=self.qb_client)[0]

        attachable.Note = "Note updated on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S"))
        attachable.save(qb=self.qb_client)

        query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)
        self.assertEquals(query_attachable.Note, "Note updated on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S")))
    def test_to_ref(self):
        attachable = Attachable()
        attachable.FileName = "test"
        attachable.Id = 12

        ref = attachable.to_ref()

        self.assertEquals(ref.name, "test")
        self.assertEquals(ref.type, "Attachable")
        self.assertEquals(ref.value, 12)
    def test_to_ref(self):
        attachable = Attachable()
        attachable.FileName = "test"
        attachable.Id = 12

        ref = attachable.to_ref()

        self.assertEquals(ref.name, "test")
        self.assertEquals(ref.type, "Attachable")
        self.assertEquals(ref.value, 12)
    def test_create_note(self):
        attachable = Attachable()

        vendor = Vendor.all(max_results=1, qb=self.qb_client)[0]

        attachable_ref = AttachableRef()
        attachable_ref.EntityRef = vendor.to_ref()
        attachable.AttachableRef.append(attachable_ref)

        attachable.Note = "Test note added on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S"))

        attachable.save(qb=self.qb_client)
        query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)

        self.assertEquals(query_attachable.AttachableRef[0].EntityRef.value, vendor.Id)
        self.assertEquals(query_attachable.Note, "Test note added on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S")))
Exemple #6
0
    def test_create_file(self):
        attachable = Attachable()

        vendor = Vendor.all(max_results=1, qb=self.qb_client)[0]

        attachable_ref = AttachableRef()
        attachable_ref.EntityRef = vendor.to_ref()
        attachable.AttachableRef.append(attachable_ref)

        attachable.FileName = 'TestFileName'
        attachable._FilePath = __file__
        attachable.ContentType = 'application/txt'

        attachable.save(qb=self.qb_client)
        query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)

        self.assertEquals(query_attachable.AttachableRef[0].EntityRef.value,
                          vendor.Id)
    def test_create_file(self):
        attachable = Attachable()
        test_file = tempfile.NamedTemporaryFile(suffix=".txt")

        vendor = Vendor.all(max_results=1, qb=self.qb_client)[0]

        attachable_ref = AttachableRef()
        attachable_ref.EntityRef = vendor.to_ref()
        attachable.AttachableRef.append(attachable_ref)

        attachable.FileName = os.path.basename(test_file.name)
        attachable._FilePath = test_file.name
        attachable.ContentType = 'text/plain'

        attachable.save(qb=self.qb_client)
        query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)

        self.assertEquals(query_attachable.AttachableRef[0].EntityRef.value, vendor.Id)
    def test_create_file(self):
        attachable = Attachable()

        vendor = Vendor.all(max_results=1, qb=self.qb_client)[0]

        attachable_ref = AttachableRef()
        attachable_ref.EntityRef = vendor.to_ref()
        attachable.AttachableRef.append(attachable_ref)

        attachable.FileName = 'TestFileName'
        attachable._FilePath = __file__
        attachable.ContentType = 'application/txt'

        attachable.save(qb=self.qb_client)
        query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)

        self.assertEquals(query_attachable.AttachableRef[0].EntityRef.value, vendor.Id)
    def test_create_note(self):
        attachable = Attachable()

        vendor = Vendor.all(max_results=1, qb=self.qb_client)[0]

        attachable_ref = AttachableRef()
        attachable_ref.EntityRef = vendor.to_ref()
        attachable.AttachableRef.append(attachable_ref)

        attachable.Note = "Test note added on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S"))

        attachable.save(qb=self.qb_client)
        query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)

        self.assertEquals(query_attachable.AttachableRef[0].EntityRef.value, vendor.Id)
        self.assertEquals(query_attachable.Note, "Test note added on {}".format(self.time.strftime("%Y-%m-%d %H:%M:%S")))
Exemple #10
0
 def sync_dues(self, request):
     """
     This will sync with quickbooks
     """
     client = get_quickbooks_client()
     chapter_name = self.name
     if "Chapter" in chapter_name:
         chapter_name = chapter_name.replace(" Chapter", "")
     customer = Customer.query(
         select=f"SELECT * FROM Customer WHERE CompanyName LIKE '{chapter_name} chapter%'",
         qb=client,
     )
     if customer:
         customer = customer[0]
     else:
         messages.add_message(
             request,
             messages.ERROR,
             f"Quickbooks Customer matching name: '{chapter_name} Chapter...' not found",
         )
         return
     invoice, linenumber_count = invoice_search("1", customer, client)
     count = self.active_actives().count()
     if not self.candidate_chapter:
         # D1; Service; Semiannual Chapter Dues payable @ $80 each # Minimum per chapter is $1600.
         line = create_line(
             count, linenumber_count, name="D1", minimum=1600, client=client
         )
         l1_min = 250
         if self.house:
             l1_min = 1125
     else:
         # D2; Service; Semiannual Colony Dues
         line = create_line(count, linenumber_count, name="D2", client=client)
         l1_min = 125
     linenumber_count += 1
     invoice.Line.append(line)
     # L1; Service; Health and Safety Assessment - Semesterly
     #   minimum for housed chapters ($1125)
     #   unhoused chapters ($250)
     #   Colony Minimum is $125
     line = create_line(
         count, linenumber_count, name="L1", minimum=l1_min, client=client
     )
     linenumber_count += 1
     invoice.Line.append(line)
     if self.health_safety_surcharge != "none":
         line = create_line(
             line.Amount,
             linenumber_count,
             name=self.health_safety_surcharge,
             client=client,
         )
         invoice.Line.append(line)
     memo = f"Actives: {count}; Surcharge: {self.SURCHARGE.get_value(self.health_safety_surcharge)}"
     memo = memo[0:999]
     invoice.CustomerMemo.value = memo
     invoice.DeliveryInfo = None
     invoice_obj = invoice.save(qb=client)
     attachment_path = self.generate_dues_attachment(file_obj=True)
     attachment = Attachable()
     attachable_ref = AttachableRef()
     attachable_ref.EntityRef = invoice.to_ref()
     attachable_ref.IncludeOnSend = True
     attachment.AttachableRef.append(attachable_ref)
     attachment.FileName = attachment_path.name
     attachment._FilePath = str(attachment_path.absolute())
     attachment.ContentType = "text/csv"
     attachment.save(qb=client)
     if attachment_path.exists():
         attachment_path.unlink()  # Delete the file when we are done
     return invoice_obj.DocNumber
    def test_unicode(self):
        attachable = Attachable()
        attachable.FileName = "test"

        self.assertEquals(str(attachable), "test")
    def test_valid_object_name(self):
        attachable = Attachable()
        client = QuickBooks()
        result = client.isvalid_object_name(attachable.qbo_object_name)

        self.assertTrue(result)
    def test_unicode(self):
        attachable = Attachable()
        attachable.FileName = "test"

        self.assertEquals(str(attachable), "test")