Пример #1
0
	def saveBOM(self):
		if select_bill_of_material_for_maintenance(self.mainte.id):
			bom = select_bill_of_material_for_maintenance(self.mainte.id)
			rwmatcost = claculateBOMItemRMCost(bom.id)
			spmatcost = claculateBOMItemSPCost(bom.id)
			mattotalcost = rwmatcost + spmatcost
			update_bill_of_material(bom.id, spmatcost, rwmatcost, mattotalcost)
			self.saveMainte()
Пример #2
0
	def tableDataShow(self):
		if select_bill_of_material_for_maintenance(self.mainte.id):
			bom = select_bill_of_material_for_maintenance(self.mainte.id)
			for idx, val in enumerate(getAllItemForBOM(bom.id)):
				self.tableData.addItems(BillOfMaterialItem(getAllItemForBOM(bom.id)[
															   idx].raw_material_id
														   , getAllItemForBOM(bom.id)[idx].spare_part_id
														   , None, getAllItemForBOM(bom.id)[idx].cost_of_material,
														   getAllItemForBOM(bom.id)[idx].qty_of_material,
														   getAllItemForBOM(bom.id)[idx].gen_code))
Пример #3
0
	def lablesData(self):
		if select_bill_of_material_for_maintenance(self.mainte.id):
			bom = select_bill_of_material_for_maintenance(self.mainte.id)
			if claculateBOMItemRMCost(bom.id) == 0:
				rwcost = 0
			else:
				rwcost = claculateBOMItemRMCost(bom.id)
			if claculateBOMItemSPCost(bom.id) == 0:
				spcost = 0
			else:
				spcost = claculateBOMItemSPCost(bom.id)
			self.totalRMCled.setText(str(rwcost))
			self.totalSPCled.setText(str(spcost))
			self.totalRMSPCled.setText(str(rwcost + spcost))
    def confirmMainte(self):
        datetimestr = datetime.now()
        timestampstr = datetimestr.strftime('%Y-%m-%d %H:%M:%S')
        indexes = self.tableView.selectionModel().selectedRows(0)
        for ind in sorted(indexes):
            maint = select_maintenance_by_code(ind.data())
        bom = select_bill_of_material_for_maintenance(maint.id)
        bomitem = select_bill_of_material_item_for_BOM(bom.id)
        for item in bomitem:
            if item.rawMaterial != None:
                decreaseRawMaterialInvQty(item.rawMaterial,
                                          item.qty_of_material)
            if item.spareParts != None:
                decreaseSparePartsInvQty(item.spareParts, item.qty_of_material)
        update_maintenance_confirm(maint.id, timestampstr)
        CreateAcConfReport(maint).create_pdf()
        CreateProConfReport(maint).create_pdf()

        self.tableData = MaintenanceTableModel()
        self.tableView.setModel(self.tableData)
        for idx, val in enumerate(getMaintenanceHolded()):
            self.tableData.addCustomer(
                Customers(getMaintenanceHolded()[idx].customers.name,
                          getMaintenanceHolded()[idx].customers.mobile_number,
                          None, None, None, None,
                          getMaintenanceHolded()[idx].m_code, None, None))
	def maintedata(self):
		bom = select_bill_of_material_for_maintenance(self.mainte.id)
		self.maintenanceCodelbl.setText(self.mainte.m_code)
		self.bomCodelbl.setText(bom.gen_code)
		self.customerNamelbl.setText(self.mainte.customers.name)
		self.customerMobilelbl.setText(self.mainte.customers.mobile_number)
		self.maintenanceProductlbl.setText(self.mainte.product_of_maintenance)
		self.maintenanceDescriplbl.setText(self.mainte.maintenance_description)
		self.tableDataShow()
 def Clicked(self, item):
     indexes = self.tableView.selectionModel().selectedRows(0)
     for ind in sorted(indexes):
         maint = select_maintenance_by_code(ind.data())
         self.custNamelbl.setText(maint.customers.name)
         self.custMobilePhonelbl.setText(maint.customers.mobile_number)
         self.maintCodelbl.setText(maint.m_code)
         self.maintProductlbl.setText(maint.product_of_maintenance)
         self.maintDesclbl.setText(maint.maintenance_description)
         bom = select_bill_of_material_for_maintenance(maint.id)
         self.rowCostlbl.setText(str(bom.cost_of_raw_material))
         self.spCostlbl.setText(str(bom.cost_of_spare_parts))
         self.matTotalCostlbl.setText(str(maint.cost_of_bill_of_material))
         self.calcbtn.setEnabled(True)
         self.detailsbtn.setEnabled(True)
         self.deletebtn.setEnabled(True)
         role = getLoginDataPKL()['role']
         if int(role) == 1:
             self.deletebtn.setEnabled(False)
Пример #7
0
 def Clicked(self, item):
     indexes = self.tableView.selectionModel().selectedRows(0)
     for ind in sorted(indexes):
         maint = select_maintenance_by_code(ind.data())
         self.custNamelbl.setText(maint.customers.name)
         self.custMobilePhonelbl.setText(maint.customers.mobile_number)
         self.maintCodelbl.setText(maint.m_code)
         self.maintProductlbl.setText(maint.product_of_maintenance)
         self.maintDesclbl.setText(maint.maintenance_description)
         self.createdlbl.setText(str(maint.created_at))
         self.laborled.setText(str(maint.cost_of_labor))
         self.startlbl.setText(str(maint.start_date))
         bom = select_bill_of_material_for_maintenance(maint.id)
         self.rowCostlbl.setText(str(bom.cost_of_raw_material))
         self.spCostlbl.setText(str(bom.cost_of_spare_parts))
         self.matTotalCostlbl.setText(str(maint.cost_of_bill_of_material))
         self.totalCostlbl.setText(
             str(maint.cost_of_bill_of_material + maint.cost_of_labor))
         self.finishbtn.setEnabled(True)
         self.detailsbtn.setEnabled(True)
Пример #8
0
	def addSpAction(self):
		bomo = select_bill_of_material_for_maintenance(self.mainte.id)
		from uiview.ui_addSPBOMItem import Ui_addSPBOMItemDialog
		self.addspdiloag = Ui_addSPBOMItemDialog(bomo)
		self.addspdiloag.exec_()
Пример #9
0
	def refresheddata(self):
		bom = select_bill_of_material_for_maintenance(self.mainte.id)
		self.tableData = BomItemTableModel()
		self.tableView.setModel(self.tableData)
		self.tableDataShow()
		self.lablesData()
Пример #10
0
	def createBOMFun(self):
		if select_bill_of_material_for_maintenance(self.mainte.id):
			bom = select_bill_of_material_for_maintenance(self.mainte.id)
		else:
			bom = creatBOMWithNewMAint(self.mainte.id)
		return bom
Пример #11
0
	def create_pdf(self):
		"""
		Create a pdf
		"""
		story = []

		doc = SimpleDocTemplate(self.refile, pagesize=A4)
		styles = getSampleStyleSheet()

		spacer = Spacer(0, 0.07 * inch)

		story.append(spacer)
		story.append(spacer)

		ptext = '<font size=10><a>Customer Name: {}</a></font>'.format(self.maint.customers.name)
		story.append(Paragraph(ptext, styles["Normal"]))
		story.append(spacer)

		ptext = '<font size=10><a>Customer Mobile Number: {}</a></font>'.format(
			self.maint.customers.mobile_number)
		story.append(Paragraph(ptext, styles["Normal"]))
		story.append(spacer)

		ptext = '<font size=10><a>Maintenance Product: {}</a></font>'.format(
			self.maint.product_of_maintenance)
		story.append(Paragraph(ptext, styles["Normal"]))
		story.append(spacer)

		ptext = '<font size=10><p>Maintenance Description :</p></font>'
		story.append(Paragraph(ptext, styles["Normal"]))
		story.append(spacer)

		ptext = '<font size=10><p>{}</p></font>'.format(self.maint.maintenance_description)
		story.append(Paragraph(ptext, styles["Normal"]))
		story.append(spacer)

		line = MCLine(-30, 470)
		story.append(line)
		story.append(spacer)

		"""
				Create the line items
				"""
		text_data = ["#", "Material Name", "Material Type", "QTY", "Cost"]
		d = []
		font_size = 8
		centered = ParagraphStyle(name="centered", alignment=TA_CENTER)
		for text in text_data:
			ptext = "<font size=%s><b>%s</b></font>" % (font_size, text)
			p = Paragraph(ptext, centered)
			d.append(p)

		data = [d]

		line_num = 1

		formatted_line_data = []

		bom = select_bill_of_material_for_maintenance(self.maint.id)
		for idx, val in enumerate(getAllItemForBOM(bom.id)):
			if val.raw_material_id:
				raw = select_row_material_by_id(val.raw_material_id)
				mname = raw.name
				typeName = "Raw Material"
			if val.spare_part_id:
				spare = select_spare_parts_by_id(val.spare_part_id)
				mname = spare.name
				typeName = "Spare Parts"
			line_data = [str(line_num), mname, typeName, val.qty_of_material
				, val.cost_of_material]

			for item in line_data:
				ptext = "<font size=%s>%s</font>" % (font_size - 1, item)
				p = Paragraph(ptext, centered)
				formatted_line_data.append(p)
			data.append(formatted_line_data)
			formatted_line_data = []
			line_num += 1

		table = Table(data, colWidths=[20, 220, 100, 80, 80], rowHeights=20
					  , style=[('GRID', (0, 0), (-1, -1), 0.5, colors.black)])
		story.append(table)
		story.append(spacer)
		#########################################################################################
		bomtxt = '<font size=9><p><b>BOM Cost</b></p></font>'
		pbomtxt = Paragraph(bomtxt, styles["Normal"])

		bomtxtnum = "<p>{}<p>".format(self.maint.cost_of_bill_of_material)
		pbomtxtnum = Paragraph(bomtxtnum, styles["Normal"])

		labtxt = '<font size=9><p><b>Extra Cost</b></p></font>'
		plabtxt = Paragraph(labtxt, styles["Normal"])

		labtxtnum = '<p>{}</p>'.format(self.maint.cost_of_labor)
		plabtxtnum = Paragraph(labtxtnum, styles["Normal"])

		totxt = '<font size=9><p><b>Total</b></p></font>'
		ptotxt = Paragraph(totxt, styles["Normal"])

		totxtnum = '<p>{}</p>'.format(self.maint.cost_of_labor +
									  self.maint.cost_of_bill_of_material)
		ptotxtnum = Paragraph(totxtnum, styles["Normal"])
		data = [['', '', '', pbomtxt, pbomtxtnum],
				['', '', '', plabtxt, plabtxtnum],
				['', '', '', ptotxt, ptotxtnum]]
		t = Table(data, colWidths=[5, 5, 380, 60, 50], rowHeights=15)
		t.setStyle(TableStyle([('LINEABOVE', (3, 2), (-1, -1), 0.25, colors.black)]))
		story.append(t)
		for x in range(10):
			story.append(spacer)

		#########################################################################################
		actxt = '<font size=11><p><u>Accountant</u><br/>Rani Mohamed</p></font>'
		pactxt = Paragraph(actxt, centered)

		matxtnum = '<font size=11><p><u>Manager</u><br/>Mohamed Althubiti</p></font>'
		pmatxtnum = Paragraph(matxtnum, centered)
		data = [[pactxt, '', '', '', pmatxtnum]]
		t = Table(data, colWidths=[150, 5, 250, 5, 150])
		t.setStyle(TableStyle([('LINEABOVE', (3, 2), (-1, -1), 0.25, colors.black)]))
		story.append(t)
		#########################################################################################

		story.append(spacer)

		doc.build(story, onFirstPage=self.createDocument, onLaterPages=self.createDocument)

		subprocess.Popen([self.refile], shell=True)