def _getNextPair(self): text = self.fid.readline() if text == '': self.reading = False else: key = s.subStrByChar(text,'','\t') key = s.removeSpaces(key) value = s.subStrByChar(text,'\t','\n') value = s.removeSpaces(value) return key,value return None,None
def __init__(self, item, quantity, cost): """ Initializes the Item class. Input the item code, the quantity required to fulfill the order and the cost of the item. """ self.item = s.removeSpaces(item) self.quantity = s.removeCommas(s.removeSpaces(quantity)) self.cost = s.removeCommas(s.removeSpaces(cost)) self.costRate = self._setCostRate() self.salesRate = 0 self.building = True
def __init__(self,invoice,date): """ This initializes the invoice. """ self.invoice = s.removeSpaces(invoice) self.items = [] self.transactions = [] self.balance = 0 self.date = s.removeSpaces(date) self.lateCode = 0 self.termKey = ACCT_TERM self.building = not self._isTerminator(invoice)
def __init__(self, invoice, date): """ This initializes the invoice. """ self.invoice = s.removeSpaces(invoice) self.items = [] self.transactions = [] self.balance = 0 self.date = s.removeSpaces(date) self.lateCode = 0 self.termKey = ACCT_TERM self.building = not self._isTerminator(invoice)
def __init__(self, orderNo, date, PO, shipTo=None): """ Initializes the Order class. Requires the order number, the date of the order, and the PO number to be inputted. """ self.order = s.removeSpaces(orderNo) self.date = s.removeSpaces(date) self.PO = s.removeReturns(s.removeSpaces(PO)) if shipTo is not None: self.shipTo = self.setShipTo(shipTo) self.items = [] self.totalSales = 0 self.building = True
def _getNextPair(self): """ Returns the completed map from the text file. """ text = self.fid.readline() if text == "": self.reading = False else: key = s.subStrByChar(text, "", "\t") key = s.removeSpaces(key) value = s.subStrByChar(text, "\t", "\n") value = s.removeSpaces(value) return key, value return None, None
def _getNextPair(self): """ Returns the completed map from the text file. """ text = self.fid.readline() if text == '': self.reading = False else: key = s.subStrByChar(text,'','\t') key = s.removeSpaces(key) value = s.subStrByChar(text,'\t','\n') value = s.removeSpaces(value) return key,value return None,None
def _getItem(self): """ Get item value from incoming text """ item = self.iterText('Item Name') item = s.removeSpaces(item) return item
def _setSalesTotal(self, salesTotal): """ Add sales total to account class """ salesTotal = s.removeSpaces(salesTotal) salesTotal = s.removeCommas(salesTotal) salesTotal = s.removeReturns(salesTotal) self.postedTotalSales = float(salesTotal) self._setCalculatedTotal()
def __convertDateToPostingPeriod(self): """ Converts the date of the transaction to the postion period id """ date = s.removeSpaces(self.iterText('Date')) month = s.subStrByChar(date,'','/') date_w_no_month = s.subStrByChar(date+'*', '/','*') year = s.subStrByChar(date_w_no_month+'*','/','*') return self.__getPostingPeriod(month + '/' + year)
def __init__(self, customer): """ Initializes the OpenAccount class. Needs the customer Id to be inputed to initialize. """ self.customer = s.removeSpaces(customer) self.invoices = [] self.building = True self.reported = False
def _setShipTo(self, shipTo): """ Set the ship to address of sales order """ shipTo = s.removeSpaces(shipTo) try: self.shipTo = int(SHIP_MAP[customer][shipTo]) except KeyError: self.shipTo = 1
def __hasInvoice(self,invoice): """ Returns boolean if invoice appears in Invoice Map """ invoice = s.removeSpaces(invoice) if self.invoiceMap.has_key(invoice): return True else: return False
def __init__(self,customer): """ Initializes the OpenAccount class. Needs the customer Id to be inputed to initialize. """ self.customer = s.removeSpaces(customer) self.invoices = [] self.building = True self.reported = False
def _setCommentField(self,textIn,fid=None): """ Writes field to csv """ if fid is None: fid = self.fid textOut = self.iterText(textIn) textOut = s.removeSpaces(textOut) textOut = s.removeCommas(textOut) fid.write(textOut)
def _setCommentField(self, textIn, fid=None): """ Writes field to csv """ if fid is None: fid = self.fid textOut = self.iterText(textIn) textOut = s.removeSpaces(textOut) textOut = s.removeCommas(textOut) fid.write(textOut)
def _isCustomer(self): """ Checks to see if the incoming text contains a customer number """ textIn = self.iterText('Customer') textIn = s.removeSpaces(textIn) if len(textIn) < 1: return False if textIn[0] == CUST_KEY: return True return False
def __init__(self, customer): """ Initializes the OpenAccount class. Needs customer Id to be inputted. """ self.customer = s.removeSpaces(customer) self.orders = [] self.postedTotalSales = 0.0 self.calculatedTotalSales = 0.0 self.difference = 0 self.building = True self.reported = False
def __init__(self, reference, transType): """ This initializes the account transaction. It needs the incoming invoice number and transaction type to be created. """ self.date = '' self.invoice = reference self.transType = s.removeSpaces(transType) self.amount = 0 self.termKey = INV_TERM self.building = True
def __init__(self,reference,transType): """ This initializes the account transaction. It needs the incoming invoice number and transaction type to be created. """ self.date = '' self.invoice = reference self.transType = s.removeSpaces(transType) self.amount = 0 self.termKey = INV_TERM self.building = True
def setAmount(self, amount): """ Sets amount variable. Sets variable to a real number """ amount = s.removeSpaces(amount) # amount = s.removeMinus(amount) if self._isTerminator(amount): self.building = False return if amount.find('-') == -1: self.amount = float(amount) else: amount = s.removeMinus(amount) self.amount = -float(amount)
def _getNextPair(self): """ Gets the next pair. Conditional with a new super key. """ text = self.fid.readline() if text == '': self.reading = False else: if not self._isSubKey(text): key = s.subStrByChar(text,'','\t') key = s.removeSpaces(key) subKey = s.subStrByChar(text,'\t','\t') subKey = s.removeSpaces(subKey) value = s.subStrByChar(text,'\t','\n',True) value = s.removeSpaces(value) return key,subKey,value else: subKey = s.subStrByChar(text,'\t','\t') subKey = s.removeSpaces(subKey) value = s.subStrByChar(text,'\t','\n',True) value = s.removeSpaces(value) return self.superKey,subKey,value return None,None,None
def setAmount(self,amount): """ Sets amount variable. Sets variable to a real number """ amount = s.removeSpaces(amount) # amount = s.removeMinus(amount) if self._isTerminator(amount): self.building = False return if amount.find('-') == -1: self.amount = float(amount) else: amount = s.removeMinus(amount) self.amount = -float(amount)
def _getNextPair(self): """ Gets the next pair. Conditional with a new super key. """ text = self.fid.readline() if text == "": self.reading = False else: if not self.subKey: key = s.subStrByChar(text, "", "\t") key = s.removeSpaces(key) self.superKey = key self.subKey = True subKey = s.subStrByChar(text, "\t", "\t") subKey = s.removeSpaces(subKey) value = s.subStrByChar(text, "\t", "\n") value = s.removeSpaces(value) return key, {subKey: value} else: subKey = s.subStrByChar(text, "\t", "\t") subKey = s.removeSpaces(subKey) value = s.subStrByChar(text, "\t", "\n") value = s.removeSpaces(value) return self.superKey, {subKey: value}
def _getNextPair(self): """ Gets the next pair. Conditional with a new super key. """ text = self.fid.readline() if text == '': self.reading = False else: if not self.subKey: key = s.subStrByChar(text,'','\t') key = s.removeSpaces(key) self.superKey = key self.subKey = True subKey = s.subStrByChar(text,'\t','\t') subKey = s.removeSpaces(subKey) value = s.subStrByChar(text,'\t','\n') value = s.removeSpaces(value) return key,{subKey:value} else: subKey = s.subStrByChar(text,'\t','\t') subKey = s.removeSpaces(subKey) value = s.subStrByChar(text,'\t','\n') value = s.removeSpaces(value) return self.superKey,{subKey:value}
def setDate(self,date): """ Sets date variable """ date = s.removeSpaces(date) self.date = date
def __setInvoice(self,textIn): """ Sets invoice """ self.invoice = s.removeSpaces(self.iterText('Invoice',True,textIn))
def _setLateCode(self,code): """ Sets late code variable. This variable is used to determine how far back a search is required. """ self.lateCode = s.removeSpaces(code)
def __getUnits(self): """ Returns sale unit type """ item = s.removeSpaces(self.itemID) return self.unitMap[item]
def __getItemID(self): """ Returns the Item NetSuite ID """ item = s.removeSpaces(self.itemID) return self.itemMap[item]
def __getCustomerID(self): """ Returns the Customer NetSuite ID """ customer = s.removeSpaces(self.customerID) return self.customerMap[customer]
def __setField(self,field,fid=None): """ This method writes data to the csv file. It pulls persistant data stored in the class for the fields it doesn't have. It scrubs the data for each entry for formatting errors. It takes an incoming field name pulled from the header list, finds the data from the text variable and writes to the csv. """ if field == 'Customer ID': if self.printCustomer: fieldVal = self.customerID else: fieldVal = '' elif field == 'Customer Name': if self.printCustomer: fieldVal = self.customer else: fieldVal = '' elif field == 'Item ID': fieldVal = self.itemID elif field == 'Item Description': fieldVal = self.item elif field == 'Rate': fieldVal = self.rate elif field == 'Sales Total': fieldVal = self.total elif field == 'Transaction Type': if self.isCredit(): fieldVal = 'Credit' else: fieldVal = 'Sale' elif field == 'Undeposited Funds' or field == 'Subsidiary' or \ field == 'Location' or field == 'Payment Method' : if self.printCustomer: fieldVal = self.defaults[field] else: fieldVal = '' elif field == 'Tax Code' or field == 'Price Level' or \ field == 'Cost Estimate': fieldVal = self.defaults[field] elif field == 'Customer': if self.printCustomer: fieldVal = self.__getCustomerID() else: fieldVal = '' elif field == 'Item': self.__nextField(fid) fieldVal = self.__getItemID() elif field == 'Units': fieldVal = self.__getUnits() elif field == 'Transaction Date': if self.printCustomer: fieldVal = self.iterText('Date') else: fieldVal = '' elif field == 'Posting Period': if self.printCustomer: fieldVal = self.__convertDateToPostingPeriod() else: fieldVal = '' elif field == 'Inv Open': invoice = self.iterText('Invoice') if self.__hasInvoice(invoice): fieldVal = 'True' else: fieldVal = '' elif field == 'Parent Inv': fieldVal = self.p_inv #elif field == 'Invoice': # if self.printCustomer: # fieldVal = self.iterText('Invoice') # else: # fieldVal = '' else: fieldVal = self.iterText(field) fieldVal = s.removeSpaces(fieldVal) fieldVal = s.removeCommas(fieldVal) if field == 'Quantity' or 'Cost': fieldVal = s.removeMinus(fieldVal) if fid is None: fid = self.fid fid.write(fieldVal)
def setDate(self, date): """ Sets date variable """ date = s.removeSpaces(date) self.date = date
def _setLateCode(self, code): """ Sets late code variable. This variable is used to determine how far back a search is required. """ self.lateCode = s.removeSpaces(code)