Beispiel #1
0
class ContactList(BaseModel):
    """ List of Contact Items """

    __model__ = 'ContactList'
    template_name = 'saasu_client/contactlist_model.xml'

    items = CollectionField(
        ContactListItem,
        xpath='/contactListResponse/contactList/contactListItem')

    isActive = xml_models.BoolField(
        xpath="/contactListResponse/contactList/contactListItem/isActive",
        default=True)

    finders = {
        (isActive, ): DEFAULT_GET_URL % __model__ + "&isActive=%s",
    }

    def __len__(self):
        return len(self.items)

    def __iter__(self):
        return self.items.__iter__()
Beispiel #2
0
class ServiceInvoice(BaseModel):
    """ Service Invoice Entity """

    __model__ = 'Invoice'
    template_name = 'saasu_client/serviceinvoice_model.xml'

    uid = xml_models.IntField(xpath="/invoiceResponse/invoice/@uid", default=0) 
    lastUpdatedUid = xml_models.CharField(xpath="/invoiceResponse/invoice/@lastUpdatedUid")
    # Either S for Sale or P for Purchase.
    transactionType = xml_models.CharField(xpath="/invoiceResponse/invoice/transactionType", default="S")
    # The invoice date.
    date = xml_models.DateField(xpath="/invoiceResponse/invoice/date", date_format="%Y-%m-%d") 
    # The contact for this invoice. 0 means no contact.
    contactUid = xml_models.IntField(xpath="/invoiceResponse/invoice/contactUid", default=0) 
    # The shipping contact for this invoice. Not specifying or 0 means no shipping contact.
    shipToContactUid = xml_models.IntField(xpath="/invoiceResponse/invoice/shipToContactUid", default=0) 
    # Separate multiple tags by comma. Max length for each tag is 35 characters.
    tags = xml_models.CharField(xpath="/invoiceResponse/invoice/tags", default='')
    # Don’t set this value in invoice because this field is not accessible from the UI.
    reference = xml_models.CharField(xpath="/invoiceResponse/invoice/reference", default='')
    # Brief summary of the invoice
    summary = xml_models.CharField(xpath="/invoiceResponse/invoice/summary", default='')
    # The currency of the particular invoice transaction.
    ccy = xml_models.CharField(xpath="/invoiceResponse/invoice/ccy", default='')
    # Indicates whether the FX rate for the invoice was set automatically.
    autoPopulateFxRate = xml_models.BoolField(xpath="/invoiceResponse/invoice/autoPopulateFxRate", default=False) 

    # The Foreign Currency(FC) to Base Currency(BC) FX Rate. If you are setting the FX rate manually, and only have the BC to FC FX
    # rate, then you should calculate the fcToBcFxRate for posting the transaction. For an example, if your base currency is AUD and 1
    # AUD = 0.89 USD, get the inverse by 1/0.89. So your fcToBcFxRate = 1.1235.
    fcToBcFxRate = xml_models.FloatField(xpath="/invoiceResponse/invoice/fcToBcFxRate", default=0) 
    notes = xml_models.CharField(xpath="/invoiceResponse/invoice/notes", default='')
    # Notes to be displayed on pdf.
    externalNotes = xml_models.CharField(xpath="/invoiceResponse/invoice/externalNotes", default='')
    requiresFollowUp = xml_models.BoolField(xpath="/invoiceResponse/invoice/requiresFollowUp", default=False) 
    # Invoice and/or order due date or quote expiry date.
    dueOrExpiryDate = xml_models.DateField(xpath="/invoiceResponse/invoice/dueOrExpiryDate", date_format="%Y-%m-%d") 

    # The invoice layout. Either S (Service) or I (Item)
    layout = xml_models.CharField(xpath="/invoiceResponse/invoice/layout", default='S')
    # Invoice status. Either Q (Quote), O (Order) or I (Invoice).
    status = xml_models.CharField(xpath="/invoiceResponse/invoice/status", default='I')
    # The sale invoice number. When inserting a sale, set to <Auto Number> to let the system generates the invoice number based on the preferences you set.
    invoiceNumber = xml_models.CharField(xpath="/invoiceResponse/invoice/invoiceNumber", default='')
    # The purchase order number (PO #). When inserting a purchase, set to <Auto Number> to let the system generates the PO# based on the preferences you set.
    purchaseOrderNumber = xml_models.CharField(xpath="/invoiceResponse/invoice/purchaseOrderNumber", default='')

    # TODO: Complete this part
    # quickPayment	 	 	 	Payment to be applied to this invoice.
    # payments	 	 	 	   All payments associated with this particular invoice, if incpayments is set to ‘true’ in the query string.

    # Indicates if the invoice has been sent/emailed to contact. This flag will be set to true automatically if the Invoice is sent successfully through the WSAPI.
    isSent = xml_models.BoolField(xpath="/invoiceResponse/invoice/isSent", default=False) 

    # You can include unlimited number of invoice items. For service invoice, use <ServiceInvoiceItem>?
    # For item invoice: use <ItemInvoiceItem>. You cannot mix the content of invoice items (i.e. having both <ServiceInvoiceItem> and <ItemInvoiceItem>).
    invoiceItems = CollectionField(ServiceInvoiceItem, xpath='/invoiceResponse/invoice/invoiceItems/serviceInvoiceItem')	 	 	 

    finders = {
        ('uid',): DEFAULT_GET_URL % __model__ + "&uid=%s",
        }
Beispiel #3
0
class Contact(BaseModel):
    """ Contact Entity """

    __model__ = 'Contact'
    template_name = 'saasu_client/contact_model.xml'

    uid = xml_models.IntField(xpath="/contactResponse/contact/@uid", default=0)
    lastUpdatedUid = xml_models.CharField(
        xpath="/contactResponse/contact/@lastUpdatedUid")
    # A.K.A "Title" values; Mr., Mrs., Ms., Dr., Prof.
    salutation = xml_models.CharField(
        xpath="/contactResponse/contact/salutation")
    # A.K.A "First Name".
    givenName = xml_models.CharField(
        xpath="/contactResponse/contact/givenName")
    # A.K.A. "Initial".
    middleInitials = xml_models.CharField(
        xpath="/contactResponse/contact/middleInitials")
    # A.K.A "Last Name".
    familyName = xml_models.CharField(
        xpath="/contactResponse/contact/familyName")
    # A.K.A. "Company".
    organizationName = xml_models.CharField(
        xpath="/contactResponse/contact/organizationName")
    # A.K.A. "Business Number".
    organizationAbn = xml_models.CharField(
        xpath="/contactResponse/contact/organizationAbn")
    # The organisation/company website url.
    organizationWebsite = xml_models.CharField(
        xpath="/contactResponse/contact/organizationWebsite")
    organizationPosition = xml_models.CharField(
        xpath="/contactResponse/contact/organizationPosition")

    # This is your own contact ID, different to Saasu's Contact Uid.
    contactID = xml_models.CharField(
        xpath="/contactResponse/contact/contactID")
    websiteUrl = xml_models.CharField(
        xpath="/contactResponse/contact/websiteUrl")
    email = xml_models.CharField(xpath="/contactResponse/contact/email")
    mainPhone = xml_models.CharField(
        xpath="/contactResponse/contact/mainPhone")
    homePhone = xml_models.CharField(
        xpath="/contactResponse/contact/homePhone")
    fax = xml_models.CharField(xpath="/contactResponse/contact/fax")
    mobilePhone = xml_models.CharField(
        xpath="/contactResponse/contact/mobilePhone")
    otherPhone = xml_models.CharField(
        xpath="/contactResponse/contact/otherPhone")
    # Separate multiple tags by comma. Max. length per tag is 35 characters.
    tags = xml_models.CharField(xpath="/contactResponse/contact/tags")

    postalAddress = xml_models.OneToOneField(
        PostalAddress, xpath='/contactResponse/contact/postalAddress')
    otherAddress = xml_models.OneToOneField(
        PostalAddress, xpath='/contactResponse/contact/postalAddress')

    # Default: True
    isActive = xml_models.BoolField(xpath="/contactResponse/contact/isActive",
                                    default=True)

    acceptDirectDeposit = xml_models.BoolField(
        xpath="/contactResponse/contact/acceptDirectDeposit")
    directDepositAccountName = xml_models.CharField(
        xpath="/contactResponse/contact/directDepositAccountName")
    directDepositBsb = xml_models.CharField(
        xpath="/contactResponse/contact/directDepositBsb")
    directDepositAccountNumber = xml_models.CharField(
        xpath="/contactResponse/contact/directDepositAccountNumber")

    acceptCheque = xml_models.BoolField(
        xpath="/contactResponse/contact/acceptCheque")
    chequePayableTo = xml_models.CharField(
        xpath="/contactResponse/contact/chequePayableTo")

    customField1 = xml_models.CharField(
        xpath="/contactResponse/contact/customField1")
    customField2 = xml_models.CharField(
        xpath="/contactResponse/contact/customField2")

    twitterID = xml_models.CharField(
        xpath="/contactResponse/contact/twitterID")
    skypeID = xml_models.CharField(xpath="/contactResponse/contact/skypeID")

    finders = {
        (uid, ): DEFAULT_GET_URL % __model__ + "&uid=%s",
    }
Beispiel #4
0
class ContactListItem(xml_models.Model):
    """ Contact List Item Entity """

    contactUid = xml_models.IntField(xpath="/contactListItem/contactUid")
    utcFirstCreated = xml_models.CharField(
        xpath="/contactListItem/utcFirstCreated")
    utcLastModified = xml_models.CharField(
        xpath="/contactListItem/utcLastModified")
    lastUpdatedUid = xml_models.CharField(
        xpath="/contactListItem/lastUpdatedUid")
    salutation = xml_models.CharField(xpath="/contactListItem/salutation")
    givenName = xml_models.CharField(xpath="/contactListItem/givenName")
    middleInitials = xml_models.CharField(
        xpath="/contactListItem/middleInitials")
    familyName = xml_models.CharField(xpath="/contactListItem/familyName")
    dateOfBirth = xml_models.DateField(xpath="/contactListItem/dateOfBirth",
                                       date_format="%Y-%m-%d")

    organisation = xml_models.CharField(xpath="/contactListItem/organisation")
    organisationName = xml_models.CharField(
        xpath="/contactListItem/organisationName")
    organisationAbn = xml_models.CharField(
        xpath="/contactListItem/organisationAbn")
    abn = xml_models.CharField(xpath="/contactListItem/abn")

    organizationWebsite = xml_models.CharField(
        xpath="/contactListItem/organizationWebsite")
    organizationPosition = xml_models.CharField(
        xpath="/contactListItem/organizationPosition")
    emailAddress = xml_models.CharField(xpath="/contactListItem/emailAddress")
    websiteUrl = xml_models.CharField(xpath="/contactListItem/websiteUrl")
    isActive = xml_models.BoolField(xpath="/contactListItem/isActive",
                                    default=True)

    mainPhone = xml_models.CharField(xpath="/contactListItem/mainPhone")
    homePhone = xml_models.CharField(xpath="/contactListItem/homePhone")
    mobilePhone = xml_models.CharField(xpath="/contactListItem/mobilePhone")
    otherPhone = xml_models.CharField(xpath="/contactListItem/otherPhone")
    fax = xml_models.CharField(xpath="/contactListItem/fax")

    street = xml_models.CharField(xpath="/contactListItem/street")
    city = xml_models.CharField(xpath="/contactListItem/city")
    state = xml_models.CharField(xpath="/contactListItem/state")
    postCode = xml_models.CharField(xpath="/contactListItem/postCode")
    country = xml_models.CharField(xpath="/contactListItem/country")

    otherStreet = xml_models.CharField(xpath="/contactListItem/otherStreet")
    otherCity = xml_models.CharField(xpath="/contactListItem/otherCity")
    otherState = xml_models.CharField(xpath="/contactListItem/otherState")
    otherPostCode = xml_models.CharField(
        xpath="/contactListItem/otherPostCode")

    contactID = xml_models.CharField(xpath="/contactListItem/contactID")

    acceptDirectDeposit = xml_models.BoolField(
        xpath="/contactListItem/acceptDirectDeposit")
    directDepositAccountName = xml_models.CharField(
        xpath="/contactListItem/directDepositAccountName")
    directDepositBsb = xml_models.CharField(
        xpath="/contactListItem/directDepositBsb")
    directDepositAccountNumber = xml_models.CharField(
        xpath="/contactListItem/directDepositAccountNumber")

    acceptCheque = xml_models.BoolField(xpath="/contactListItem/acceptCheque")
    chequePayableTo = xml_models.CharField(
        xpath="/contactListItem/chequePayableTo")

    # Separate multiple tags by comma. Max. length per tag is 35 characters.
    tags = xml_models.CharField(xpath="/contactListItem/tags")

    customField1 = xml_models.CharField(xpath="/contactListItem/customField1")
    customField2 = xml_models.CharField(xpath="/contactListItem/customField2")