def okClick(self): company = cl.company() contact = cl.contact() company.name = str(self.lineCompany.displayText()) contact.name = str(self.lineContactName.displayText()) contact.phone = str(self.lineContactNum.displayText()) contact.email = str(self.lineEmail.displayText()) company.licenseNumber = str(self.lineLicenseNum.displayText()) company.notes = str(self.textNoteBox.toPlainText()) company.contacts.append(contact) contact.companies.append(company) cl.inv.listAllCompanies.append(company) cl.inv.listAllContacts.append(contact) cl.save() self.hide() self.lineCompany.clear() self.lineContactName.clear() self.lineContactNum.clear() self.lineEmail.clear() self.lineLicenseNum.clear() self.textNoteBox.clear() cMain.listWidget.addItem(company.name)
def okPressed(self): target_container = '' if self.sourceType == 'Crude': target_container = self.crudeList[self.productBox.currentIndex()] elif self.sourceType == 'Distillate': target_container = self.distillateList[self.productBox.currentIndex()] weight = float(self.lineEdit.text()) newProduct = cl.unfinishedProduct() newProduct.intendedFinish = 'Distillate' newProduct.runsIncluded.append(target_container) newProduct.ID = str(self.lineEdit_2.text()) newProduct.weight = weight cl.inv.listAllUnfinishedProduct.append(newProduct) target_container.weight -= weight if target_container.weight <= 0: tlist = cl.inv.listAllContainers tlist.pop(tlist.index(target_container)) if self.sourceType == 'Crude': self.crudeList.pop(self.crudeList.index(target_container)) elif self.sourceType == 'Distillate': self.distillateList.pop(self.distillateList.index(target_container)) cl.save() self.hide()
def saveDay(self): global currentDate, OpenBags, OpenRuns saveList = [] date = (str(currentDate.month) + '-' + str(currentDate.day) + '-' + str(currentDate.year)) print(str(date)) i = 0 while i < self.listDailyRuns.count(): saveString = str(self.listDailyRuns.item(i).text()) saveList.append(OpenRuns[i]) isplit = saveString.split() unfinished = cl.unfinishedProduct() unfinished.ID = isplit[0] for run in OpenRuns: if str(run.ID) == unfinished.ID: unfinished.runsIncluded.append(run) for bag in OpenBags: if str(bag.ID) in isplit[0]: unfinished.owner = bag.owner bag.trimWeight -= float(isplit[4]) print('trim subtracted') if bag.trimWeight <= 0.0: cl.inv.listAllBags.pop(cl.inv.listAllBags.index(bag)) cl.inv.listFinishedBags.append(bag) print('bag retired') cl.inv.listAllUnfinishedProduct.append(unfinished) print(isplit[0]) i += 1 cl.inv.listAllRuns.append([date, saveList]) cl.save() self.updateBags()
def okClick(self): try: locations = cl.inv.listAllLocations locationDict = dict() for location in locations: locationDict.update({str(location.ID): location}) for tote in self.totesToSave: inn, ok = QtGui.QInputDialog.getItem(self, str(tote.ID), 'Choose Location:', locationDict.keys()) if ok: tote.location = locationDict[str(inn)] tote.location.items.append(tote) cl.inv.listAllTotes.append(tote) cl.inv.listAllTotesArchive.append(tote) self.currentShipment.totes = self.totesToSave if self.pushPass.isChecked(): self.currentShipment.testResults.append('Pass') elif self.pushFail.isChecked(): self.currentShipment.testResults.append('Fail') cl.save() self.listContainer.clear() self.hide() intake.update() lg.write('IntakePostWindow - post results saved...', deepData=str(self.totesToSave)) except: lg.write('IntakePostWindow - ERROR: okClick(self)', deepData=str(sys.exc_info()))
def okPress(self): finished = cl.finishedProduct() finished.ID = self.target_product.ID finished.weight = float(self.totalYield.text()) finished.kind = self.kind finished.unfinishedProductIncluded.append(self.target_product) cl.inv.listAllUnfinishedProduct.pop( cl.inv.listAllUnfinishedProduct.index(self.target_product)) cl.inv.listAllFinishedProduct.append(finished) target_container = str(self.container.text()) found = False for item in cl.inv.listAllContainers: if str(item.ID) == target_container: target_container = item found = True if found == False: newContainer = cl.container() newContainer.ID = target_container newContainer.kind = finished.kind cl.inv.listAllContainers.append(newContainer) target_container = newContainer target_container.productIncluded.append(finished) finished.container = target_container target_container.weight += finished.weight cl.save() yieldW.update() self.hide()
def sendTo(self, target, fromT): try: if '(C)' in target: message = 'Close ' else: message = 'Finish ' inn = QtGui.QMessageBox.question(self, 'Really?', message + str(target) + '?', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if inn == QtGui.QMessageBox.Yes: ilist = fromT.selectedItems() items = [] for item in ilist: for i in self.finishingList: if str(i.ID) == str(item.text()): i.intendedFinish = target cl.save() self.update() lg.write('FinishWindow - ' + target + ' --> product transfered...', deepData=ilist) except: lg.write('FinishWindow - ERROR: sendTo(self,target,fromT)', deepData=str(sys.exc_info()))
def sendTo(self,target,fromT): ilist = fromT.selectedItems() items = [] for item in ilist: for i in self.finishingList: if str(i.ID) == str(item.text()): i.intendedFinish = target cl.save() self.update()
def pay(self): payment = self.payments[self.listPayments.currentRow()] inn, ok = QtGui.QInputDialog.getText(self, 'Enter', 'Amount:') if ok: payment.transaction.amountToBePayed -= float(inn) payment.transaction.amountPayed += float(inn) if payment.transaction.amountToBePayed <= 0: payment.paymentRecieved = True cl.save() self.hide() posMain.updateLists()
def okClick(self): try: self.shipment.totalPrice = float(self.labelTotalPrice.text()) self.shipment.totalWeight = float(self.labelTotalWeight.text()) cl.save() self.listContainer.clear() self.shipment = cl.shipment() self.hide() intake.update() lg.write('IntakeContainerWindow - shipment saved...') except: lg.write('IntakeContainerWindow - ERROR: okClick(self)', deepData=str(sys.exc_info()))
def deleteSelected(self): toDelete = str(self.listWidget.currentItem().text()) for c in cl.inv.listAllCompanies: if c.name == toDelete: inn = QtGui.QMessageBox.question(self, 'Really?', 'Delete ' + toDelete + '?', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if inn == QtGui.QMessageBox.Yes: cl.inv.listAllCompanies.pop( cl.inv.listAllCompanies.index(c)) self.listWidget.takeItem(self.listWidget.currentRow()) cl.save()
def saveDay(self): global currentDate, OpenTotes, OpenRuns, weightLoss weightLoss = {} saveList = [] date = (str(currentDate.month) + '-' + str(currentDate.day) + '-' + str(currentDate.year)) print(str(date)) lg.write('ManagerWindow - beginning save...', deepData=date) i = 0 try: while i < self.listDailyRuns.count(): saveString = str(self.listDailyRuns.item(i).text()) saveList.append(OpenRuns[i]) isplit = saveString.split() unfinished = cl.unfinishedProduct() unfinished.ID = isplit[0] for run in OpenRuns: if str(run.ID) == unfinished.ID: unfinished.runsIncluded.append(run) unfinished.location = run.location run.location.items.append(unfinished) for tote in OpenTotes: if str(tote.ID) in isplit[0]: unfinished.owner = tote.owner tote.trimWeight -= float(isplit[4]) print('trim subtracted') if tote.trimWeight <= 0.0: cl.inv.listAllTotes.pop( cl.inv.listAllTotes.index(tote)) cl.inv.listFinishedTotes.append(tote) cl.inv.listFinishedTotesArchive.append(tote) tote.location.items.pop( tote.location.items.index(tote)) tote.location = 'Retired' print('bag retired') cl.inv.listAllUnfinishedProduct.append(unfinished) cl.inv.listAllUnfinishedProductArchive.append(unfinished) print(isplit[0]) i += 1 self.listDailyRuns.clear() OpenRuns = [] cl.inv.listAllRuns.append([date, saveList]) cl.inv.listAllRunsArchive.append([date, saveList]) cl.save() self.updateBags() lg.write('ManagerWindow - save successful...') except: lg.write('ManagerWindow - ERROR: saveDay(self)', deepData=str(sys.exc_info()))
def sendProduct(self): global products for kind in self.kinds.values(): current = kind.currentItem() print kind.currentItem() if current != None: for container in products.values(): if container.isPackaged: ins = '(P)' elif container.isPackaged == False: ins = '(B)' else: ins = '' conName = container.ID + ins + ' : ' + str( container.numberOfUnits) if str(conName) == str(current.text()): container.kind = container.kind[3:] cl.save() self.updateLists()
def group(self): try: lg.write('FinishWindow - attempting group...') ilist = self.listToBe.selectedItems() tlist = [] flist = [] nums = [] changeList = self.changeDat.copy() combo = cl.unfinishedProduct() for item in ilist: print(str(item.text())) for i in self.finishingList: if str(i.ID) == str(item.text()): cl.inv.listAllUnfinishedProduct.pop( cl.inv.listAllUnfinishedProduct.index(i)) tlist.append(i.ID) combo.runsIncluded.append(i) combo.owner = i.owner combo.location = i.location i.location.items.pop(i.location.items.index(i)) else: flist.append(i) combo.ID = str(tlist[0]) combo.location.items.append(combo) tlist.pop(0) for item in tlist: splitCombo = combo.ID.split('-') splitItem = item.split('-') targetCombo = splitCombo[0] + '-' + splitCombo[1] targetItem = splitItem[0] + '-' + splitItem[1] print targetCombo print targetItem if targetCombo == targetItem: combo.ID += "/" + item[-1] else: combo.ID += "/" + item cl.inv.listAllUnfinishedProduct.append(combo) cl.inv.listAllUnfinishedProductArchive.append(combo) self.finishingList = flist[:] cl.save() self.update() lg.write('FinishWindow - group successful...', deepData=combo) except: lg.write('FinishWindow - ERROR: group(self)', deepData=str(sys.exc_info()))
def save(self): self.runSource.intendedFinish = '(C)Distillate' path = QtGui.QFileDialog.getSaveFileName(self,'Save File','','CSV(*.csv)') if not path.isEmpty(): with open(unicode(path),'wb') as stream: writer = csv.writer(stream) for row in range(self.tableWidget.rowCount()): rowdata = [] for column in range(self.tableWidget.columnCount()): item = self.tableWidget.item(row,column) if item is not None: rowdata.append(unicode(item.text()).encode('utf8')) else: rowdata.append('') writer.writerow(rowdata) writer.writerow([self.runSource,'','','','','','','','','']) cl.save()
def okClick(self): c = self.currentCompany contact = c.contacts[0] c.name = str(self.lineCompany.displayText()) contact.name = str(self.lineContactName.displayText()) contact.phone = str(self.lineContactNum.displayText()) contact.email = str(self.lineEmail.displayText()) c.licenseNumber = str(self.lineLicenseNum.displayText()) c.notes = str(self.textNoteBox.toPlainText()) cl.save() self.lineCompany.clear() self.lineContactName.clear() self.lineContactNum.clear() self.lineEmail.clear() self.lineLicenseNum.clear() self.textNoteBox.clear() self.hide()
def send(self, whereTo): target = '' options = ['Distillate', 'Crumble/Goo', 'Live Resin', 'Crystals'] inn, ok = QtGui.QInputDialog.getItem(self, 'From where?', 'From Which Type?:', options) if ok: if str(inn) == 'Distillate': target = DistillateB[self.listDistoBulk.currentRow()] elif str(inn) == 'Crumble/Goo': target = CrumbleB[self.listCrumBulk.currentRow()] elif str(inn) == 'Live Resin': target = ResinB[self.listLiveBulk.currentRow()] elif str(inn) == 'Crystals': target = CrystalB[self.listCryBulk.currentRow()] target.kind = whereTo + target.kind cl.save() self.update()
def deleteSelected(self): toDelete = str(self.listWidget.currentItem().text()) cLog.write('mainWindow - attempting account deletion...') try: for c in cl.inv.listAllCompanies: if c.name == toDelete: inn = QtGui.QMessageBox.question( self, 'Really?', 'Delete ' + toDelete + '?', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if inn == QtGui.QMessageBox.Yes: cl.inv.listAllCompanies.pop( cl.inv.listAllCompanies.index(c)) self.listWidget.takeItem(self.listWidget.currentRow()) cl.save() cLog.write('mainWindow - account deleted...', deepData=toDelete) except: cLog.write('mainWindow - ERROR: deleteSelected(self)', deepData=str(sys.exc_info()))
def harvestCrystals(self): try: lg.write('FinishWindow - harvesting crystals...') listItem = self.listCry.selectedItems() targetSource = '' for item in listItem: for i in self.finishingList: if str(i.ID) == str(item.text()): targetSource = i targetSource.intendedFinish = '' resinToBe = copy.deepcopy(targetSource) resinToBe.ID += 'R' targetSource.ID += 'C' cl.inv.listAllUnfinishedProduct.append(resinToBe) cl.inv.listAllUnfinishedProductArchive.append(resinToBe) cl.save() self.update() lg.write('FinishWindow - crystals harvested...', deepData=targetSource.ID) except: lg.write('FinishWindow - ERROR: harvestCrystals(self)', deepData=str(sys.exc_info()))
def okClick(self): try: company = cl.company() contact = cl.contact() company.name = str(self.lineCompany.displayText()) contact.name = str(self.lineContactName.displayText()) contact.phone = str(self.lineContactNum.displayText()) contact.email = str(self.lineEmail.displayText()) company.licenseNumber = str(self.lineLicenseNum.displayText()) company.notes = str(self.textNoteBox.toPlainText()) if self.pushBuyer.isChecked(): company.isBuyer = True if self.pushSupplier.isChecked(): company.isSupplier = True company.contacts.append(contact) contact.companies.append(company) cl.inv.listAllCompanies.append(company) cl.inv.listAllCompaniesArchive.append(company) cl.inv.listAllContacts.append(contact) cl.inv.listAllContactsArchive.append(contact) cl.save() self.hide() self.lineCompany.clear() self.lineContactName.clear() self.lineContactNum.clear() self.lineEmail.clear() self.lineLicenseNum.clear() self.textNoteBox.clear() cMain.listWidget.addItem(company.name) cLog.write('customerNewWindow - account added...', deepData=company.name) except: cLog.write('customerNewWindow - ERROR: okClick(self)', deepData=str(sys.exc_info()))
def group(self): ilist = self.listToBe.selectedItems() tlist = [] flist = [] nums = [] changeList = self.changeDat.copy() combo = cl.unfinishedProduct() for item in ilist: print(str(item.text())) for i in self.finishingList: if str(i.ID) == str(item.text()): cl.inv.listAllUnfinishedProduct.pop(cl.inv.listAllUnfinishedProduct.index(i)) tlist.append(i.ID) combo.runsIncluded.append(i) else: flist.append(i) combo.ID = tlist[0] tlist.pop(0) for item in tlist: combo.ID += "/"+item[-1] cl.inv.listAllUnfinishedProduct.append(combo) self.finishingList = flist[:] cl.save() self.update()
def okPressed(self): target_container = '' if self.sourceType == 'Crude': target_container = self.crudeList[self.productBox.currentIndex()] elif self.sourceType == 'Distillate': target_container = self.distillateList[ self.productBox.currentIndex()] weight = float(self.lineWeightUsed.text()) newProduct = cl.unfinishedProduct() newProduct.intendedFinish = 'Distillate' newProduct.owner = target_container.productIncluded[ 0].unfinishedProductIncluded[0].owner runs = [] for product in target_container.productIncluded: for unfinishedProduct in product.unfinishedProductIncluded: for run in unfinishedProduct.runsIncluded: runs.append(run) for run in runs: newProduct.runsIncluded.append(run) newProduct.ID = str(self.lineID.text()) newProduct.weight = weight cl.inv.listAllUnfinishedProduct.append(newProduct) target_container.weight -= weight if target_container.weight <= 0: tlist = cl.inv.listAllContainers tlist.pop(tlist.index(target_container)) if self.sourceType == 'Crude': self.crudeList.pop(self.crudeList.index(target_container)) elif self.sourceType == 'Distillate': self.distillateList.pop( self.distillateList.index(target_container)) cl.save() self.hide()
def ok(self): paid = bool() total = float(self.lineSaleTotal.text()) transaction = self.soldProducts[0].paymentStatus transaction.amountToBePayed = total if self.pushPaidFull.isChecked(): transaction.amountPayed = transaction.amountToBePayed transaction.amountToBePayed = 0.00 else: transaction.amountPayed = float(self.linePaidPartial.text()) transaction.amountToBePayed -= float(self.linePaidPartial.text()) if transaction.amountToBePayed == 0.00: recieved = True else: recieved = False for item in self.soldProducts: transaction.valuedEntity.append(item) container = item.container container.numberOfUnits -= item.unitsSold container.weight -= container.unitSize * item.unitsSold container.history.append([ str(datetime.datetime.now()), '-', item.unitsSold, ' units sold to ' + str(transaction.sendingEntity.name) ]) if container.numberOfUnits <= 0: cl.inv.listAllContainers.pop( cl.inv.listAllContainers.index(container)) cl.inv.listAllTransactions.append(transaction) cl.inv.listAllTransactionsArchive.append(transaction) final = cl.finalizedSale(self.soldProducts[:], transaction, str(datetime.datetime.now()), recieved, total) cl.inv.listAllReciepts.append(final) cl.inv.listAllRecieptsArchive.append(final) self.hide() cl.save() posMain.updateLists()
def okClick(self): try: c = self.currentCompany contact = c.contacts[0] c.name = str(self.lineCompany.displayText()) contact.name = str(self.lineContactName.displayText()) contact.phone = str(self.lineContactNum.displayText()) contact.email = str(self.lineEmail.displayText()) c.licenseNumber = str(self.lineLicenseNum.displayText()) c.notes = str(self.textNoteBox.toPlainText()) if self.pushBuyer.isChecked(): c.isBuyer = True else: c.isBuyer = False if self.pushSupplier.isChecked(): c.isSupplier = True else: c.isSupplier = False cl.save() self.lineCompany.clear() self.lineContactName.clear() self.lineContactNum.clear() self.lineEmail.clear() self.lineLicenseNum.clear() self.textNoteBox.clear() if self.pushBuyer.isChecked(): self.pushBuyer.toggle() if self.pushSupplier.isChecked(): self.pushSupplier.toggle() self.hide() cLog.write('customerEditWindow - account edited...', deepData=c.name) except: cLog.write('customerEditWindow - ERROR: okClick(self)', deepData=str(sys.exc_info()))
def load_file(fp): """ load_file reads the file at path `fp` and returns a save object for the data contained :param fp: Filepath to .sav file :return: save object for that data """ try: with open(fp, "rb+") as f: misc.log(f"File loaded from: {fp}", 'debug') contents = f.read() except Exception as e: misc.log( e, 'critical', crashmsg="Fatal error encountered loading file with load_file().") return classes.save(contents, fp)
def okPress(self): try: finished = cl.finishedProduct() finished.ID = self.target_product.ID finished.weight = float(self.totalYield.text()) finished.kind = self.kind finished.location = self.target_product.location try: self.target_product.location.items.pop( self.target_product.location.items.index( self.target_product)) except: pass finished.owner = self.target_product.owner ### finished.unfinishedProductIncluded.append(self.target_product) cl.inv.listAllUnfinishedProduct.pop( cl.inv.listAllUnfinishedProduct.index(self.target_product)) cl.inv.listAllFinishedProduct.append(finished) cl.inv.listAllFinishedProductArchive.append(finished) target_container = str(self.container.text()) found = False for item in cl.inv.listAllContainers: if str(item.ID) == target_container: target_container = item found = True if found == False: newContainer = cl.container() newContainer.ID = target_container newContainer.kind = finished.kind cl.inv.listAllContainers.append(newContainer) cl.inv.listAllContainersArchive.append(newContainer) target_container = newContainer target_container.history.append([ str(datetime.datetime.now()), '+', finished.weight, 'yielded from ' + str(finished.ID) ]) target_container.productIncluded.append(finished) finished.container = target_container target_container.weight += finished.weight optionList = [] for i in cl.inv.listAllLocations: optionList.append(str(i.ID)) inn2, ok = QtGui.QInputDialog.getItem(self, 'Choose', 'Choose location to store:', optionList) if ok: for i in cl.inv.listAllLocations: if str(i.ID) == inn2: target_container.location = i i.items.append(target_container) else: return try: cl.inv.ALLCONTAINERS.append(target_container) except: cl.inv.ALLCONTAINERS = [target_container] cl.save() yieldW.update() self.hide() lg.write('YieldPOP - product yielded...', deepData=finished) except: lg.write('YieldPOP - ERROR: okPress(self)', deepData=str(sys.exc_info()))
def save(self): cl.save() self.update()
def okClick(self): cl.save() self.listContainer.clear() self.shipment = cl.shipment() self.hide()
def saveData(self): cl.save()
import classes as cl cl.load() ID = raw_input('ID: ') description = raw_input('description: ') loc = cl.location() loc.ID = ID loc.description = description cl.inv.listAllLocations.append(loc) cl.save() print('Location added!')
def save(): cl.save()