Multi-tarif et suppression de ligne de document possible
[bilio:bilio.git] / document.rb
1 # coding: utf-8
2
3 class Document < Gtk::VBox
4
5         def initialize window
6         
7                 super(false, 3)
8                 
9                 set_border_width 10
10                 
11                 @window = window
12                 @db = window.db
13                 @login = window.login
14                 
15                 @id = 0
16                 @type = 0
17                 
18                 @ligne_modif_id = []
19                 @ligne_supp_id = []
20                 
21                 @imprimer = Gtk::Button.new Gtk::Stock::PRINT
22                 @valider = Gtk::Button.new Gtk::Stock::OK
23                 @annuler = Gtk::Button.new Gtk::Stock::CANCEL
24                 
25                 agencement
26                 
27                 @valider.signal_connect( "clicked" ) { validate }
28                 @annuler.signal_connect( "clicked" ) { quit }
29                 @imprimer.signal_connect( "clicked" ) { imprimer }
30         
31         end
32         
33         def agencement
34         
35                 vbox = Gtk::VBox.new false, 3
36                 @frame = Gtk::Frame.new
37                 @frame.label = "Nouveau document"
38                 vbox.pack_start( @frame, true, true, 3 )
39                 
40                 vbox_corps = Gtk::VBox.new false, 3
41                 @frame.add vbox_corps
42                 vbox_corps.pack_start( en_tete, false, false, 3 )
43                 vbox_corps.pack_start( lignes, true, true, 3 )
44                 vbox_corps.pack_start( pieds, false, false, 3 )
45                 
46                 hbox_button = Gtk::HBox.new false, 2
47                 hbox3 = Gtk::HBox.new false, 2
48                 align0 = Gtk::Alignment.new 0, 0, 0, 0
49                 align0.add @imprimer
50                 align1 = Gtk::Alignment.new 1, 1, 0, 0
51                 hbox3.pack_start( @annuler, true, true, 3 )
52                 hbox3.pack_start( @valider, true, true, 3 )
53                 align1.add hbox3
54                 hbox_button.add align0
55                 hbox_button.add align1
56                 
57                 vbox.pack_start( hbox_button, false, false, 3 )
58                 
59                 self.add vbox
60         
61         end
62
63         def en_tete
64         
65                 # Objets
66                 @client = Gtk::Entry.new
67                 @date_document = Gtk::Entry.new
68                 @date_livraison = Gtk::Entry.new
69                 @label_livraison = Gtk::Label.new "Date de livraison :"
70                 @note = Gtk::TextView.new
71                 @radio_comptant = Gtk::RadioButton.new "Tarif Comptant"
72                 @radio_credit = Gtk::RadioButton.new @radio_comptant, "Tarif Crédit"
73                 
74                 
75                 # Propriétés
76                 @radio_comptant.active = true
77                 
78                 # Agencement            
79                 table = Gtk::Table.new 6, 3, false
80                 
81                 table.attach( Gtk::Label.new("Client :"), 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5 )
82                 table.attach( @client, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
83                 table.attach( @radio_comptant, 2, 3, 0, 1, Gtk::FILL|Gtk::FILL, Gtk::FILL, 5, 5 )
84                 table.attach( @radio_credit, 3, 4, 0, 1, Gtk::FILL|Gtk::FILL, Gtk::FILL, 5, 5 )
85                 
86                 table.attach( Gtk::Label.new("Date du document :"), 4, 5, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5 )
87                 table.attach( @date_document, 5, 6, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5 )
88                 
89                 table.attach( @label_livraison, 2, 3, 2, 3, Gtk::FILL, Gtk::FILL, 5, 5 )
90                 table.attach( @date_livraison, 3, 4, 2, 3, Gtk::FILL, Gtk::FILL, 5, 5 )
91                 
92                 scroll_note = Gtk::ScrolledWindow.new
93                 scroll_note.add @note
94                 scroll_note.set_policy Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC
95                 scroll_note.shadow_type = Gtk::SHADOW_IN
96                 
97                 align_note = Gtk::Alignment.new 0, 0, 0, 0
98                 align_note.add Gtk::Label.new( "Note :" )
99                 
100                 table.attach( align_note, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 5, 5 )
101                 table.attach( scroll_note, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 5, 5 )
102                 
103                 table
104         
105         end
106         
107         def lignes
108         
109                 @article_store = Gtk::ListStore.new(String)
110                 refresh_code_article
111                 
112                 # list_store (id, id_document, id_article, code, designation, qtite, id_tva, colisage, pu, remise, total_ligne)
113                 @list_store = Gtk::ListStore.new(Integer, Integer, Integer, String, String, Integer, String, Integer, String, Integer, String)
114                 @view = Gtk::TreeView.new(@list_store)
115                 @view.signal_connect ("row-activated") { |view, path, column|
116                          #p @view.model.get_value(@view.selection.selected, 0)
117                 }
118                 
119                 # Create a renderer with the background property set
120                 renderer_center = Gtk::CellRendererText.new
121                 renderer_center.background = "white"
122                 renderer_center.xalign = 0.5
123                 renderer_center.mode = Gtk::CellRendererText::MODE_EDITABLE
124                 
125                 # Create a renderer with the background property set
126                 renderer_left = Gtk::CellRendererText.new
127                 renderer_left.xalign = 0
128                 renderer_left.mode = Gtk::CellRendererText::MODE_EDITABLE
129                 
130                 # Create a renderer with the background property set
131                 renderer_right = Gtk::CellRendererText.new
132                 renderer_right.xalign = 1
133                 renderer_right.mode = Gtk::CellRendererText::MODE_EDITABLE
134                 
135                 # Create a renderer with the background property set
136                 renderer_right_bold = Gtk::CellRendererText.new
137                 renderer_right_bold.xalign = 1
138                 renderer_right_bold.mode = Gtk::CellRendererText::MODE_EDITABLE
139                 renderer_right_bold.background = "#eee"
140                 
141                 # Colonne pour le code article :
142                 renderer_code = Gtk::CellRendererText.new
143                 renderer_code.xalign = 0
144                 renderer_code.mode = Gtk::CellRendererText::MODE_EDITABLE
145                 renderer_code.editable = true
146                 renderer_code.signal_connect('edited') { |combo, data, text|
147                         edit_cell(data, text, 3)
148                 }  
149                 col = Gtk::TreeViewColumn.new("Code article", renderer_code, :text => 3)
150                 col.resizable = true
151                 @view.append_column(col)
152                 
153                 # Colonne pour la quantité :
154                 renderer_designation = Gtk::CellRendererText.new
155                 renderer_designation.xalign = 0
156                 renderer_designation.mode = Gtk::CellRendererText::MODE_EDITABLE
157                 renderer_designation.editable = true
158                 renderer_designation.signal_connect('edited') { |combo, data, text|
159                         if !text.empty? then
160                                 search = Search.new @window, text
161                                 search.run { |response| 
162                                         if ( !search.liste.view.selection.selected.nil? ) then
163                                                 code = search.liste.view.model.get_value( search.liste.view.selection.selected, 1 )
164                                                 add_article code, true
165                                         end
166                                         search.destroy                  
167                                 }
168                         end
169                 }  
170                 col = Gtk::TreeViewColumn.new("Désignation", renderer_designation, :text => 4)
171                 col.resizable = true
172                 col.expand = true
173                 @view.append_column(col)
174                 
175                 # Colonne pour la quantité :
176                 renderer_qtite = Gtk::CellRendererSpin.new
177                 renderer_qtite.adjustment = Gtk::Adjustment.new(0, 0, 999999, 1, 10, 0)
178                 renderer_qtite.xalign = 1
179                 renderer_qtite.mode = Gtk::CellRendererText::MODE_EDITABLE
180                 renderer_qtite.editable = true
181                 renderer_qtite.signal_connect('edited') { |combo, data, text|
182                         edit_cell(data, text, 5)
183                 } 
184                 col = Gtk::TreeViewColumn.new("Quantité", renderer_qtite, :text => 5)
185                 #col.sort_column_id = 5
186                 col.resizable = true
187                 @view.append_column(col)
188                 
189                 col = Gtk::TreeViewColumn.new("Colisage", renderer_right, :text => 7)
190                 #col.sort_column_id = 7
191                 col.resizable = true
192                 @view.append_column(col)
193                 
194                 # Colonne pour le PU :
195                 renderer_pu = Gtk::CellRendererSpin.new
196                 renderer_pu.adjustment = Gtk::Adjustment.new(0, 0, 999999, 1, 10, 0)
197                 renderer_pu.digits = 2
198                 renderer_pu.xalign = 1
199                 renderer_pu.mode = Gtk::CellRendererText::MODE_EDITABLE
200                 renderer_pu.editable = true
201                 renderer_pu.signal_connect('edited') { |combo, data, text|
202                         edit_cell(data, text, 8)
203                 } 
204                 col = Gtk::TreeViewColumn.new("Prix unitaire", renderer_pu, :text => 8)
205                 #col.sort_column_id = 8
206                 col.resizable = true
207                 @view.append_column(col)
208                 
209                 # Colonne pour la remise :
210                 renderer_remise = Gtk::CellRendererSpin.new
211                 renderer_remise.adjustment = Gtk::Adjustment.new(0, 0, 100, 1, 10, 0)
212                 renderer_remise.xalign = 1
213                 renderer_remise.mode = Gtk::CellRendererText::MODE_EDITABLE
214                 renderer_remise.editable = true
215                 renderer_remise.signal_connect('edited') { |combo, data, text|
216                         edit_cell(data, text, 9)
217                 } 
218                 col = Gtk::TreeViewColumn.new("Remise %", renderer_remise, :text => 9)
219                 #col.sort_column_id = 9
220                 col.resizable = true
221                 @view.append_column(col)
222                 
223                 col = Gtk::TreeViewColumn.new("Total ligne", renderer_right_bold, :text => 10)
224                 #col.sort_column_id = 10
225                 col.resizable = true
226                 @view.append_column(col)
227                 
228                 col = Gtk::TreeViewColumn.new("TVA", renderer_center, :text => 6)
229                 #col.sort_column_id = 6
230                 col.resizable = true
231                 @view.append_column(col)
232                 
233                 scroll = Gtk::ScrolledWindow.new
234         scroll.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
235         scroll.add @view
236         
237         scroll
238         
239         end
240         
241         def pieds
242         
243                 @ht = Gtk::Entry.new
244                 @tva = Gtk::Entry.new
245                 @ttc = Gtk::Entry.new
246                 
247                 @ht.editable = false
248                 @ht.width_chars = 8
249                 @ht.xalign = 1
250                 @tva.editable = false
251                 @tva.width_chars = 8
252                 @tva.xalign = 1
253                 @ttc.editable = false
254                 @ttc.width_chars = 8
255                 @ttc.xalign = 1
256         
257                 align = Gtk::Alignment.new 1, 0, 0, 0
258                 
259                 table = Gtk::Table.new 3, 2, false
260                 align.add table
261                 
262                 table.attach( Gtk::Label.new("HT :"), 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 2, 2 )
263                 table.attach( @ht, 1, 2, 0, 1, Gtk::EXPAND, Gtk::FILL, 2, 2 )
264                 
265                 table.attach( Gtk::Label.new("TVA :"), 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 2, 2 )
266                 table.attach( @tva, 1, 2, 1, 2, Gtk::EXPAND, Gtk::FILL, 2, 2 )
267                 
268                 table.attach( Gtk::Label.new("TTC :"), 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 2, 2 )
269                 table.attach( @ttc, 1, 2, 2, 3, Gtk::EXPAND, Gtk::FILL, 2, 2 )
270                 
271                 align
272         
273         end
274         
275         def refresh id, type
276         
277                 @id = id
278                 @type = type
279                 
280                 @ligne_modif_id = []
281                 
282                 @date_livraison.sensitive = type.eql?(3)
283                 
284                 if id>0 then
285                         @frame.label = @window.type_doc[type] + " n° #{id}" 
286                         
287                         req = "SELECT * FROM documents WHERE id=#{id}"
288                         res = @db.requete req
289                         
290                         remplir_en_tete res
291                         
292                         req = "SELECT T0.id, T0.id_document, T0.id_article, T0.code, T0.designation, T0.qtite, T0.id_tva, T0.colisage, T0.pu, T0.remise, T0.total_ligne FROM documents_lignes T0 WHERE id_document=#{id} ORDER BY T0.id"
293                         res = @db.requete req
294                         
295                         remplir_lignes res
296                         
297                         remplir_pieds
298                 else
299                         case type
300                                 when 1, 3
301                                         @frame.label = "Nouveau "
302                                 when 5
303                                         @frame.label = "Nouvel "
304                                 else
305                                         @frame.label = "Nouvelle "
306                         end
307                 
308                         @frame.label += @window.type_doc[type].downcase 
309                         
310                         empty_component
311                         @list_store.append
312                 end
313         
314         end
315         
316         def refresh_code_article
317                 
318                 @article_store.clear
319                 
320                 res = @db.requete "SELECT * FROM articles LIMIT 100"
321                 
322                 res.each { |h| 
323                         
324                         iter = @article_store.append
325                         iter[0] = h['code']
326                 }
327
328         
329         end
330         
331         def remplir_en_tete res
332         
333                 date_document = ""
334                 date_livraison = ""
335                 res.each { |doc|
336                         @client.text = doc['client']
337                         date_document = doc['date_document']
338                         date_livraison = doc['date_livraison']
339                         @note.buffer.text = doc['note']
340                         @radio_credit.active = doc['tarif_id'].eql?("2")
341                         @radio_comptant.active = doc['tarif_id'].eql?("1")
342                 }
343                 @date_document.text = Date.parse(date_document).strftime("%d/%m/%Y")
344                 @date_livraison.text = Date.parse(date_livraison).strftime("%d/%m/%Y")
345         
346         end
347         
348         def remplir_lignes res
349         
350                 @list_store.clear
351                 
352                 res.each { |h| 
353                         
354                         iter = @list_store.append
355                         iter[0] = h['id'].to_i
356                         iter[1] = h['id_document'].to_i
357                         iter[2] = h['id_article'].to_i
358                         iter[3] = h['code']
359                         iter[4] = h['designation']
360                         iter[5] = h['qtite'].to_i
361                         iter[6] = "%.2f" % h['id_tva']
362                         iter[7] = h['colisage'].to_i
363                         iter[8] = "%.2f" % h['pu']
364                         iter[9] = h['remise'].to_i
365                         iter[10] = "%.2f €" % h['total_ligne']
366                 }
367                 
368                 @list_store.append
369
370         end
371         
372         def remplir_pieds
373                 
374                 ht = 0.0
375                 tva = 0.0
376         
377                 @list_store.each { |model, path, iter|
378                         ligne = @view.model.get_iter(path)
379                         ht += ligne[10].to_f unless ligne[10].nil?
380                         tva += ligne[10].to_f*(ligne[6].to_f/100) unless ligne[10].nil? or ligne[6].nil? 
381                 }
382                 
383                 ht = ht.round(2)
384                 tva = tva.round(2)
385                 
386                 @ht.text = "%.2f €" % ht
387                 @tva.text = "%.2f €" % tva
388                 @ttc.text = "%.2f €" % (ht+tva).round(2)
389                 
390         end
391         
392         def empty_component
393         
394                 @client.text = ""
395                 date = DateTime.now
396                 @date_document.text = date.strftime("%d/%m/%Y")
397                 date += 1
398                 @date_livraison.text = date.strftime("%d/%m/%Y")
399                 @note.buffer.text = ""
400                 
401                 @radio_comptant.active = true
402                 
403                 @list_store.clear
404                 
405                 @ht.text = "0 €"
406                 @tva.text = "0 €"
407                 @ttc.text = "0 €"
408         
409         end
410         
411         def edit_cell data, text, col
412         
413                 ligne = @view.model.get_iter(data)
414                 
415                 if !text.empty? then
416                         
417                         case col
418                         
419                                 when 3
420                                         # Changement du code article
421                                         add_article text                                        
422                                 when 4
423                                         ligne[col] = text
424                                 when 5
425                                         # Changement de quantité
426                                         ligne[col] = text.to_i
427                                         # On indique quels sont la ligne qui a été modifiée
428                                         @ligne_modif_id << ligne[0] unless @ligne_modif_id.include?(ligne[0])
429                                 when 8
430                                         ligne[col] = text if text.to_f>=0.0
431                                         # On indique quels sont la ligne qui a été modifiée
432                                         @ligne_modif_id << ligne[0] unless @ligne_modif_id.include?(ligne[0])
433                                 when 9
434                                         ligne[col] = text.to_i if (text.to_i>=0 and text.to_i<=100)
435                                         # On indique quels sont la ligne qui a été modifiée
436                                         @ligne_modif_id << ligne[0] unless @ligne_modif_id.include?(ligne[0])
437                         
438                         end             
439                 
440                 else
441                         # Suppresion de la ligne si le code article est vide
442                         suppr_article ligne if col.eql?(3)              
443                 end
444                 
445                 calcule_total_ligne ligne
446                 
447         end
448         
449         def add_article code, recalcule=false
450                 
451                 ligne = @view.selection.selected        
452                 tarif = (@radio_comptant.active? ? 1 : 2)
453                 
454                 req = "SELECT T0.id, T0.code, T0.gencode, T0.designation, T0.colisage, T0.id_tva, T1.tarif, T0.stock "
455                 req += " FROM articles T0 INNER JOIN articles_tarifs T1 ON T0.code=T1.code "
456                 req += " WHERE T1.tarif_id=#{tarif} "
457                 req += " AND T0.code='#{code}'"
458                 res = @db.requete req
459                 
460                 if res.count>0 then
461                         article = res.first
462                         
463                         @list_store.append if ligne[3].nil?
464                         ligne[3] = code
465                         ligne[2] = article['id'].to_i
466                         ligne[4] = article['designation']
467                         ligne[6] = "%.2f" % article['id_tva']
468                         ligne[7] = article['colisage'].to_i
469                         ligne[8] = "%.2f" % article['tarif']
470                         ligne[5] = 1 if ligne[5].eql?(0)
471                 
472                 end
473                 
474                 calcule_total_ligne ligne if recalcule
475                 
476                 # On indique quels sont les lignes qui ont été modifiées ou ajoutées
477                 id_ligne = @view.selection.selected[0]
478                 @ligne_modif_id << id_ligne unless @ligne_modif_id.include?(id_ligne)
479                 
480         end
481         
482         def suppr_article ligne
483         
484                 @ligne_supp_id << ligne[0].to_i if ligne[0].to_i>0
485                 ligne[0] = 0
486                 ligne[1] = 0
487                 ligne[2] = 0
488                 ligne[3] = ""
489                 ligne[4] = ""
490                 ligne[6] = ""
491                 ligne[7] = 1
492                 ligne[8] = ""
493                 ligne[5] = 0
494         
495         end
496         
497         def calcule_total_ligne ligne
498                 ligne[10] = "%.2f €" % ( ligne[5]*ligne[8].to_f*ligne[7]*( 1-ligne[9].to_f/100 ) ).round(2)
499                 remplir_pieds
500         end
501         
502         def imprimer
503                 validate
504                 Edition.new @db, @id            
505         end
506         
507         def validate quitter=true
508         
509                 date_document = Date.parse(@date_document.text).strftime("%Y-%m-%d")
510                 date_livraison =  Date.parse(@date_livraison.text).strftime("%Y-%m-%d")
511                 tarif = ( @radio_comptant.active? ? 1 : 2 )
512                         
513                 if @id>0 then
514                         req = "UPDATE documents SET "
515                         req += " client='#{@client.text.gsub("'", "''")}', date_document='#{date_document}', note='#{@note.buffer.text}', id_type_document=#{@type}, date_livraison='#{date_livraison}', tarif_id=#{tarif} "
516                         req += " WHERE id=#{@id}"
517                         
518                         if !@ligne_modif_id.empty? then
519                         
520                                 @list_store.each { |model, path, iter|
521                                         
522                                         id_ligne = @view.model.get_iter(path)[0]
523                                         
524                                         if ( @ligne_modif_id.include?(id_ligne) and !@view.model.get_iter(path)[3].nil? ) then
525                                         
526                                                 id_article = @view.model.get_iter(path)[2]
527                                                 code = @view.model.get_iter(path)[3].gsub("'", "''")
528                                                 designation = @view.model.get_iter(path)[4].gsub("'", "''")
529                                                 qtite = @view.model.get_iter(path)[5]
530                                                 id_tva = @view.model.get_iter(path)[6]
531                                                 colisage = @view.model.get_iter(path)[7]
532                                                 pu = @view.model.get_iter(path)[8]
533                                                 remise = @view.model.get_iter(path)[9]
534                                                 total_ligne = @view.model.get_iter(path)[10]
535                                                                 
536                                                 req_ligne = ""
537                                                 if ( !id_article.eql?(0) ) then
538                                                         if id_ligne.eql?(0) then
539                                                                 p "Insertion de ligne : #{id_article}"
540                                                                 req_ligne = "INSERT INTO documents_lignes (id_document, id_article, qtite, id_tva, colisage, pu, remise, code, designation, total_ligne) "
541                                                                 req_ligne += " VALUES (#{@id}, #{id_article}, #{qtite}, '#{id_tva}', #{colisage}, "
542                                                                 req_ligne += " '#{pu}', #{remise}, '#{code}', '#{designation}', '#{total_ligne.to_f}') "
543                                                         else
544                                                                 p "Modification de ligne : #{id_article}"
545                                                                 req_ligne = "UPDATE documents_lignes SET "
546                                                                 req_ligne += " id_article=#{id_article}, code='#{code}', designation='#{designation}', "
547                                                                 req_ligne += " qtite=#{qtite}, id_tva='#{id_tva}', colisage=#{colisage}, pu='#{pu}', remise=#{remise}, total_ligne='#{total_ligne.to_f}' "
548                                                                 req_ligne += " WHERE id=#{id_ligne} "
549                                                         end             
550                                                 end             
551                                                 
552                                                 res = @db.requete req_ligne unless req_ligne.empty? 
553                                         
554                                         end
555                                         
556                                 }                               
557                                                                 
558                         end
559                         
560                         @ligne_supp_id.each { |l|                               
561                                 req = "DELETE FROM documents_lignes WHERE id=#{l}"
562                                 @db.requete req
563                                 p "Suppresion de ligne : #{l}"
564                         }
565                         
566                 else                    
567                         p "Nouveau document"
568                                         
569                         req = "INSERT INTO documents (client, date_document, note, id_type_document, date_livraison, id_user, tarif_id)"
570                         req += " VALUES ('#{@client.text.gsub("'", "''")}', '#{date_document}', '#{@note.buffer.text}', #{@type}, '#{date_livraison}', '#{@login.user.id}', #{tarif})"
571                 end
572                 
573                 res = @db.requete req
574                 
575                 if (res.empty? and @id.eql?(0)) then
576                 
577                         req = "SELECT id FROM documents ORDER BY id DESC LIMIT 1"
578                         res = @db.requete req
579                         
580                         @id = res.first['id']
581                         
582                         @list_store.each { |model, path, iter|
583                                         
584                                 if !@view.model.get_iter(path)[3].nil? then
585                                         
586                                         id_ligne = @view.model.get_iter(path)[0]
587                                         id_article = @view.model.get_iter(path)[2]
588                                         code = @view.model.get_iter(path)[3].gsub("'", "''")
589                                         designation = @view.model.get_iter(path)[4].gsub("'", "''")
590                                         qtite = @view.model.get_iter(path)[5]
591                                         id_tva = @view.model.get_iter(path)[6]
592                                         colisage = @view.model.get_iter(path)[7]
593                                         pu = @view.model.get_iter(path)[8]
594                                         remise = @view.model.get_iter(path)[9]
595                                         total_ligne = @view.model.get_iter(path)[10]
596                                                         
597                                         p "Insertion de ligne"
598                                         req_ligne = "INSERT INTO documents_lignes (id_document, id_article, qtite, id_tva, colisage, pu, remise, code, designation, total_ligne) "
599                                         req_ligne += " VALUES (#{@id}, #{id_article}, #{qtite}, '#{id_tva}', #{colisage}, "
600                                         req_ligne += " '#{pu}', #{remise}, '#{code}', '#{designation}', '#{total_ligne.to_f}') "
601                                         res = @db.requete req_ligne if ( id_article>0)
602                                         
603                                 end
604                         }
605                 
606                 end
607                 
608                 quit @type if quitter
609         
610         end
611         
612         def quit statut=nil
613                 
614                 @window.liste_documents.refresh statut unless statut.nil?       
615                 @window.affiche @window.liste_documents
616         
617         end
618         
619 end