Exemple #1
0
    def test_request(self):
        """
        python -m unittest tests.models.chantier.TestChantier.test_request
        """
        # Test list chantier
        l_chantier = Chantier.get_chantier(path=self.path)
        self.assertEqual(len(l_chantier), 1)
        self.assertEqual(l_chantier[0], 'Dassault aviation - chantier rafale')

        # Test from index instance method
        test_chantier = Chantier.from_index_({'chantier_id': 0},
                                             path=self.path)

        for k, v in self.d_init[0].items():
            if k not in [sch.name for sch in BaseModel.l_hfields]:
                self.assertEqual(test_chantier.__getattribute__(k), v)

        # Test from subindex instance method
        test_chantier = Chantier.from_subindex_(
            {
                'rs_client': 'Dassault aviation',
                'nom': 'chantier rafale'
            },
            path=self.path)

        for k, v in self.d_init[0].items():
            if k not in [sch.name for sch in BaseModel.l_hfields]:
                self.assertEqual(test_chantier.__getattribute__(k), v)
Exemple #2
0
def process_table(table_key):

    # Clean facile doc tmpdir
    clean_tmp_dir()

    # Create tmp dir
    driver = FileDriver('tmp_doc', '')
    tmpdir = driver.TempDir(create=True, prefix='tmp_doc_')

    if table_key == 'employe':
        full_path = driver.join(tmpdir.path, 'table_employe.xlsx')
        Employe.table_loading(full_path=full_path, type='excel')

    elif table_key == 'fournisseur':
        full_path = driver.join(tmpdir.path, 'table_fournisseur.xlsx')
        Fournisseur.table_loading(full_path=full_path, type='excel')

    elif table_key == 'client':
        full_path = driver.join(tmpdir.path, 'table_client.xlsx')
        Client.table_loading(full_path=full_path, type='excel')

    elif table_key == 'contact':
        full_path = driver.join(tmpdir.path, 'table_contact.xlsx')
        Contact.table_loading(full_path=full_path, type='excel')

    elif table_key == 'chantier':
        full_path = driver.join(tmpdir.path, 'table_chantier.xlsx')
        Chantier.table_loading(full_path=full_path, type='excel')

    elif table_key == 'affaire':
        full_path = driver.join(tmpdir.path, 'table_affaire.xlsx')
        FeuilleTravaux.table_loading(full_path=full_path, type='excel')

    elif table_key == 'devis':
        full_path = driver.join(tmpdir.path, 'table_devis.xlsx')
        Devis.table_loading(full_path=full_path, type='excel')

    elif table_key == 'facture':
        full_path = driver.join(tmpdir.path, 'table_facture.xlsx')
        Facture.table_loading(full_path=full_path, type='excel')

    elif table_key == 'commande':
        full_path = driver.join(tmpdir.path, 'table_commande.xlsx')
        Commande.table_loading(full_path=full_path, type='excel')

    elif table_key == 'heure':
        full_path = driver.join(tmpdir.path, 'table_heure.xlsx')
        Heure.table_loading(full_path=full_path, type='excel')

    else:
        raise ValueError('key not understood {}'.format(table_key))
    import time
    time.sleep(1)
    return full_path, tmpdir
Exemple #3
0
def build_table(table_key, reduced=True, load_jQuery=False, head_class="table-active"):

    if table_key == 'employe':
        df_table, d_footer, kwargs = Employe.table_loading(reduced=reduced)

    elif table_key == 'fournisseur':
        df_table, d_footer, kwargs = Fournisseur.table_loading(reduced=reduced)

    elif table_key == 'client':
        df_table, d_footer, kwargs = Client.table_loading(reduced=reduced)

    elif table_key == 'contact':
        df_table, d_footer, kwargs = Contact.table_loading(reduced=reduced)

    elif table_key == 'chantier':
        df_table, d_footer, kwargs = Chantier.table_loading(reduced=reduced)

    elif table_key == 'affaire':
        if reduced:
            df_table, d_footer, kwargs = Affaire.table_loading()
        else:
            df_table, d_footer, kwargs = FeuilleTravaux.table_loading()

    elif table_key == 'devis':
        df_table, d_footer, kwargs = Devis.table_loading(reduced=reduced)

    elif table_key == 'facture':
        df_table, d_footer, kwargs = Facture.table_loading(reduced=reduced)

    elif table_key == 'commande':
        df_table, d_footer, kwargs = Commande.table_loading(reduced=reduced)

    elif table_key == 'heure':
        df_table, d_footer, kwargs = Heure.table_loading(reduced=reduced)

    else:
        raise ValueError('key not understood {}'.format(table_key))

    table = html_table.Table(df_table.columns, 'overview-{}'.format(table_key), head_class=head_class,
                             load_jQuery=load_jQuery, **kwargs)

    html = table.render_table_from_pandas(df_table, d_footer=d_footer)

    return html
Exemple #4
0
 def list(id_, **kwlist):
     if id_ == 'responsable':
         return zip(Employe.get_employes(**{'categorie': 'charge affaire'}),
                    Employe.get_employes(**{'categorie': 'charge affaire'}))
     elif id_ == 'devis':
         return zip(Devis.get_devis(), Devis.get_devis())
     elif id_ == 'chantier':
         kwargs = kwlist.get('chantier', {})
         return Chantier.get_chantier(return_id=True, **kwargs)
     elif id_ == 'contact_chantier_client':
         return Contact.get_contact('client_chantier',
                                    return_id=True,
                                    **kwlist.get('contact', {}))
     elif id_ == 'contact_facturation_client':
         return Contact.get_contact('client_administration',
                                    return_id=True,
                                    **kwlist.get('contact', {}))
     elif id_ == 'contact_chantier_interne':
         return zip(Employe.get_employes(**{'categorie': 'chantier'}),
                    Employe.get_employes(**{'categorie': 'chantier'}))
     else:
         return []
Exemple #5
0
def build_form(table_key,
               request,
               deform_template_path,
               step=0,
               force_get=True,
               data={},
               validate=True,
               script=None,
               session=None):

    if 'index' in request.form.keys() and 'Ajouter' not in data.get(
            'action', ''):
        index = request.form['index']
    else:
        index = None

    if table_key == 'employe':
        d_form_data = Employe.form_loading(step, index, data)
        nb_step_form = Employe.nb_step_form

    elif table_key == 'fournisseur':
        d_form_data = Fournisseur.form_loading(step, index, data)
        nb_step_form = Fournisseur.nb_step_form

    elif table_key == 'client':
        d_form_data = Client.form_loading(step, index, data)
        nb_step_form = Client.nb_step_form

    elif table_key == 'contact':
        d_form_data = Contact.form_loading(step, index, data)
        nb_step_form = Contact.nb_step_form

    elif table_key == 'chantier':
        d_form_data = Chantier.form_loading(step, index, data)
        nb_step_form = Chantier.nb_step_form

    elif table_key == 'affaire':
        if index is None and 'secondaire' in data.get('action', ''):
            index = request.form['index']

        d_form_data = Affaire.form_loading(step, index, data)
        nb_step_form = Affaire.nb_step_form

    elif table_key == 'devis':
        d_form_data = Devis.form_loading(step, index, data)
        nb_step_form = Devis.nb_step_form

    elif table_key == 'facture':
        # Accountant Admin restriction on this form
        restricted = True
        if session is not None:
            if 'CADMIN' in session['rights'] or 'SADMIN' in session['rights']:
                restricted = False

        d_form_data = Facture.form_loading(step,
                                           index,
                                           data,
                                           restricted=restricted)
        nb_step_form = Facture.nb_step_form

    elif table_key == 'commande':
        d_form_data = Commande.form_loading(step, index, data)
        nb_step_form = Commande.nb_step_form

    elif table_key == 'heure':
        d_form_data = Heure.form_loading(step, index, data)
        nb_step_form = Heure.nb_step_form

    else:
        raise ValueError('key not understood {}'.format(table_key))

    web, data = mutlistep.MultipleStepForm(request, deform_template_path, step, nb_step_form, **d_form_data)\
        .process_form(force_get=force_get, validate=validate, d_format=d_form_data['formatting'], script=script)

    return web, data
Exemple #6
0
def process_form(table_key, d_data, action):

    # Code to download document at the completion of some form (Devis, Affaire, ...)
    script = u'$.ajax({method: "POST", url: "/url_success_form", data: {"table_key": %s, "index": %s}})' \
             u'.done(function (response, status, request) {alert(%s %s);});'

    if table_key in ['affaire', 'devis', 'facture', 'commande'
                     ] and 'Suprimer' not in action:
        script = u'$.ajax({method: "POST", url: "/url_success_form", data: {"table_key": %s, "index": %s}})' \
                 u'.done(function (response, status, request) { alert(%s %s);' \
                 u'var url = response["url"].concat(response["data"]);' \
                 u'window.location = url});'

    if table_key == 'employe':
        l_index, l_fields = Employe.l_index, Employe.l_fields()
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Employe,
                                      action,
                                      d_data=d_data,
                                      table_key=table_key)

    elif table_key == 'fournisseur':
        l_index, l_fields = Fournisseur.l_index, Fournisseur.l_fields()
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Fournisseur,
                                      action,
                                      d_data=d_data,
                                      table_key=table_key)

    elif table_key == 'client':
        l_index, l_fields = Client.l_index, Client.l_fields()
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Client,
                                      action,
                                      d_data=d_data,
                                      table_key=table_key)

    elif table_key == 'contact':
        l_index, l_fields = Contact.l_index, Contact.l_fields()
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Contact,
                                      action,
                                      d_data=d_data,
                                      table_key=table_key)

    elif table_key == 'chantier':
        l_index, l_fields = Chantier.l_index, Chantier.l_fields()
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Chantier,
                                      action,
                                      d_data=d_data,
                                      table_key=table_key)

    elif table_key == 'affaire':
        l_index, l_fields = Affaire.l_index, Affaire.l_fields()
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Affaire,
                                      action,
                                      d_data=d_data,
                                      table_key=table_key)

    elif table_key == 'devis':
        l_index, l_fields = Devis.l_index, [f for f in Devis.l_fields()]
        d_data['price'] = 0
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Devis,
                                      action,
                                      d_data,
                                      table_key=table_key)

    elif table_key == 'commande':

        # Create tmp dir
        driver = FileDriver('tmp_upload', '')
        tmpdir = driver.TempDir(create=True, prefix='tmp_upload_')

        # Create s3 ressources
        ressource = boto3.resource(
            's3',
            aws_access_key_id=d_sconfig['aws_access_key_id'],
            aws_secret_access_key=d_sconfig['aws_secret_access_key'])

        filename = ''.join(
            ['{}',
             mimetypes.guess_extension(d_data['details']['mimetype'])])
        d_files = {
            filename: {
                'f': d_data['details']['fp'],
                'bucket':
                ressource.Bucket(d_sconfig.get('bucket_name', 'lstcmd')),
                'tmpfile': FileDriver('', '').join(tmpdir.path, filename)
            }
        }

        l_index, l_fields = Commande.l_index, [f for f in Commande.l_fields()]
        d_data['montant_ttc'], d_data['montant_tva'] = 0, 0
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Commande,
                                      action,
                                      d_data,
                                      table_key=table_key,
                                      d_files=d_files)

    elif table_key == 'facture':
        l_index, l_fields = Facture.l_index, [f for f in Facture.l_fields()]
        d_data['montant_ttc'], d_data['montant_tva'] = 0, 0
        statue = generic_process_form(l_index,
                                      l_fields,
                                      Facture,
                                      action,
                                      d_data,
                                      table_key=table_key)

    elif table_key == 'heure':
        l_index, l_fields, statue = Heure.l_index, Heure.l_fields(), {
            'success': True
        }

        # Load current database of hours
        df, l_hid = Heure.load_db(), []
        df = df.loc[df['semaine'] == d_data['index']]

        # Alter or add hours that have been sent
        for d_heure in d_data['heure']:
            d_data_ = {
                k: v
                for k, v in d_heure.items() +
                [('semaine', d_data['index']), ('index', d_data['index'])]
            }

            if d_heure['heure_id'] == l_index[0].sn.missing:
                statue = generic_process_form(l_index,
                                              l_fields,
                                              Heure,
                                              'Ajouter',
                                              d_data_,
                                              table_key=table_key)
            else:
                l_hid += [d_data_[l_index[0].name]]
                statue = generic_process_form(l_index,
                                              l_fields,
                                              Heure,
                                              'Modifier',
                                              d_data_,
                                              table_key=table_key)

        # Remove hours that have been deleted if any
        for hid in set(df.heure_id.values).difference(l_hid):
            d_data_ = {'index': d_data['index'], l_index[0].name: hid}
            statue = generic_process_form(l_index,
                                          l_fields,
                                          Heure,
                                          'Suprimer',
                                          d_data_,
                                          table_key=table_key)

        if 'success' in statue:
            statue.update({
                'data':
                (u'"{}"'.format(table_key), u'"{}"'.format(d_data['index']),
                 u'"{}: {}'.format(table_key, d_data['index']),
                 u' {} avec succes"'.format("edite"))
            })
    else:
        statue = {'error': u'Unknown table'}

    if 'success' not in statue:
        if statue['error'] == 'index':
            script = \
                u'alert("Erreur: l\'element {} existe dans la base. Modifier l\'element existant ou changer la valeur' \
                u' du champ {}");'.format(statue['index'], statue['index_name'])

        else:
            raise ValueError('{}'.format(statue))

    else:
        script = script % statue['data']
    return script
    def document_(index, path, driver, name='doc_fdt.docx'):
        df, _ = FeuilleTravaux.load_view()
        df = df.loc[df[[f.name for f in Affaire.l_index]].apply(
            lambda r: all([r[c] == index[c] for c in r.index]), axis=1)]

        # Load contact
        df_contact = Contact.load_db()

        # Load client
        df_client = Client.load_db()

        # Load chantier
        df_chantier = Chantier.load_db()

        word_document = WordDocument(path, driver, {'top_margin': 0.5})

        # Document title
        title = u'Feuille de travaux {}'.format('/'.join(
            df[FeuilleTravaux.l_main_index].values[0]))
        word_document.add_title(title,
                                font_size=15,
                                text_align='center',
                                color='000000')

        # CLIENT
        s_client = df_client.loc[
            df_client.designation ==
            df['designation_client_devis'].iloc[0]].iloc[0]

        word_document.add_title(u'Client',
                                font_size=12,
                                text_align='left',
                                color='000000')
        word_document.add_field(u'Désignation',
                                s_client['designation'],
                                left_indent=0.15)
        word_document.add_field(u'Raison sociale',
                                s_client['raison_social'],
                                left_indent=0.15)
        word_document.add_field(u'Division',
                                s_client['division'],
                                left_indent=0.15)

        word_document.add_field(u'Adresse',
                                value=u'{}, {} - {} {}'.format(
                                    s_client['adresse'], s_client['cs_bp'],
                                    s_client['code_postal'],
                                    s_client['ville']),
                                left_indent=0.15)
        s_contact = df_contact.loc[df_contact.contact_id ==
                                   df['contact_id_devis'].iloc[0]].iloc[0]
        word_document.add_field(u'Responsable commande',
                                u'{} ({})'.format(s_contact['contact_id'],
                                                  s_contact['contact']),
                                left_indent=0.15,
                                space_before=0.1)
        # DEVIS
        word_document.add_title(u'Devis',
                                font_size=12,
                                text_align='left',
                                color='000000')

        word_document.add_field(u'Numéro',
                                df['devis_id'].iloc[0],
                                left_indent=0.15)
        word_document.add_field(u'Objet',
                                df['object_devis'].iloc[0],
                                left_indent=0.15)
        word_document.add_field(u'Responsable devis',
                                df['responsable_devis'].iloc[0],
                                left_indent=0.15)
        word_document.add_field(u'Date de début',
                                df['date_start_devis'].iloc[0],
                                left_indent=0.15)
        word_document.add_field(u'Date de fin',
                                df['date_end_devis'].iloc[0],
                                left_indent=0.15)
        word_document.add_field(u'Montant total du devis',
                                u'{} euros'.format(df['price_devis'].iloc[0]),
                                left_indent=0.15)
        word_document.add_simple_paragraph(['Details'],
                                           space_before=0.06,
                                           space_after=0.06,
                                           left_indent=0.15,
                                           bold=True)

        l_values = [[
            df['heure_prod_devis'].iloc[0],
            df['prix_heure_prod_devis'].iloc[0],
            df['heure_autre_devis'].iloc[0],
            df['prix_heure_autre_devis'].iloc[0],
            df['montant_achat_devis'].iloc[0], df['coef_achat_devis'].iloc[0]
        ]]

        df_table = pd.DataFrame(l_values,
                                columns=[
                                    u'Heures Prod', u'Prix Heures Prod',
                                    u'Heures Autres', u'Prix Heures Autres',
                                    u'Montant achat', u'Coef achat'
                                ])

        word_document.add_table(df_table, index_column=-1, left_indent=0.15)

        # CHANTIER
        s_chantier = df_chantier.loc[df_chantier['chantier_id'] ==
                                     df['chantier_id'].iloc[0]].iloc[0]
        contact_client_ch = df['contact_chantier_client'].iloc[0]
        designation = df_contact.loc[df_contact.contact_id ==
                                     contact_client_ch, 'contact'].iloc[0]

        word_document.add_title(u'Chantier',
                                font_size=12,
                                text_align='left',
                                color='000000')
        word_document.add_field(u'Adresse',
                                u'{}, {} {}'.format(s_chantier['adresse'],
                                                    s_chantier['code_postal'],
                                                    s_chantier['ville']),
                                left_indent=0.15)
        word_document.add_field(u'Responsable interne',
                                df['contact_chantier_interne'].iloc[0],
                                left_indent=0.15)
        word_document.add_field(u'Responsable client',
                                u'{} ({})'.format(contact_client_ch,
                                                  designation),
                                left_indent=0.15)

        # SUIVI
        heure_prod = df['heure_prod_saisie'].sum(
        ) + df['heure_prod_saisie_interim'].sum()
        heure_autre = df['heure_autre_saisie'].sum(
        ) + df['heure_autre_saisie_interim'].sum()
        montant_achat = df['montant_total_commande'].sum()

        word_document.add_title('Suivi',
                                font_size=12,
                                text_align='left',
                                color='000000')

        l_values = [[u"REALISE", heure_prod, heure_autre, montant_achat],
                    [
                        u"ECART DEVIS",
                        heure_prod - df['heure_prod_devis'].sum(),
                        heure_autre - df['heure_autre_devis'].sum(),
                        montant_achat - df['montant_achat_devis'].sum()
                    ]]

        df_table = pd.DataFrame(
            l_values, columns=[' ', 'Heures prod', 'Heures autre', 'Achat'])

        word_document.add_table(df_table, index_column=0, left_indent=0.15)

        # FACTURATION
        s_contact = df_contact.loc[
            df_contact.contact_id ==
            df['contact_facturation_client'].iloc[0]].iloc[0]
        coord = u'{}, {} {} {}'.format(s_contact['adresse'],
                                       s_contact['cs_bp'],
                                       s_contact['code_postal'],
                                       s_contact['ville'])

        client = s_client['raison_social']
        if s_client['division']:
            client = ' - '.join([client, s_client['division']])

        word_document.add_title(u'Facturation',
                                font_size=12,
                                text_align='left',
                                color='000000')
        word_document.add_simple_paragraph(
            [client, s_contact['contact'], coord],
            break_run=True,
            space_before=0.06,
            alignment='center')

        l_values = [['Visa'] + [str('__/__/____')] * 6,
                    ['Encaissement'] + [str('__/__/____')] * 6]
        df_table = pd.DataFrame(l_values,
                                columns=['Situation'] +
                                ['{}'.format(i + 1) for i in range(6)])
        word_document.add_table(df_table, index_column=0, left_indent=0.15)

        l_values = [['Visa'] + [str('__/__/____')] * 6,
                    ['Encaissement'] + [str('__/__/____')] * 6]

        df_table = pd.DataFrame(l_values,
                                columns=['Situation'] +
                                ['{}'.format(i + 7) for i in range(6)])
        word_document.add_table(df_table, index_column=0, left_indent=0.15)

        # Save document
        word_document.save_document(name)
Exemple #8
0
    def test_basic(self):
        """
        python -m unittest tests.models.chantier.TestChantier.test_basic

        """
        # Add Fournisseur
        test_chantier = Chantier(self.d_index, self.d_data, path=self.path)
        test_chantier.add()

        # Assert new Fournisseur is in the database
        df = test_chantier.load_db(self.path)
        for k, v in self.d_subindex.items():
            df = df.loc[df[k] == v]
        self.assertTrue(not df.empty)

        # Make sure same Fournisseur can't added twice
        try:
            test_chantier = Chantier(self.d_index, self.d_data, path=self.path)
            test_chantier.add()
            self.assertTrue(False)
        except ValueError:
            self.assertTrue(True)

        # test alter Fournisseur
        test_chantier.code_postal = '09999'
        test_chantier.chantier_id = 1
        test_chantier.alter()

        # Assert record has bee changed in the database
        df = test_chantier.load_db(self.path)
        df = df.loc[df['chantier_id'] == 1]
        self.assertEqual(df.iloc[0]['code_postal'], '09999')

        # Assert deletion works
        test_chantier.delete()
        df = test_chantier.load_db(test_chantier.path)
        for k, v in self.d_index.items():
            df = df.loc[df[k] == v]
        self.assertTrue(df.empty)
Exemple #9
0
    def document_(index,
                  path,
                  driver=FileDriver('doc_fact', ''),
                  name='doc_fact.docx'):

        df = Achat.load_view()
        df = df.loc[df[Commande.l_index[0].name] == index[
            Commande.l_index[0].name]]

        df_contact = Contact.load_db()
        df_chantier = Chantier.load_db()

        word_document = WordDocument(path, driver, {})

        title = u'COMMANDE {}'.format(index[Commande.l_index[0].name])
        word_document.add_title(title,
                                font_size=15,
                                text_align='center',
                                color='000000')

        # Info affaire
        word_document.add_title(u'Détails Affaire',
                                font_size=12,
                                text_align='left',
                                color='000000',
                                space_before=1.)
        word_document.add_field(u"Numero d'affaire",
                                u'{}/{}'.format(df['affaire_num'].iloc[0],
                                                df['affaire_ind'].iloc[0]),
                                left_indent=0.15,
                                space_before=0.1)
        word_document.add_field(u'Désignation client',
                                df['designation_client'].iloc[0],
                                left_indent=0.15,
                                space_before=0.1)
        word_document.add_field(u'Objet du devis',
                                df['object'].iloc[0],
                                left_indent=0.15,
                                space_before=0.1)
        word_document.add_field(u'Montant achat devis',
                                df['responsable'].iloc[0],
                                left_indent=0.15,
                                space_before=0.1)
        word_document.add_field(u'Début du chantier',
                                df['date_start'].iloc[0],
                                left_indent=0.15,
                                space_before=0.1)
        word_document.add_field(u'Fin du chantier',
                                df['date_end'].iloc[0],
                                left_indent=0.15,
                                space_before=0.1)
        word_document.add_field(u'Base de prix',
                                df['base_prix'].iloc[0],
                                left_indent=0.15,
                                space_before=0.1)
        word_document.add_field(u'Responsable affaire',
                                df['responsable'].iloc[0],
                                left_indent=0.15,
                                space_before=0.1)

        # Info Chantier
        s_chantier = df_chantier.loc[df_chantier['chantier_id'] ==
                                     df['chantier_id'].iloc[0]].iloc[0]
        contact_client_ch = df['contact_chantier_client'].iloc[0]
        designation = df_contact.loc[df_contact.contact_id ==
                                     contact_client_ch, 'contact'].iloc[0]

        word_document.add_title(u'Info Chantier',
                                font_size=12,
                                text_align='left',
                                color='000000',
                                space_before=1.)
        word_document.add_field(u'Adresse',
                                u'{}, {} {}'.format(s_chantier['adresse'],
                                                    s_chantier['code_postal'],
                                                    s_chantier['ville']),
                                left_indent=0.15)
        word_document.add_field(u'Responsable chantier interne',
                                df['contact_chantier_interne'].iloc[0],
                                left_indent=0.15)
        word_document.add_field(u'Responsable chantier client',
                                u'{} ({})'.format(contact_client_ch,
                                                  designation),
                                left_indent=0.15)

        word_document.add_title(u'Info Commande',
                                font_size=12,
                                text_align='left',
                                color='000000',
                                space_before=1.)
        word_document.add_field(
            u'Montant Commande HT',
            u'{} Euros'.format(float(
                int(df['montant_ht'].iloc[0] * 100) / 100)),
            left_indent=0.15,
            space_before=0.1)

        # Save document
        word_document.save_document(name)