class ItemInvoiceItem(BaseModel): """ Item Invoice Item Entity """ __model__ = 'ItemInvoiceItem' template_name = 'saasu_client/iteminvoiceitem_model.xml' # The quantity. Maximum 3 decimals. quantity = xml_models.FloatField(xpath="/itemInvoiceItem/quantity", default=0) # The inventory item for this invoice line item. This also covers # combo item. For combo item, use combo item uid. inventoryItemUid = xml_models.IntField(xpath="/itemInvoiceItem/inventoryItemUid", default=0) # Description of service invoice line item. Use pipe (|) character to indicate new line. description = xml_models.CharField(xpath="/itemInvoiceItem/description") # Must be one of the tax codes in your file. Invalid tax code will be ignored. taxCode = xml_models.CharField(xpath="/itemInvoiceItem/taxCode") # Unit price of inventory item. unitPriceInclTax = xml_models.FloatField(xpath="/itemInvoiceItem/unitPriceInclTax", default=0) # Percentage discount. E.g. for 10% off the unit price is set the value to 10. # Valid values: between 0 and 100. Maximum 2 decimals. percentageDiscount = xml_models.IntField(xpath="/itemInvoiceItem/percentageDiscount", default=0)
class ServiceInvoiceItem(BaseModel): """ Service Invoice Item Entity """ __model__ = 'ServiceInvoiceItem' template_name = 'saasu_client/serviceinvoiceitem_model.xml' # Description of service invoice line item. Use pipe (|) character to indicate new line. description = xml_models.CharField(xpath="/serviceInvoiceItem/description") # The Account for this line item. accountUid = xml_models.IntField(xpath="/serviceInvoiceItem/accountUid") # Must be one of the tax codes in your file. Invalid tax code will be ignored. taxCode = xml_models.CharField(xpath="/serviceInvoiceItem/taxCode") # The total amount (tax inclusive) for this line item. Positive, negative, and 0 are accepted. Maximum 2 decimals. totalAmountInclTax = xml_models.FloatField(xpath="/serviceInvoiceItem/totalAmountInclTax", default=0)
class InventoryListItem(xml_models.Model): """ Inventory List Item Entity """ uid = xml_models.IntField(xpath="/inventoryItem/@uid", default=0) lastUpdatedUid = xml_models.CharField( xpath="/inventoryItem/@lastUpdatedUid") utcFirstCreated = xml_models.CharField( xpath="/inventoryItem/utcFirstCreated") utcLastModified = xml_models.CharField( xpath="/inventoryItem/utcLastModified") code = xml_models.CharField(xpath="/inventoryItem/code") description = xml_models.CharField(xpath="/inventoryItem/description") isActive = xml_models.BoolField(xpath="/inventoryItem/isActive", default=True) isInventoried = xml_models.BoolField(xpath="/inventoryItem/isInventoried", default=False) assetAccountUid = xml_models.IntField( xpath="/inventoryItem/assetAccountUid", default=0) stockOnHand = xml_models.IntField(xpath="/inventoryItem/stockOnHand", default=0) currentValue = xml_models.IntField(xpath="/inventoryItem/currentValue", default=0) quantityOnOrder = xml_models.IntField( xpath="/inventoryItem/quantityOnOrder", default=0) quantityCommited = xml_models.IntField( xpath="/inventoryItem/quantityCommited", default=0) isBought = xml_models.BoolField(xpath="/inventoryItem/isBought", default=False) purchaseExpenseAccountUid = xml_models.IntField( xpath="/inventoryItem/purchaseExpenseAccountUid", default=0) minimumStockLevel = xml_models.IntField( xpath="/inventoryItem/minimumStockLevel", default=0) primarySupplierContactUid = xml_models.IntField( xpath="/inventoryItem/primarySupplierContactUid", default=0) defaultReOrderQuantity = xml_models.IntField( xpath="/inventoryItem/defaultReOrderQuantity", default=0) isSold = xml_models.BoolField(xpath="/inventoryItem/isSold", default=True) saleIncomeAccountUid = xml_models.IntField( xpath="/inventoryItem/saleIncomeAccountUid", default=0) saleTaxCode = xml_models.CharField(xpath="/inventoryItem/saleTaxCode") saleCoSAccountUid = xml_models.IntField( xpath="/inventoryItem/saleCoSAccountUid", default=0) sellingPrice = xml_models.FloatField(xpath="/inventoryItem/sellingPrice", default=0) isSellingPriceIncTax = xml_models.BoolField( xpath="/inventoryItem/isSellingPriceIncTax", default=True) buyingPrice = xml_models.FloatField(xpath="/inventoryItem/buyingPrice", default=0) isBuyingPriceIncTax = xml_models.BoolField( xpath="/inventoryItem/isBuyingPriceIncTax", default=True) isVoucher = xml_models.BoolField(xpath="/inventoryItem/isVoucher", default=False) validFrom = xml_models.DateField(xpath="/inventoryItem/validFrom", date_format="%Y-%m-%d") validTo = xml_models.DateField(xpath="/inventoryItem/validTo", date_format="%Y-%m-%d") isVirtual = xml_models.BoolField(xpath="/inventoryItem/isVirtual", default=True) isVisible = xml_models.BoolField(xpath="/inventoryItem/isVisisble", default=False)
class InventoryItem(BaseModel): """ Inventory Item Entity """ __model__ = 'InventoryItem' # Required for update. uid = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/@uid", default=0) # Required for update. lastUpdatedUid = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/@lastUpdatedUid") # Inventory item code. Must be unique. code = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/code") # Inventory item description. # Multi-line description is supported. Use the pipe (|) to indicate newline. description = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/description") # Default: True isActive = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isActive", default=True) notes = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/notes") isInventoried = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isInventoried", default=False) # Required only if IsInventoried is set to true. Accounts used must be of type Asset. assetAccountUid = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/assetAccountUid", default=0) # How many stocks on hand? This element is only used when you retrieve an Inventory Item from your File. # This value is ignored on insert and update. stockOnHand = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/stockOnHand", default=0) # Current stock value. This element is only used when you retrieve an Inventory Item from your File. # This value is ignored on insert and update. currentValue = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/currentValue", default=0) # Specifies if this item can be bought or not. Default: false (cannot be bought). isBought = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isBought", default=False) # Expense Account for tracking purchase. # Required only if the Inventory Item is not inventoried and item can be bought (isInventoried == false && isBought == true). # Accounts used must be of type Expense. purchaseExpenseAccountUid = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/purchaseExpenseAccountUid", default=0) # Default tax code when the inventory item is purchased. purchaseTaxCode = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/purchaseTaxCode") # Minimum stock level used for re-stocking alert report. minimumStockLevel = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/minimumStockLevel", default=0) # The primary supplier for this Inventory Item. primarySupplierContactUid = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/primarySupplierContactUid", default=0) # The primary supplier’s item code for this Inventory Item. primarySupplierItemCode = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/primarySupplierItemCode") # Default re-order quantity for re-stocking alert report. defaultReOrderQuantity = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/defaultReOrderQuantity", default=0) # Default buying price for the item. Only applicable if the Inventory Item is marked as bought. buyingPrice = xml_models.FloatField( xpath="/inventoryItemResponse/inventoryItem/buyingPrice", default=0) # A flag specifying whether the buying price includes/excludes tax. isBuyingPriceIncTax = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isBuyingPriceIncTax", default=True) # Specifies whether the Inventory Item can be sold or not. Default: false (cannot be sold). isSold = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isSold", default=True) # Account for tracking sales. Only required if the item can be sold (isSold == true). Accounts used must be of type Income. saleIncomeAccountUid = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/saleIncomeAccountUid", default=0) # Default tax code for sale. saleTaxCode = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/saleTaxCode") # Accounts for tracking cost of sales. Required only if Inventory Item is inventoried & for sale. # Accounts used must be of type Cost of Sales. saleCoSAccountUid = xml_models.IntField( xpath="/inventoryItemResponse/inventoryItem/saleCoSAccountUid", default=0) # The default selling price for this Inventory Item. Only applicable if the Inventory Item is marked as sold. sellingPrice = xml_models.FloatField( xpath="/inventoryItemResponse/inventoryItem/sellingPrice", default=0) isSellingPriceIncTax = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isSellingPriceIncTax", default=True) # A flag that indicates this is an item you sell, that you haven’t bought or assembled as stock to make available for sale. isVirtual = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isVirtual", default=True) # The type if this item is marked as virtual. vType = xml_models.CharField( xpath="/inventoryItemResponse/inventoryItem/vType") # A flag to set the Item to visible, for an example this can be # used in your database so that Item is flagged to be displayed in your ecommerce product listings. isVisible = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isVisisble", default=False) # A flag specifying whether this item is treated as a voucher. isVoucher = xml_models.BoolField( xpath="/inventoryItemResponse/inventoryItem/isVoucher", default=False) # When the voucher becomes effective. validFrom = xml_models.DateField( xpath="/inventoryItemResponse/inventoryItem/validFrom", date_format="%Y-%m-%d") # When the voucher expires. validTo = xml_models.DateField( xpath="/inventoryItemResponse/inventoryItem/validTo", date_format="%Y-%m-%d") finders = { (uid, ): DEFAULT_GET_URL % __model__ + "&uid=%s", }
def test_raises_error_if_not_an_int(self): with self.assertRaises(ValueError): field = xml_models.FloatField(xpath='/root/kiddie/char') response = field.parse(XML, None)
def test_casts_to_int(self): field = xml_models.FloatField(xpath='/root/kiddie/float') response = field.parse(XML, None) self.assertEquals(11.11, response)
def test_uses_base(self, mock_base): field = xml_models.FloatField(xpath='/root/kiddie/int') response = field.parse(XML, None) self.assertTrue(mock_base.called)
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", }