Exemplo n.º 1
0
    def QueryOutputRecord(self):
        """查询出货记录"""
        oBeginDate = self.dateEditBeginOutputRecord.date()
        sBeginTime = oBeginDate.toString("yyyy-MM-dd 00:00:00")
        iBeginTime = pubmisc.Str2Time(sBeginTime)
        oEndDate = self.dateEditEndOutputRecord.date()
        sEndTime = oEndDate.toString("yyyy-MM-dd 23:59:59")
        iEndTime = pubmisc.Str2Time(sEndTime)
        sGoods = self.comboBoxOutputRecordGoods.currentText()
        sBuyer = self.comboBoxOutputRecordBuyer.currentText()

        dSellInfo = pubmisc.CallManagerFunc("shippingmgr", "GetSellInfoRecord", iBeginTime, iEndTime, sGoods, sBuyer)
        lstHead = ["日期", "商品", "卖家", "售价", "数量", "备注", "利润", "双击删除"]
        self.tableWidgetOutputRecord.setColumnCount(len(lstHead))
        self.tableWidgetOutputRecord.setRowCount(len(dSellInfo))
        self.tableWidgetOutputRecord.setHorizontalHeaderLabels(lstHead)
        self.tableWidgetOutputRecord.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
        iRow = iAllNum = fPrice = fProfile = 0
        for iID, tSellInfo in dSellInfo.items():
            iTime, sGoods, sSeller, fSellPrice, iNum, sRemark = tSellInfo
            for iCol, xValue in enumerate(tSellInfo):
                if iCol == 0:
                    xValue = pubmisc.Time2Str(xValue)
                item = QtWidgets.QTableWidgetItem(str(xValue))
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                self.tableWidgetOutputRecord.setItem(iRow, iCol, item)

            fBuyPrice = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsBuyPrice", sGoods)
            fCurProfile = (fSellPrice - fBuyPrice) * iNum
            item = QtWidgets.QTableWidgetItem(str(fCurProfile))
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetOutputRecord.setItem(iRow, iCol + 1, item)

            icon = QtGui.QIcon(QtGui.QPixmap("image/main.ico"))
            item = QtWidgets.QTableWidgetItem(icon, str(iID))
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetOutputRecord.setItem(iRow, iCol + 2, item)

            iRow += 1
            fProfile += fCurProfile
            iAllNum += tSellInfo[4]
            fPrice += tSellInfo[3] * tSellInfo[4]

        self.labelNum.setText("总售货数量: %s" % iAllNum)
        self.labelAmount.setText("总售货金额: %s" % fPrice)
        self.labelProfile.setText("总利润: %s" % fProfile)
        self.labelNum.show()
        self.labelAmount.show()
        self.labelProfile.show()
Exemplo n.º 2
0
def InitConfig():
    sys.excepthook = pubmisc.SysExceptHook

    sTime = pubmisc.Time2Str(timeformat="%Y-%m-%d")
    sLogName = os.path.join("log", sTime + ".log")
    handler = logging.FileHandler(filename=sLogName,
                                  mode="a",
                                  encoding="utf-8")
    handler.setFormatter(
        logging.Formatter(
            "%(asctime)s - %(filename)s(%(lineno)d) - %(levelname)s - %(message)s"
        ))
    logger = logging.getLogger()
    logger.addHandler(handler)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    logger.addHandler(ch)
Exemplo n.º 3
0
def InitConfig():
    if not os.path.exists("xh"):
        os.makedirs("xh")
    sLogDir = os.path.join(os.getcwd(), "log")
    pubmisc.MakeDirs(sLogDir)
    logging.basicConfig(
        filename="log/log%s.log" %
        pubmisc.Time2Str(timeformat="%Y-%m-%d %H-%M-%S"),
        format=
        "[%(asctime)s] [%(levelname)s] [%(filename)s] [%(lineno)s] %(message)s",
        datefmt="%Y-%m-%d %H:%M:%S",
        level=logging.DEBUG,
    )
    ch = logging.StreamHandler()
    logger = logging.getLogger()
    logger.addHandler(ch)
    logging.info("init config...")
Exemplo n.º 4
0
    def QueryInputRecord(self):
        """查询进货记录"""
        oBeginDate = self.dateEditBeginInputRecord.date()
        sBeginTime = oBeginDate.toString("yyyy-MM-dd 00:00:00")
        iBeginTime = pubmisc.Str2Time(sBeginTime)
        oEndDate = self.dateEditEndInputRecord.date()
        sEndTime = oEndDate.toString("yyyy-MM-dd 23:59:59")
        iEndTime = pubmisc.Str2Time(sEndTime)
        sGoods = self.comboBoxInputRecord.currentText()

        dbuyInfo = pubmisc.CallManagerFunc("purchasemgr", "GetBuyInfoRecord",
                                           iBeginTime, iEndTime, sGoods)
        lstHead = ["日期", "类型", "商品", "进价", "数量", "备注", "双击删除"]
        self.tableWidgetInputRecord.setColumnCount(len(lstHead))
        self.tableWidgetInputRecord.setRowCount(len(dbuyInfo))
        self.tableWidgetInputRecord.setHorizontalHeaderLabels(lstHead)
        self.tableWidgetInputRecord.horizontalHeader().setSectionResizeMode(
            QtWidgets.QHeaderView.Stretch)
        iRow = iAllNum = fPrice = 0
        for iID, tBuyInfo in dbuyInfo.items():
            for iCol, xValue in enumerate(tBuyInfo):
                if iCol == 0:
                    xValue = pubmisc.Time2Str(tBuyInfo[iCol])
                item = QtWidgets.QTableWidgetItem(str(xValue))
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                self.tableWidgetInputRecord.setItem(iRow, iCol, item)

            icon = QtGui.QIcon(QtGui.QPixmap("image/main.ico"))
            item = QtWidgets.QTableWidgetItem(icon, str(iID))
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetInputRecord.setItem(iRow, iCol + 1, item)

            iRow += 1
            iAllNum += tBuyInfo[4]
            fPrice += tBuyInfo[3] * tBuyInfo[4]

        self.labelNum.setText("总进货数量: %s" % iAllNum)
        self.labelAmount.setText("总进货金额: %s" % fPrice)
        self.labelNum.show()
        self.labelAmount.show()
Exemplo n.º 5
0
    def QueryProfile(self):
        """查询利润"""
        oBeginDate = self.dateEditBegin.date()
        sBeginTime = oBeginDate.toString("yyyy-MM-dd 00:00:00")
        iBeginTime = pubmisc.Str2Time(sBeginTime)
        oEndDate = self.dateEditEnd.date()
        sEndTime = oEndDate.toString("yyyy-MM-dd 23:59:59")
        iEndTime = pubmisc.Str2Time(sEndTime)
        self.MaxProfileCol = 0
        dSellInfo = pubmisc.CallManagerFunc("shippingmgr", "GetSellInfo",
                                            iBeginTime, iEndTime)
        self.ProfileInfo = {}
        for _, tSellInfo in dSellInfo.items():
            iTime, sGoods, _, fSellPrice, iNum, __ = tSellInfo
            sTime = pubmisc.Time2Str(iTime)
            fBuyPrice = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsBuyPrice",
                                                sGoods)
            fProfile = (fSellPrice - fBuyPrice) * iNum

            sDayTime = sTime[:10]
            sMonthTime = sTime[:7]
            sYearTime = sTime[:4]
            self.AddProfile(sGoods, sDayTime, fProfile)
            self.AddProfile(sGoods, sMonthTime + "月", fProfile)
            self.AddProfile(sGoods, sYearTime + "年", fProfile)
            self.AddProfile(sGoods, "总利润", fProfile)

        iGoodsNum = len(self.ProfileInfo)
        self.tableWidgetProfile.setRowCount(iGoodsNum)

        lstTime = [
            "总利润",
        ]
        sLastYear = ""
        while oBeginDate.toString("yyyy-MM") <= oEndDate.toString("yyyy-MM"):
            sCurYear = oBeginDate.toString("yyyy")
            if sLastYear != sCurYear:
                lstTime.append(sCurYear + "年")
                sLastYear = sCurYear
            lstTime.append(oBeginDate.toString("yyyy-MM") + "月")
            oBeginDate = oBeginDate.addMonths(1)

        self.tableWidgetProfile.setColumnCount(len(lstTime) + 1)

        lstGoods = [sGoods for sGoods in self.ProfileInfo]

        lstTitle = lstTime[:]
        lstTitle.insert(0, "商品")
        self.tableWidgetProfile.setHorizontalHeaderLabels(lstTitle)
        # if len(lstTitle) < 14:
        #     self.tableWidgetProfile.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)

        for iRow, sGoods in enumerate(lstGoods):
            item = QtWidgets.QTableWidgetItem(sGoods)
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetProfile.setItem(iRow, 0, item)
            for iCol, sTime in enumerate(lstTime):
                fProfile = self.GetProfileByDate(sGoods, sTime)
                item = QtWidgets.QTableWidgetItem(str(fProfile))
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                self.tableWidgetProfile.setItem(iRow, iCol + 1, item)