コード例 #1
0
    def merma_Handle(self, inputs):
        item = int(inputs[Merma.code.name])
        storeDict = {}
        for column in DBProcess(Merma.Merma_tbl).getColumnDefinition:

            if column["name"] in [Merma.created.name] and column["name"] in inputs:
                jdate = general().date2julian(inputs[column["name"]])
                inputs[column["name"]] = jdate

            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(Merma.Merma_tbl).parse(column, inputs[column["name"]])

        self.session.query(Merma).filter_by(code=item).update(storeDict)
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        creator_profile = login().getProfile(inputs)

        user_rootlst = login().Get({User.usrtype.name: 74})["value"]

        url_merma="http://erpt.sugelico.com/?md=merma&merma="+str(item)
        bodymsg = "<h2>Productos mermados</h2>" \
                  "<p>" + \
                  " Colocado por el usuario: " + creator_profile["value"][0]["name"] \
                  + " Codigo del reverso: <a href='" + url_merma + "'>"+str(item)+"</a></p>"

        for user_root in user_rootlst:
            general().sendMail(user_root[User.username.name], bodymsg)
        return {"status": 200, "value": {Merma.code.name: item}, 'type': 'application/json'}
コード例 #2
0
    def addEquivalence(self, inputs):
        equivalence = 1
        if "equivalence" in inputs:
            equivalence = float(inputs["equivalence"])

        self.code = CodeGen().GenCode({"table": "Equivalence", "column": "code"})

        Equivalence(code=self.code, eq_name=inputs["eq_name"],
                    from_eq=int(inputs["from_eq"]), to_eq=int(inputs["to_eq"]),
                    equivalence=equivalence, optype="*",
                    created_by=login().decLoginKey(inputs["key"]),
                    created_date=general().date2julian()).save()

        self.reversecode = CodeGen().GenCode({"table": "Equivalence", "column": "code"})

        Equivalence(code=self.reversecode, eq_name=inputs["eq_name"]+"(Reverso)",
                    to_eq=int(inputs["from_eq"]), from_eq=int(inputs["to_eq"]),
                    equivalence=equivalence, optype="/",
                    created_by=login().decLoginKey(inputs["key"]),
                    created_date=general().date2julian()).save()

        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": {"code": self.code, "reversecode":self.reversecode}, 'type': 'application/json'}
コード例 #3
0
ファイル: TableArea.py プロジェクト: hidura/sugelico
 def setUserArea(self, inputs):
     # This method receive the
     # usertype: just the 73 user type will be the one
     # that can be added to a specific area, the 3 ones can access to any area,
     # if the user isn't a 73 will be ignored.
     # the usercode and the area.
     usertype = 0
     usercode = int(inputs["usercode"])
     if "usertype" in inputs:
         usertype = int(inputs["usertype"])
     else:
         usertype = login().getProfile(inputs)["value"]["type"]
     if usertype == 73:
         if UserArea.objects(user_code=usercode,
                             area=int(inputs["area"])).first() == None:
             UserArea(user_code=usercode, area=int(inputs["area"])).save()
     else:
         if usertype in [71, 74]:
             areaLst = self.session.query(Area)
         elif usertype in [72]:
             areaLst = self.session.query(Area).filter_by(status=11)
         for areas_info in areaLst:
             if UserArea.objects(user_code=usercode,
                                 area=areas_info.code).first() == None:
                 UserArea(user_code=usercode, area=areas_info.code).save()
     self.msg = {"msg": "Salvado"}
     self.session.close()
     self.connORM.dispose()
     return {"status": 200, "value": self.msg, 'type': 'application/json'}
コード例 #4
0
    def merma_Get(self, inputs):

        storeDict = self.session.query(Merma).filter_by(code = int(inputs["code"])).first()
        dataCol = []
        if storeDict!=None:
            dataDict ={Merma.merma_made.name:storeDict.merma_made,
                       Merma.code.name:storeDict.code,
                       Merma.description.name:storeDict.description,
                       Merma.created.name:general().julian2date(str(storeDict.created)),
                       Merma.created_by.name:login().getProfile({"usercode":storeDict.created_by})["value"]["name"]}

            productsMerma = MermaProd.objects(merma=storeDict.code)
            products = []
            for prodsInMerma in productsMerma:
                #MermaProd(code=mermaprod_code, product=product, amount=float(inputs["amount"]),
                #          merma=self.code).save()
                products.append({"code":prodsInMerma.mermaprod_code,
                                 "product_name":Items().Get({Item.code.name:prodsInMerma.product})
                                 ["value"][0][Item.item_name.name],
                                 "product":prodsInMerma.product, "amount":prodsInMerma.amount})
            dataDict["products"]=products
            dataCol.append(dataDict)

        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": dataCol, 'type': 'application/json'}
コード例 #5
0
    def create_merma(self, inputs):
        self.code = CodeGen().GenCode({"table": Merma.__tablename__, "column": Merma.code.name})
        # Generating the code.

        self.session.add(Merma(code=self.code, status=12,
                               created_by=login().decLoginKey(inputs["key"])))
        # Saving
        self.session.commit()
        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": {"code": self.code}, 'type': 'application/json'}
コード例 #6
0
ファイル: Categories.py プロジェクト: hidura/sugelico
    def getByUser(self, inputs):
        # This method gets the data, from the db.
        profile=login().getProfile({'key':inputs["user_code"]})["value"]
        storeDict = self.session.query(category, Status.description, company._name).\
            filter(Status.code == category.status,Type.code==category.cat_type).\
            filter(company.code == category.company).\
            filter(company.email ==profile["email"] )

        if category.code.name in inputs:
            storeDict = storeDict.filter(category.code == int(inputs[category.code.name]))

        if category.cat_type.name in inputs:
            storeDict = storeDict.filter(category.cat_type == int(inputs[category.cat_type.name]))

        if category.cat_name.name in inputs:
            storeDict = storeDict.filter(category.cat_name.ilike("%" + str(inputs[category.cat_name.name]) + "%"))


        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol = []
        for dataLst in storeDict:
            dicStore = {"status_name": dataLst._asdict()[Status.description.name],
                        "company_name":dataLst._asdict()[company._name.name]}

            for key in DBProcess(category.category_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[category.__name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.

                    dicStore[colname] = DBProcess(category.category_tbl).parse2publish(dataDict[colname])

            product_type = self.session.query(Type).filter_by(code=dicStore[category.type_product.name]).first()
            if product_type!=None:
                dicStore["product_type_name"] = product_type.tpname

            category_type = self.session.query(Type).filter_by(code=dicStore[category.cat_type.name]).first()
            if category_type != None:
                dicStore["categorytp_name"] = category_type.tpname
            if printer_reg.objects(name=dicStore["printer"]).first()!=None:
                dicStore["printer_id"]=printer_reg.objects(name=dicStore["printer"]).first().code
            dataCol.append(dicStore)
            # Appending everything to be returned
        if "wrap_to" in inputs:
            dataCol = General().WrapInfo(inputs, dataCol,
                                         [{category.code.name: "id"},
                                          {category.cat_name.name: "text"}])

        self.session.close()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
コード例 #7
0
    def modItem2Bill(self, inputs):
        self.code = CodeGen().GenCode({"table": "Buyitems", "column": "code"})

        Buyitems.objects(code=self.code).update(set__item=int(inputs["product"]),
                                                set__total_item=float(inputs["total"]), set__total_tax=float(inputs["tax"]),
                                                set__other_costs=float(inputs["other_costs"]),set__discount=float(inputs["discount"]),
                                                set__unit=int(inputs["unit"]), set__equivalence=float(inputs["equivalence"]),
                                                set__created_by=login().decLoginKey(inputs["key"]), set__created_date=general().date2julian())

        cur_amount = Items().Get({Item.code.name: inputs["product"]})["value"][0][Item.amount.name]
        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": {"code": self.code}, 'type': 'application/json'}
コード例 #8
0
    def addItem2Bill(self, inputs):
        self.code = CodeGen().GenCode({"table": "Buyitems", "column": "code"})
        equivalence = 1
        if "from_eq" in inputs:
            equivalence = int(str(inputs["from_eq"]).split(":")[0])
        unit = 517
        if "to_eq" in inputs:
            unit = int(inputs["to_eq"])

        amount = float(inputs["amount"])
        equivalence_data = Equivalence.objects(from_eq=unit, to_eq=equivalence)

        equivalence_info = equivalence_data.first()
        if equivalence_info!= None:
            if equivalence_info.optype == "*":
                amount = float(equivalence_info.equivalence) * float(inputs["amount"])
            if equivalence_info.optype == "/":
                amount = float(equivalence_info.equivalence) / float(inputs["amount"])


        Buyitems(code=self.code, product=int(inputs["product"]), amount=amount,
                 total=float(inputs["total"]), tax=float(inputs["total_tax"]),
                 bill=int(inputs["bill"]),unit=unit,term="",portion="",notes="",
                 created_by=login().decLoginKey(inputs["key"]),created_date=general().date2julian()).save()

        cur_amount = self.session.query(Item.amount).filter_by(code=int(inputs["product"])).first()[0]

        if cur_amount == None or cur_amount=='None':
            cur_amount = 0.00

        Items().Handle({Item.code.name: inputs["product"], Item.amount.name: float(cur_amount) + amount})

        warehouse_info = self.session.query(WareHouse).filter_by(mainwarehouse=True)
        warehouse_info = self.session.query(WareHouse).filter_by(mainwarehouse=True)
        if warehouse_info != None and "amount" in inputs:
            warehose = warehouse_info[0]
            connection = self.connORM.raw_connection()
            cursor = connection.cursor()

            cursor.callproc('products_movement', [self.code, amount,
                                                  warehose.code, 0])
            cursor.close()


        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": {"code":self.code}, 'type': 'application/json'}
コード例 #9
0
    def setDefault(self, codeHTML):
        if codeHTML.find("title") != None:
            codeHTML.find("title").string = "Sugelico Panel"
        sideBar = codeHTML.find(id="principal_menu")
        menu_lst = codeHTML.find(id="modules_section")

        menu = ""
        name = ""

        if "key" in self.inputs:
            key = login().decLoginKey(self.inputs["key"])
            if key != None:
                menuStr = login().getuserGroupModule(self.inputs)["value"]
                menuStr += "<a href='#' class='dropdown-item close_session' " \
                           "onClick='logout(this); return false;'>Cerrar Sesión</a>"
                menu = BeautifulSoup(menuStr)

                profile = login().getProfile(self.inputs)["value"]
                name = profile["name"]
                name_area = codeHTML.find(id="dropdownMenuButton")
                if name_area != None:
                    dataCol = login().getProfile(self.inputs)
                    name_area.string = str(dataCol["value"]["name"])
                if menu_lst != None:
                    menu_lst.\
                        append(BeautifulSoup(login().getuserModule(self.inputs)["value"]))# Adding the group of Modules
                if codeHTML.find(
                        id="module_name") != None and "group" in self.inputs:
                    group_info = Group_module.objects(code=int(
                        self.inputs["group"]),
                                                      status=11).first()
                    codeHTML.find(
                        id="module_name"
                    )["style"] = "width:100%;text-decoration: underline;"
                    codeHTML.find(id="module_name").string = group_info.name
        if sideBar != None:
            sideBar.append(menu)

        ##Looking for new messages
        msg_amount = codeHTML.find(id="msg_amount")
        if msg_amount != None:
            msg_amount.string = "0"
        dropdownmenu = codeHTML.find(id="dropmenu")
        if dropdownmenu != None:
            dropdownmenu.string = """<li><a href="#">Editar perfil<i class="pull-right icon-pencil"></i></a></li>
                            <li><a href="#">Cuenta<i class="pull-right icon-usd"></i></a></li>
                            <li><a href="#">Ayuda<i class="pull-right icon-question-sign"></i></a></li>
                            <li><a href="#">Tour<i class="pull-right icon-info-sign"></i></a></li>
                            <li class="divider"></li>
                            <li><a href="#" class="text-right">Salir del sistema</a></li>"""

        title_lst = codeHTML.find_all("title")
        for title in title_lst:
            if "-" in title.string:
                pageTitle = title.string.split("-")[1]
                title = codeHTML.find(id="panelPage")
                if title != None:
                    title.string = pageTitle
                subtitle = codeHTML.find(id="subtitle")
                if subtitle != None:
                    subtitle.string = pageTitle