forked from routablehq/python-quickbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvoice.py
More file actions
119 lines (97 loc) · 3.32 KB
/
invoice.py
File metadata and controls
119 lines (97 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from six import python_2_unicode_compatible
from .base import QuickbooksBaseObject, Ref, CustomField, Address, EmailAddress, CustomerMemo, QuickbooksManagedObject, \
QuickbooksTransactionEntity, LinkedTxn, LinkedTxnMixin
from .tax import TxnTaxDetail
from .detailline import DetailLine, SalesItemLine, SubtotalLine, DiscountLine, GroupLine, DescriptionOnlyLine
from ..mixins import QuickbooksPdfDownloadable, DeleteMixin, SendMixin, VoidMixin
class DeliveryInfo(QuickbooksBaseObject):
def __init__(self):
super(DeliveryInfo, self).__init__()
self.DeliveryType = ""
self.DeliveryTime = ""
@python_2_unicode_compatible
class Invoice(DeleteMixin, QuickbooksPdfDownloadable, QuickbooksManagedObject, QuickbooksTransactionEntity,
LinkedTxnMixin, SendMixin, VoidMixin):
"""
QBO definition: An Invoice represents a sales form where the customer pays for a product or service later.
"""
class_dict = {
"DepartmentRef": Ref,
"CurrencyRef": Ref,
"CustomerRef": Ref,
"ClassRef": Ref,
"SalesTermRef": Ref,
"ShipMethodRef": Ref,
"DepositToAccountRef": Ref,
"BillAddr": Address,
"ShipAddr": Address,
"TxnTaxDetail": TxnTaxDetail,
"BillEmail": EmailAddress,
"CustomerMemo": CustomerMemo,
"DeliveryInfo": DeliveryInfo
}
list_dict = {
"CustomField": CustomField,
"Line": DetailLine,
"LinkedTxn": LinkedTxn,
}
detail_dict = {
"SalesItemLineDetail": SalesItemLine,
"SubTotalLineDetail": SubtotalLine,
"DiscountLineDetail": DiscountLine,
"DescriptionOnly": DescriptionOnlyLine,
"GroupLineDetail": GroupLine
}
qbo_object_name = "Invoice"
def __init__(self):
super(Invoice, self).__init__()
self.Deposit = 0
self.Balance = 0
self.AllowIPNPayment = True
self.AllowOnlineCreditCardPayment = False
self.AllowOnlineACHPayment = False
self.DocNumber = None
self.PrivateNote = ""
self.DueDate = ""
self.ShipDate = ""
self.TrackingNum = ""
self.TotalAmt = ""
self.TxnDate = ""
self.ApplyTaxAfterDiscount = False
self.PrintStatus = "NotSet"
self.EmailStatus = "NotSet"
self.ExchangeRate = 1
self.GlobalTaxCalculation = "TaxExcluded"
self.InvoiceLink = ""
self.EInvoiceStatus = None
self.BillAddr = None
self.ShipAddr = None
self.BillEmail = None
self.CustomerRef = None
self.CurrencyRef = None
self.CustomerMemo = None
self.DepartmentRef = None
self.TxnTaxDetail = None
self.DeliveryInfo = None
self.CustomField = []
self.Line = []
self.LinkedTxn = []
def __str__(self):
return str(self.TotalAmt)
def to_linked_txn(self):
linked_txn = LinkedTxn()
linked_txn.TxnId = self.Id
linked_txn.TxnType = "Invoice"
linked_txn.TxnLineId = 1
return linked_txn
@property
def email_sent(self):
if self.EmailStatus == "EmailSent":
return True
return False
def to_ref(self):
ref = Ref()
ref.name = self.DocNumber
ref.type = self.qbo_object_name
ref.value = self.Id
return ref