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 addToTotal(self,textIn): """ Returns the added price to the total """ if not self.isCredit(textIn): self.__setInvoice(textIn) price = float(s.removeCommas(self.iterText('Price',True,textIn))) self.total += price else: price = float(s.removeCommas(s.removeMinus(self.iterText(\ 'Price',True,textIn)))) self.total -= price
def setRate(self,textIn=None): """ Calculates the rate to a higher percision of digits so the original value can be overwritten. """ if textIn is None: quantity = float(s.removeMinus(s.removeCommas(\ self.iterText('Quantity')))) price = float(s.removeMinus(s.removeCommas(self.iterText('Price')))) self.rate = str(round(price / quantity,self.SIG_FIGS)) else: quantity = float(s.removeMinus(s.removeCommas(\ self.iterText('Quantity',True,textIn)))) price = float(s.removeMinus(s.removeCommas(\ self.iterText('Price',True,textIn)))) return str(round(price / quantity,self.SIG_FIGS))
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 _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 __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)