Esempio n. 1
0
    def update_ecriture(self):
        """ Update an ecriture"""

        data = {}
        data['compte_id'] = self.options.compte
        data['id'] = self.options.id
        if self.options.montant:
            data['montant'] = self.options.montant
        if self.options.type:
            data['type'] = self.options.type
        if self.options.dc and self.options.dc == "d":
            data['dc'] = -1
        elif self.options.dc and  self.options.dc == "c":
            data['dc'] = 1
        if self.options.nom:
            data['nom'] = self.options.nom
        if self.options.description:
            data['description'] = self.options.description
        if self.options.date:
            if not re.match(r"^201[0-9]\/\d{1,2}\/\d{1,2}$", self.options.date):
                raise Exception("format non valide de date")
            data['date'] = self.options.date
        if self.options.categorie:
            data['categorie'] = self.options.categorie

        print data
        response = RequestServer.put_method("ecriture", dumps(data))
        print response
Esempio n. 2
0
    def split_ecriture(self):
        """ Update an ecriture"""

        data = {}
        data['compte_id'] = self.options.compte
        data['id'] = self.options.id
        if not self.options.ec:
            response = RequestServer.get_method("ecriture",
                                                ecriture=data['id'],
                                                compte=data['compte_id'],
                                                filter={"sort": "ecriture_categorie",}
                                               )
            if response.status_code == 404:
                raise Exception("Impossible de trouver ecriture categorie")
            tmp_response = response.json()
            data['ecriture_categorie_id'] = tmp_response[0]["ecriture_categorie_id"]
        else:    
            data['ecriture_categorie_id'] = self.options.ec
        if not self.options.montant:
            raise Exception("Montant obligatoire")
        if not re.match(r"^\d+([\.,]\d{1,2})?$", self.options.montant):
            raise Exception("Erreur dans le montant")
        data['montant'] = self.options.montant
        if not self.options.categorie:
            raise Exception("Categorie obligatoire")
        if not re.match(r"^\d{1,2}$",self.options.categorie):
            raise Exception("Erreur de categorie")
        data['categorie'] = self.options.categorie

        print data
        response = RequestServer.put_method("split", dumps(data))
        print response
Esempio n. 3
0
 def update(self):
     """ update data by rest method """
     self.rqst = RequestServer.put_method(self.rest_method,
                                          self.filter,
                                          self.attribut
                                         )