1 from datetime
import date
2 from com.sun.star.table
import CellRangeAddress
3 from com.sun.star.sheet.GeneralFunction
import MAX
10 import LeenoDialogs
as DLG
13 import LeenoBasicBridge
23 Controlla che non ci siano atti contabili registrati e dà il consenso a procedere.
24 Ritorna True se il consenso è stato dato, False altrimenti
28 if oSheet.Name !=
'CONTABILITA':
32 if partenza[2] ==
'#reg':
34 Title=
"Voce già registrata",
35 Text=
"Lavorando in questo punto del foglio,\n"
36 "comprometterai la validità degli atti contabili già emessi.\n\n"
38 "SCEGLIENDO SI' SARAI COSTRETTO A RIGENERARLI!"
52 Inserisce una nuova voce in CONTABILITA.
60 stile = oSheet.getCellByPosition(0, lrow).CellStyle
62 if stile ==
'comp Int_colonna_R_prima':
64 elif stile ==
'Ultimus_centro_bordi_lati':
67 if oSheet.getCellByPosition(23, i).Value != 0:
68 nSal = int(oSheet.getCellByPosition(23, i).Value)
71 while oSheet.getCellByPosition(0, lrow).CellStyle == stile:
73 if oSheet.getCellByPosition(0, lrow).CellStyle ==
'uuuuu':
77 elif stile ==
'Comp TOTALI':
79 elif stile
in stili_contab:
81 nSal = int(oSheet.getCellByPosition(23, sStRange.RangeAddress.StartRow + 1).Value)
87 oSheetto = oDoc.getSheets().getByName(
'S5')
88 oRangeAddress = oSheetto.getCellRangeByPosition(0, 22, 48, 26).getRangeAddress()
89 oCellAddress = oSheet.getCellByPosition(0, lrow).getCellAddress()
91 oSheet.getRows().insertByIndex(lrow, 5)
92 oSheet.copyRange(oCellAddress, oRangeAddress)
93 oSheet.getCellRangeByPosition(0, lrow, 48, lrow + 5).Rows.OptimalHeight =
True
99 sopra = sStRange.RangeAddress.StartRow
100 for n
in reversed(range(0, sopra)):
101 if oSheet.getCellByPosition(1, n).CellStyle ==
'Ultimus_centro_bordi_lati':
103 if oSheet.getCellByPosition(1, n).CellStyle ==
'Data_bianca':
104 data = oSheet.getCellByPosition(1, n).Value
107 oSheet.getCellByPosition(1, sopra + 2).Value = data
109 oSheet.getCellByPosition(1, sopra + 2).Value = date.today().toordinal() - 693594
112 iSheet = oSheet.RangeAddress.Sheet
113 oCellRangeAddr = CellRangeAddress()
114 oCellRangeAddr.Sheet = iSheet
115 oCellRangeAddr.StartColumn = 0
116 oCellRangeAddr.EndColumn = 0
117 oCellRangeAddr.StartRow = lrow + 2
118 oCellRangeAddr.EndRow = lrow + 2
119 oSheet.group(oCellRangeAddr, 1)
122 if oDoc.NamedRanges.hasByName(
'_Lib_' + str(nSal)):
123 if lrow - 1 == oSheet.getCellRangeByName(
'_Lib_' + str(nSal)).getRangeAddress().EndRow:
126 oSheet.getCellByPosition(23, sopra + 1).Value = nSal
127 oSheet.getCellByPosition(23, sopra + 1).CellStyle =
'Sal'
129 oSheet.getCellByPosition(35, sopra + 4).Formula =
'=B' + str(sopra + 2)
130 oSheet.getCellByPosition(36, sopra +4).Formula = (
131 '=IF(ISERROR(P' + str(sopra + 5) +
');"";IF(P' +
132 str(sopra + 5) +
'<>"";P' + str(sopra + 5) +
';""))')
133 oSheet.getCellByPosition(36, sopra + 4).CellStyle =
"comp -controolo"
138 @@@@ NOTA BENE : QUESTA PARTE È PER L'USO INTERATTIVO
139 VEDIAMO CHE FARNE IN SEGUITO
140 if cfg.read('Generale', 'pesca_auto') == '1':
152 Questa operazione svuoterà il foglio CONTABILITA e cancellerà
153 tutti gli elaborati contabili generati fino a questo momento.
155 OPERAZIONE NON REVERSIBILE!
157 VUOI PROCEDERE UGUALMENTE?"""
159 Text= messaggio) == 1:
166 Ricrea il foglio di contabilità partendo da zero.
169 for n
in range(1, 20):
170 if oDoc.NamedRanges.hasByName(
'_Lib_' + str(n)):
171 oDoc.NamedRanges.removeByName(
'_Lib_' + str(n))
172 oDoc.NamedRanges.removeByName(
'_SAL_' + str(n))
173 oDoc.NamedRanges.removeByName(
'_Reg_' + str(n))
174 for el
in (
'Registro',
'SAL',
'CONTABILITA'):
175 if oDoc.Sheets.hasByName(el):
176 oDoc.Sheets.removeByName(el)
178 oDoc.Sheets.insertNewByName(
'CONTABILITA', 3)
179 PL.GotoSheet(
'CONTABILITA')
180 oSheet = oDoc.Sheets.getByName(
'CONTABILITA')
183 oSheet.getCellRangeByName(
'C1').String =
'CONTABILITA'
184 oSheet.getCellRangeByName(
'C1').CellStyle =
'comp Int_colonna'
185 oSheet.getCellRangeByName(
'C1').CellBackColor = 16757935
186 oSheet.getCellByPosition(0, 2).String =
'N.'
187 oSheet.getCellByPosition(1, 2).String =
'Articolo\nData'
188 oSheet.getCellByPosition(2, 2).String =
'LAVORAZIONI\nO PROVVISTE'
189 oSheet.getCellByPosition(5, 2).String =
'P.U.\nCoeff.'
190 oSheet.getCellByPosition(6, 2).String =
'Lung.'
191 oSheet.getCellByPosition(7, 2).String =
'Larg.'
192 oSheet.getCellByPosition(8, 2).String =
'Alt.\nPeso'
193 oSheet.getCellByPosition(9, 2).String =
'Quantità\nPositive'
194 oSheet.getCellByPosition(11, 2).String =
'Quantità\nNegative'
195 oSheet.getCellByPosition(13, 2).String =
'Prezzo\nunitario'
196 oSheet.getCellByPosition(15, 2).String =
'Importi'
197 oSheet.getCellByPosition(16, 2).String =
'Incidenza\nsul totale'
198 oSheet.getCellByPosition(17, 2).String =
'Sicurezza\ninclusa'
199 oSheet.getCellByPosition(18, 2).String =
'importo totale\nsenza errori'
200 oSheet.getCellByPosition(19, 2).String =
'Lib.\nN.'
201 oSheet.getCellByPosition(20, 2).String =
'Lib.\nP.'
202 oSheet.getCellByPosition(22, 2).String =
'flag'
203 oSheet.getCellByPosition(23, 2).String =
'SAL\nN.'
204 oSheet.getCellByPosition(25, 2).String =
'Importi\nSAL parziali'
205 oSheet.getCellByPosition(27, 2).String =
'Sicurezza\nunitaria'
206 oSheet.getCellByPosition(28, 2).String =
'Materiali\ne Noli €'
207 oSheet.getCellByPosition(29, 2).String =
'Incidenza\nMdO %'
208 oSheet.getCellByPosition(30, 2).String =
'Importo\nMdO'
209 oSheet.getCellByPosition(31, 2).String =
'Super Cat'
210 oSheet.getCellByPosition(32, 2).String =
'Cat'
211 oSheet.getCellByPosition(33, 2).String =
'Sub Cat'
214 oSheet.getCellByPosition(36, 2).String =
'Importi\nsenza errori'
215 oSheet.getCellByPosition(0, 2).Rows.Height = 800
217 oSheet.getCellRangeByPosition(0, 2, 36, 2).CellStyle =
'comp Int_colonna_R'
218 oSheet.getCellByPosition(0, 2).CellStyle =
'comp Int_colonna_R_prima'
219 oSheet.getCellByPosition(18, 2).CellStyle =
'COnt_noP'
220 oSheet.getCellRangeByPosition(0, 0, 0, 3).Rows.OptimalHeight =
True
222 oSheet.getCellRangeByPosition(0, 1, 36, 1).CellStyle =
'comp In testa'
223 oSheet.getCellByPosition(2, 1).String =
'QUESTA RIGA NON VIENE STAMPATA'
224 oSheet.getCellRangeByPosition(0, 1, 1, 1).merge(
True)
225 oSheet.getCellByPosition(13, 1).String =
'TOTALE:'
226 oSheet.getCellByPosition(20, 1).String =
'SAL SUCCESSIVO:'
228 oSheet.getCellByPosition(25, 1).Formula =
'=$P$2-SUBTOTAL(9;$P$2:$P$2)'
230 oSheet.getCellByPosition(15,
231 1).Formula =
'=SUBTOTAL(9;P3:P4)'
232 oSheet.getCellByPosition(0, 1).Formula =
'=AK2'
233 oSheet.getCellByPosition(
234 17, 1).Formula =
'=SUBTOTAL(9;R3:R4)'
236 oSheet.getCellByPosition(
237 28, 1).Formula =
'=SUBTOTAL(9;AC3:AC4)'
238 oSheet.getCellByPosition(29,
239 1).Formula =
'=AE2/Z2'
240 oSheet.getCellByPosition(29, 1).CellStyle =
'Comp TOTALI %'
241 oSheet.getCellByPosition(
242 30, 1).Formula =
'=SUBTOTAL(9;AE3:AE4)'
243 oSheet.getCellByPosition(
244 36, 1).Formula =
'=SUBTOTAL(9;AK3:AK4)'
247 oSheet.getCellByPosition(2, 3).String =
'T O T A L E'
248 oSheet.getCellByPosition(15,
249 3).Formula =
'=SUBTOTAL(9;P3:P4)'
250 oSheet.getCellByPosition(
251 17, 3).Formula =
'=SUBTOTAL(9;R3:R4)'
252 oSheet.getCellByPosition(
253 30, 3).Formula =
'=SUBTOTAL(9;AE3:AE4)'
254 oSheet.getCellRangeByPosition(0, 3, 36, 3).CellStyle =
'Comp TOTALI'
256 oSheet.getCellByPosition(0, 4).String =
'Fine Computo'
257 oSheet.getCellRangeByPosition(0, 4, 36, 4).CellStyle =
'Riga_rossa_Chiudi'
270 Mostra il foglio di contabilità, se presente
273 if oDoc.Sheets.hasByName(
'S1'):
274 oDoc.Sheets.getByName(
'S1').getCellByPosition(7, 327).Value = 1
275 if oDoc.Sheets.hasByName(
'CONTABILITA'):
276 oSheet = oDoc.Sheets.getByName(
'CONTABILITA')
293 Se presenti, attiva e visualizza le tabelle di contabilità
294 @@@ MODIFICA IN CORSO CON 'LeenoContab.generaContabilita'
298 if oDoc.Sheets.hasByName(
'S1'):
299 oDoc.Sheets.getByName(
'S1').getCellByPosition(7, 327).Value = 1
300 if oDoc.Sheets.hasByName(
'CONTABILITA'):
301 for el
in (
'Registro',
'SAL',
'CONTABILITA'):
302 if oDoc.Sheets.hasByName(el):
305 oDoc.Sheets.insertNewByName(
'CONTABILITA', 5)
307 PL.GotoSheet(
'CONTABILITA')
309 PL.GotoSheet(
'CONTABILITA')
317 Aggiunge/detrae rigo di PARTITA PROVVISORIA
320 oSheet = oDoc.CurrentController.ActiveSheet
321 if oSheet.Name !=
"CONTABILITA":
323 x = PL.LeggiPosizioneCorrente()[1]
324 if oSheet.getCellByPosition(0, x).CellStyle ==
'comp 10 s_R':
325 if oSheet.getCellByPosition(2, x).Type.value !=
'EMPTY':
328 oSheet.getCellByPosition(2, x).String = testo
329 oSheet.getCellRangeByPosition(2, x, 8, x).CellBackColor = 16777113
344 partita(
'SI DETRAE PARTITA PROVVISORIA')
350 Visualizza in modalità struttura i documenti contabili
353 oSheet = oDoc.CurrentController.ActiveSheet
355 oRanges = oDoc.NamedRanges
357 if oSheet.Name ==
'CONTABILITA':
360 elif oSheet.Name ==
'Registro':
363 elif oSheet.Name ==
'SAL':
367 for i
in range(1, 50):
369 oRange=oRanges.getByName(pref + str(i)).ReferredCells.RangeAddress
371 oSheet.group(oRange, 1)
372 oSheet.getCellRangeByPosition(0, oRange.StartRow,
373 11, oRange.EndRow).Rows.IsVisible =
False
376 oSheet.getCellRangeByPosition(0, oRange.StartRow,
377 11, oRange.EndRow).Rows.IsVisible =
True
378 PL._gotoCella(0, oRange.StartRow -1)
379 oDoc.CurrentController.setFirstVisibleRow(y)
385 if oSheet.Name ==
'CONTABILITA':
386 PL.struttura_ComputoM()
392 CONTABILITA' - Si ottiene una riga gialla con l'indicazione delle
393 voci di misurazione registrate ed un parziale dell'importo del SAL a
394 cui segue la visualizzazione in struttura delle voci registrate nel
395 Libretto delle Misure.
401 oSheet = oDoc.CurrentController.ActiveSheet
402 if oSheet.Name !=
'CONTABILITA':
405 oRanges = oDoc.NamedRanges
415 idxsal = int(cfg.read(
'Contabilita',
'idxsal'))
416 for i
in reversed(range(1, idxsal)):
417 if oRanges.hasByName(
"_Lib_" + str(i)) ==
True:
428 daVoce = int(oSheet.getCellByPosition(2, libretti[-1]
429 ).String.split(
'÷')[1]) + 1
432 oCellRange = oSheet.getCellRangeByPosition(0, 3, 0,
434 if daVoce >= int(oCellRange.computeFunction(MAX)):
436 Title =
'ATTENZIONE!',
437 Text=
'Tutte le voci di questo Libretto delle Misure\n'
438 'sono già registrate.')
441 nomearea=
"_Lib_" + str(nSal)
445 daVoce = PL.InputBox(str(daVoce),
"Registra Libretto, da voce n.")
454 primariga = sStRange.RangeAddress.StartRow
457 oCellRange = oSheet.getCellRangeByPosition(
459 aVoce = int(oCellRange.computeFunction(MAX))
461 aVoce = PL.InputBox(str(aVoce),
"Registra Libretto, a voce n.")
465 elif int(aVoce) < int(aVoce):
473 ultimariga = sStRange.RangeAddress.EndRow
475 progress =
Dialogs.Progress(Title=
'Generazione elaborato...', Text=
"Libretto delle Misure")
476 progress.setLimits(1, 6)
485 while i < ultimariga + 1:
487 SAL = (art, desc, um, quant, prezzo, importo)
503 for k, g
in itertools.groupby(sorted(SAL), operator.itemgetter(0,1,2)):
504 quant = sum(float(q[3])
for q
in g)
509 PL.comando (
'DeletePrintArea')
513 oSheet.getCellByPosition(25, ultimariga - 1).String =
"SAL n." + str(nSal)
514 oSheet.getCellByPosition(25, ultimariga).Formula = (
515 "=SUBTOTAL(9;P" + str(primariga + 1) +
":P" + str(ultimariga+1) +
")" )
516 oSheet.getCellByPosition(25, ultimariga).CellStyle =
"comp sotto Euro 3_R"
519 inizioFirme = ultimariga + 1
521 PL.MENU_firme_in_calce (inizioFirme)
522 fineFirme = inizioFirme + 10
525 area=
"$A$" + str(primariga + 1) +
":$AJ$" + str(fineFirme + 1)
533 oSheet.getCellRangeByPosition(0, inizioFirme, 32, fineFirme).CellStyle =
"Ultimus_centro_bordi_lati"
535 oSheet.getCellByPosition(2, inizioFirme + 1).CellStyle =
"Ultimus_destra"
537 oNamedRange=oRanges.getByName(nomearea).ReferredCells.RangeAddress
540 daRiga = oNamedRange.StartRow
541 aRiga = oNamedRange.EndRow
542 daColonna = oNamedRange.StartColumn
543 aColonna = oNamedRange.EndColumn
545 iSheet = oSheet.RangeAddress.Sheet
555 oTitles = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
556 oTitles.Sheet = iSheet
557 oTitles.StartColumn = 0
559 oTitles.EndColumn = 11
561 oSheet.setTitleRows(oTitles)
563 oNamedRange.EndColumn = 11
564 oSheet.setPrintAreas((oNamedRange,))
565 oSheet.setPrintTitleRows(
True)
567 oSheet.PageStyle =
"Page_Style_Libretto_Misure2"
572 oSheet.getCellRangeByPosition(daColonna, daRiga, 11, aRiga).CellBackColor = -1
576 for i
in range(0, 50):
577 oSheet.getRows().insertByIndex(fineFirme, 1)
578 oSheet.getCellByPosition(2, fineFirme).String =
"===================="
580 if oSheet.getCellByPosition(1, fineFirme).Rows.IsStartOfNewPage ==
True:
582 oSheet.getRows().removeByIndex(fineFirme, 1)
587 oBordo = oSheet.getCellRangeByPosition(0, fineFirme, 32, fineFirme)
588 bordo = oBordo.BottomBorder
590 bordo.OuterLineWidth = 2
591 oBordo.BottomBorder = bordo
599 inumPag = 1 + old_nPage
604 oS2 = oDoc.getSheets().getByName(
'S2')
610 oS2.getCellByPosition(yS2 + nSal, xS2 + 1).Value = nSal
611 oS2.getCellByPosition(yS2 + nSal, xS2 + 2).Value = date.today().toordinal() - 693594
612 oS2.getCellByPosition(yS2 + nSal, xS2 + 24).Value = aVoce
613 oS2.getCellByPosition(yS2 + nSal, xS2 + 25).Value = inumPag
620 for i
in range(primariga, fineFirme):
621 if oSheet.getCellByPosition(1, i).CellStyle ==
"comp Art-EP_R":
624 primariga = sStRange.RangeAddress.StartRow
625 oSheet.getCellByPosition(19, i).Value= nLib
626 oSheet.getCellByPosition(22, i).String =
"#reg"
627 oSheet.getCellByPosition(23, i).Value= nSal
629 for nPag
in range(0, len(oSheet.RowPageBreaks)):
630 if i < oSheet.RowPageBreaks[nPag].Position:
631 oSheet.getCellByPosition(20, i).Value = nPag
636 oSheet.getCellByPosition(20 , fineFirme).Value = nPag
637 oSheet.getCellByPosition(20 , fineFirme).CellStyle =
"num centro"
643 oSheet.getRows().insertByIndex(daRiga, 1)
644 oSheet.getCellRangeByPosition (0, daRiga, 36, daRiga).CellStyle =
"uuuuu"
647 oSheet.getCellByPosition(2, daRiga).String = (
648 "segue Libretto delle Misure n." + str(nSal) +
649 " - " + str(daVoce) +
"÷" + str(aVoce)
651 oSheet.getCellByPosition(20, daRiga).Value = nPag
652 oSheet.getCellByPosition(19, daRiga).Value= nLib
653 oSheet.getCellByPosition(23, daRiga).Value= nSal
654 oSheet.getCellByPosition(15, daRiga).Formula =(
655 "=SUBTOTAL(9;$P$" + str(primariga + 2) +
":$P$" + str(
656 ultimariga + 2) +
")"
658 oSheet.getCellByPosition(15, daRiga).CellStyle =
"comp sotto Euro 3_R"
659 oSheet.getCellByPosition(25, daRiga).Formula =(
660 "=SUBTOTAL(9;$P$" + str(primariga + 2) +
":$P$" + str(
661 ultimariga + 2) +
")"
663 oSheet.getCellByPosition(25, daRiga).CellStyle =
"comp sotto Euro 3_R"
666 oSheet.getCellByPosition(25, 2).Value = nSal
667 oSheet.getCellByPosition(25, 2).CellStyle =
"Menu_sfondo _input_grasBig"
668 oSheet.getCellByPosition(25, 1).Formula = (
669 "=$P$2-SUBTOTAL(9;$P$2:$P$" + str(ultimariga + 2) +
")"
672 PL._gotoCella(0, daRiga)
682 return nSal, daVoce, aVoce, primariga+1, ultimariga+1, datiSAL, sic, mdo
693 CONTABILITA' - genera un nuovo foglio 'Registro'. Si ottiene una riga
694 gialla con l'indicazione delle voci di misurazione registrate ed un
695 parziale dell'importo del SAL a cui segue la visualizzazione in
696 struttura delle relative voci registrate nel Libretto delle Misure.
701 nSal, daVoce, aVoce, primariga, ultimariga, datiSAL, sic, mdo =
GeneraLibretto(oDoc)
705 progress =
Dialogs.Progress(Title=
'Generazione elaborato...', Text=
"Registro di Contabilità")
706 progress.setLimits(1, 5)
712 oSheet = oDoc.Sheets.getByName(
"CONTABILITA")
715 while i < ultimariga:
717 REG = ((num + '\n' + art + '\n' + data), desc, Nlib, Plib, um,
718 quantP, quantN, prezzo, importo)
725 oDoc.getSheets().insertNewByName(
'Registro',5)
726 PL.GotoSheet(
'Registro')
727 oSheet = oDoc.Sheets.getByName(
'Registro')
730 oSheet.getCellRangeByPosition(0,0,9,0).CellStyle=
"An.1v-Att Start"
731 oSheet.getCellByPosition(0,0).String = (
"N. ord.\nArticolo\nData")
732 oSheet.getCellByPosition(1,0).String = (
"LAVORAZIONI\nE SOMMINISTRAZIONI")
733 oSheet.getCellByPosition(2,0).String = (
"Lib.\nN.")
734 oSheet.getCellByPosition(3,0).String = (
"Lib.\nP.")
735 oSheet.getCellByPosition(4,0).String = (
"U.M.")
736 oSheet.getCellByPosition(5,0).String = (
"Quantità\nPositive")
737 oSheet.getCellByPosition(6,0).String = (
"Quantità\nNegative")
738 oSheet.getCellByPosition(7,0).String = (
"Prezzo\nunitario")
739 oSheet.getCellByPosition(8,0).String = (
"Importo\ndebito")
740 oSheet.getCellByPosition(9,0).String = (
"Importo\npagamento")
743 oSheet.getCellByPosition(0,0).Columns.Width = 1600
744 oSheet.getCellByPosition(1,0).Columns.Width = 6600
745 oSheet.getCellByPosition(2,0).Columns.Width = 650
746 oSheet.getCellByPosition(3,0).Columns.Width = 650
747 oSheet.getCellByPosition(4,0).Columns.Width = 1000
748 oSheet.getCellByPosition(5,0).Columns.Width = 1600
749 oSheet.getCellByPosition(6,0).Columns.Width = 1600
750 oSheet.getCellByPosition(7,0).Columns.Width = 1400
751 oSheet.getCellByPosition(8,0).Columns.Width = 1950
752 oSheet.getCellByPosition(9,0).Columns.Width = 1950
758 PL.GotoSheet(
'Registro')
759 oSheet= oDoc.Sheets.getByName(
"Registro")
761 oRanges = oDoc.NamedRanges
762 oPrevRange = oRanges.getByName(
"_Reg_" + str(nSal - 1)).ReferredCells.RangeAddress
764 fRow = oPrevRange.StartRow
765 lRow = oPrevRange.EndRow
766 insRow = oPrevRange.EndRow + 1
774 oSheet.PageStyle =
'PageStyle_REGISTRO_A4'
777 lastRow = insRow + len(REG) -1
778 oRange = oSheet.getCellRangeByPosition(0, insRow, 8, lastRow)
783 oRange.setDataArray(reg)
788 oSheet.getCellRangeByPosition(0, insRow, 1, lastRow).CellStyle =
"List-stringa-sin"
789 oSheet.getCellRangeByPosition(2, insRow, 4, lastRow).CellStyle =
"List-num-centro"
790 oSheet.getCellRangeByPosition(5, insRow, 6, lastRow).CellStyle =
"comp 1a"
791 oSheet.getCellRangeByPosition(7, insRow, 9, lastRow).CellStyle =
"List-num-euro"
794 oSheet.getRows().insertByIndex(insRow, 1)
795 oSheet.getCellRangeByPosition (0, insRow, 9, insRow).CellStyle =
"uuuuu"
798 oSheet.getCellByPosition(1, insRow).String =
"segue Registro n." + str(nSal) +
" - " + str(daVoce) +
"÷" + str(aVoce)
799 oSheet.getCellByPosition(2, insRow).Value= nSal
800 oSheet.getCellByPosition(3, insRow).Value = REG[-1][3]
802 oSheet.getCellByPosition(8, insRow).Formula = (
803 "=SUBTOTAL(9;I" + str(insRow +2) +
":I" + str(lastRow +2) +
")")
804 oSheet.getCellByPosition(8, insRow).CellStyle =
"comp sotto Euro 3_R"
808 oSheet.getRows().insertByIndex(insRow, 1)
809 oSheet.getCellByPosition(1, insRow).String =
"R I P O R T O"
811 oSheet.getCellByPosition(8, insRow).Formula = (
812 '=IF(SUBTOTAL(9;$I$2:$I$' + str(insRow) +
')=0;"";SUBTOTAL(9;$I$2:$I$' + str(insRow))
814 oSheet.getCellByPosition(9, insRow).Formula = (
815 '=IF(SUBTOTAL(9;$J$2:$J$' + str(insRow) +
')=0;"";SUBTOTAL(9;$J$2:$J$' + str(insRow))
817 oSheet.getCellRangeByPosition (0, insRow, 9, insRow).CellStyle =
"Ultimus_Bordo_sotto"
820 oSheet.getRows().insertByIndex(insRow, 1)
822 oSheet.getCellByPosition(1, insRow).String =
"LAVORI A MISURA"
823 oSheet.getCellRangeByPosition(0, insRow, 9, insRow).CellStyle =
"Ultimus_centro_bordi_lati"
824 PL._gotoCella(1, insRow)
826 lastRow = insRow + len(REG)
828 inizioFirme = lastRow + 5
829 PL.MENU_firme_in_calce (inizioFirme)
830 fineFirme = inizioFirme + 18
835 area=
"$A$" + str(insRow) +
":$J$" + str(fineFirme + 1)
836 nomearea =
"_Reg_" + str(nSal)
839 oRanges = oDoc.NamedRanges
840 oNamedRange=oRanges.getByName(nomearea).ReferredCells.RangeAddress
848 iSheet = oSheet.RangeAddress.Sheet
851 oTitles = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
852 oTitles.Sheet = iSheet
857 oSheet.setTitleRows(oTitles)
859 oSheet.setPrintAreas((oNamedRange,))
860 oSheet.setPrintTitleRows(
True)
865 oSheet.getCellRangeByPosition(0, lastRow +1, 9, fineFirme).CellStyle =
"Ultimus_centro_bordi_lati"
868 oSheet.getCellByPosition(1, lastRow + 2).String =
"Parziale dei Lavori a Misura €"
869 oSheet.getCellByPosition(1, lastRow + 2).CellStyle =
"Ultimus_destra"
870 oSheet.getCellByPosition(8, lastRow + 2).Formula = (
871 '=SUBTOTAL(9;$I$2:$I$' + str(inizioFirme))
872 oSheet.getCellByPosition(8, lastRow + 2).CellStyle =
"Ultimus_destra_totali"
874 oSheet.getCellByPosition(1, lastRow + 4).String =
'Lavori a tutto il ' + PL.oggi() +
' - T O T A L E €'
875 oSheet.getCellByPosition(1, lastRow + 4).CellStyle =
"Ultimus_destra"
876 oSheet.getCellByPosition(8, lastRow + 4).Formula = (
877 '=SUBTOTAL(9;$I$2:$I$' + str(inizioFirme))
878 oSheet.getCellByPosition(8, lastRow + 4).CellStyle =
"Ultimus_destra_totali"
881 oSheet.getCellByPosition(1, lastRow + 6).CellStyle =
"Ultimus_destra"
882 oSheet.getCellByPosition(1, lastRow + 16).CellStyle =
"Ultimus_destra"
887 for i
in range(0, 50):
888 oSheet.getRows().insertByIndex(fineFirme, 1)
889 oSheet.getCellByPosition(1, fineFirme).String =
"===================="
891 if oSheet.getCellByPosition(1, fineFirme).Rows.IsStartOfNewPage ==
True:
893 oSheet.getRows().removeByIndex(fineFirme, 1)
896 oSheet.getCellByPosition(1,fineFirme).String =
"A R I P O R T A R E"
897 oSheet.getCellByPosition(8, fineFirme).Formula = (
898 '=IF(SUBTOTAL(9;$I$2:$I$' + str(inizioFirme) +
')=0;"";SUBTOTAL(9;$I$2:$I$' + str(inizioFirme))
899 oSheet.getCellByPosition(9, inizioFirme).Formula = (
900 '=IF(SUBTOTAL(9;$J$2:$J$' + str(inizioFirme) +
')=0;"";SUBTOTAL(9;$J$2:$J$' + str(inizioFirme))
901 oSheet.getCellRangeByPosition (0, fineFirme, 9, fineFirme).CellStyle =
"Ultimus_Bordo_sotto"
910 progress =
Dialogs.Progress(Title=
'Generazione elaborato...', Text=
"Registro di Contabilità")
911 progress.setLimits(1, 6)
917 oDoc.getSheets().insertNewByName(
'SAL',6)
919 oSheet = oDoc.Sheets.getByName(
'SAL')
922 oSheet.getCellRangeByPosition(0,0,6,0).CellStyle=
"An.1v-Att Start"
923 oSheet.getCellByPosition(0,0).String = (
"N. ord.\nArticolo")
924 oSheet.getCellByPosition(1,0).String = (
"LAVORAZIONI\nE SOMMINISTRAZIONI")
925 oSheet.getCellByPosition(2,0).String = (
"U.M.")
926 oSheet.getCellByPosition(3,0).String = (
"Quantità")
927 oSheet.getCellByPosition(4,0).String = (
"Prezzo\nunitario")
928 oSheet.getCellByPosition(5,0).String = (
"Importo")
929 oSheet.getCellByPosition(6,0).String = (
"Pagine")
931 oSheet.getCellByPosition(0,0).Columns.Width = 1600
932 oSheet.getCellByPosition(1,0).Columns.Width = 10100
933 oSheet.getCellByPosition(2,0).Columns.Width = 1500
934 oSheet.getCellByPosition(3,0).Columns.Width = 1800
935 oSheet.getCellByPosition(4,0).Columns.Width = 1400
936 oSheet.getCellByPosition(5,0).Columns.Width = 1900
937 oSheet.getCellByPosition(6,0).Columns.OptimalWidth =
True
938 oSheet.getCellByPosition(0, 2).Rows.OptimalHeight =
True
943 oSheet= oDoc.Sheets.getByName(
"SAL")
945 oRanges = oDoc.NamedRanges
946 oPrevRange = oRanges.getByName(
"_SAL_" + str(nSal - 1)).ReferredCells.RangeAddress
948 fRow = oPrevRange.StartRow
949 lRow = oPrevRange.EndRow
950 insRow = oPrevRange.EndRow + 1
952 oSheet.PageStyle =
'PageStyle_REGISTRO_A4'
957 lastRow = insRow + len(datiSAL) -1
958 oRange = oSheet.getCellRangeByPosition(0, insRow, 3, lastRow)
963 oRange.setDataArray(sal)
966 for x
in range(insRow, lastRow + 1):
967 formule.append([
'=VLOOKUP(A' + str(x + 1) +
';elenco_prezzi;5;FALSE())',
968 '=D' + str(x + 1) +
'*E' + str(x + 1)]
974 oSheet.getCellRangeByPosition(0, insRow, 1, lastRow).CellStyle =
"List-stringa-sin"
975 oSheet.getCellRangeByPosition(2, insRow, 2, lastRow).CellStyle =
"List-num-centro"
976 oSheet.getCellRangeByPosition(3, insRow, 3, lastRow).CellStyle =
"comp 1a"
977 oSheet.getCellRangeByPosition(4, insRow, 5, lastRow).CellStyle =
"List-num-euro"
980 oRange = oSheet.getCellRangeByPosition(4, insRow, 5, lastRow)
981 formule = tuple(formule)
982 oRange.setFormulaArray(formule)
985 for x
in range(insRow, lastRow + 1):
986 oSheet.getCellByPosition(4, x).Value = oSheet.getCellByPosition(4, x).Value
987 oSheet.getCellByPosition(0, x).String = str(nOrd) \
988 +
'\n' + oSheet.getCellByPosition(0, x).String
995 oSheet.getRows().insertByIndex(insRow, 1)
996 oSheet.getCellRangeByPosition (0, insRow, 9, insRow).CellStyle =
"uuuuu"
1000 oSheet.getCellByPosition(1, insRow).String =
"segue Stato di Avanzamento Lavori n." + str(nSal) +
" - " + str(daVoce) +
"÷" + str(aVoce)
1004 oSheet.getCellByPosition(5, insRow).Formula = (
1005 "=SUBTOTAL(9;$F$" + str(insRow +2) +
":F" + str(lastRow +2) +
")")
1006 oSheet.getCellByPosition(5, insRow).CellStyle =
"comp sotto Euro 3_R"
1008 lastRow = insRow + len(datiSAL)
1011 oSheet.getCellByPosition(1, lastRow + 2).String =
"Parziale dei Lavori a Misura €"
1012 oSheet.getCellByPosition(5, lastRow + 2).Formula = (
1013 '=SUBTOTAL(9;$F$' + str(insRow) +
':$F$' + str(lastRow + 2))
1014 rigaPsal = lastRow + 2
1016 oSheet.getCellByPosition(1, lastRow + 4).String =
'Lavori a tutto il ' + PL.oggi() +
' - T O T A L E €'
1017 oSheet.getCellByPosition(5, lastRow + 4).Formula = (
1018 '=SUBTOTAL(9;$F$' + str(insRow) +
':$F$' + str(lastRow + 2))
1020 progress.setValue(5)
1022 fineFirme = lastRow + 6
1023 for i
in range(0, 50):
1024 oSheet.getRows().insertByIndex(fineFirme, 1)
1025 oSheet.getCellByPosition(1, fineFirme).String =
"===================="
1030 if oSheet.getCellByPosition(1, fineFirme).Rows.IsStartOfNewPage ==
True:
1031 oDoc.CurrentController.select(oSheet.getCellByPosition(1, fineFirme))
1038 oSheet.getCellRangeByPosition(
1039 0, lastRow +1, 5, fineFirme).CellStyle =
"Ultimus_centro_bordi_lati"
1040 oSheet.getCellRangeByPosition (0, fineFirme, 5, fineFirme).CellStyle =
"comp Descr"
1041 oSheet.getCellByPosition(1, lastRow + 2).CellStyle =
"Ultimus_destra"
1042 oSheet.getCellByPosition(1, lastRow + 4).CellStyle =
"Ultimus_destra"
1043 oSheet.getCellByPosition(5, lastRow + 2).CellStyle =
"Ultimus_destra_totali"
1044 oSheet.getCellByPosition(5, lastRow + 4).CellStyle =
"Ultimus_destra_totali"
1046 lastRow = fineFirme + 1
1048 oSheet.getCellByPosition(1, lastRow + 1).String =
"R I E P I L O G O S A L"
1050 oSheet.getCellByPosition(1, lastRow + 3).String = (
"Appalto: a misura")
1051 oSheet.getCellByPosition(1, lastRow + 4).String = (
"Offerta: unico ribasso")
1053 oSheet.getCellByPosition(1, lastRow + 6).String = (
"Lavori a Misura €")
1054 oSheet.getCellByPosition(5, lastRow + 6).Formula =
"=$F$" + str(rigaPsal + 1)
1056 oSheet.getCellByPosition(1, lastRow + 7).String = (
"Di cui importo per la Sicurezza")
1057 oSheet.getCellByPosition(5, lastRow + 7).Value = - sic
1059 oSheet.getCellByPosition(1, lastRow + 8).String = (
"Di cui importo per la Manodopera")
1060 oSheet.getCellByPosition(5, lastRow + 8).Value = - mdo
1062 oSheet.getCellByPosition(1, lastRow + 9).String =
"Importo dei Lavori a Misura su cui applicare il ribasso"
1063 oSheet.getCellByPosition(5, lastRow + 9).Formula =
"=SUM(F" + str(lastRow + 7) +
":F" + str(lastRow + 9) +
")"
1065 oSheet.getCellByPosition(1, lastRow + 10).Formula = (
1066 '''=CONCATENATE("RIBASSO del ";TEXT($S2.$C$78*100;"#.##0,00");"%")''')
1067 oSheet.getCellByPosition(5, lastRow + 10).Formula =
"=-$F$" + str(lastRow + 10) +
"*$S2.$C$78"
1069 oSheet.getCellByPosition(1, lastRow + 11).String = (
"Importo per la Sicurezza")
1070 oSheet.getCellByPosition(5, lastRow + 11).Value = sic
1072 oSheet.getCellByPosition(1, lastRow + 12).String = (
"Importo per la Manodopera")
1073 oSheet.getCellByPosition(5, lastRow + 12).Value = mdo
1075 oSheet.getCellByPosition(1, lastRow + 13).String =
"PER I LAVORI A MISURA €"
1076 oSheet.getCellByPosition(5, lastRow + 13).Formula =
"=SUM($F$" + str(lastRow + 10) +
":$F$" + str(lastRow + 13) +
")"
1079 oSheet.getCellByPosition(1, lastRow + 15).String =
"T O T A L E €"
1080 oSheet.getCellByPosition(5, lastRow + 15).Formula =
"=SUM($F$" + str(lastRow + 10) +
":$F$" + str(lastRow + 13) +
")"
1082 progress.setValue(6)
1085 inizioFirme = lastRow + 17
1086 PL.MENU_firme_in_calce (inizioFirme)
1087 fineFirme = inizioFirme + 12
1089 oSheet.getCellRangeByPosition(
1090 0, lastRow, 5, fineFirme).CellStyle =
"Ultimus_centro_bordi_lati"
1091 oSheet.getCellByPosition(1, lastRow + 1).CellStyle =
"Ultimus_centro_Dsottolineato"
1092 oSheet.getCellRangeByPosition(1, lastRow + 3, 1, lastRow + 4).CellStyle =
"Ultimus_sx_italic"
1093 oSheet.getCellRangeByPosition (5, lastRow + 6,5, lastRow + 15).CellStyle =
"ULTIMUS"
1094 oSheet.getCellByPosition(1, lastRow + 6).CellStyle =
"Ultimus_sx_bold"
1095 oSheet.getCellRangeByPosition(1, lastRow + 7, 1, lastRow + 8).CellStyle =
"Ultimus_sx"
1096 oSheet.getCellByPosition(5, lastRow + 8).CellStyle =
"Ultimus_"
1097 oSheet.getCellRangeByPosition(1, lastRow + 9, 1, lastRow + 10).CellStyle =
"Ultimus_destra"
1098 oSheet.getCellRangeByPosition(1, lastRow + 11, 1, lastRow + 12).CellStyle =
"Ultimus_sx"
1099 oSheet.getCellByPosition(5, lastRow + 12).CellStyle =
"Ultimus_"
1100 oSheet.getCellRangeByPosition(1, lastRow + 13, 1, lastRow + 13).CellStyle =
"Ultimus_destra_bold"
1101 oSheet.getCellRangeByPosition(1, lastRow + 15, 1, lastRow + 15).CellStyle =
"Ultimus_destra_bold"
1102 oSheet.getCellByPosition(5, lastRow + 15).CellStyle =
"Ultimus_destra_totali"
1106 progress.setValue(7)
1109 for i
in range(0, 50):
1110 oSheet.getRows().insertByIndex(fineFirme, 1)
1111 oSheet.getCellByPosition(1, fineFirme).String =
"===================="
1113 if oSheet.getCellByPosition(1, fineFirme).Rows.IsStartOfNewPage ==
True:
1115 oSheet.getRows().removeByIndex(fineFirme, 1)
1118 oSheet.getCellRangeByPosition (0, fineFirme, 5, fineFirme).CellStyle =
"comp Descr"
1121 area=
"$A$" + str(insRow + 2) +
":$F$" + str(fineFirme + 1)
1122 nomearea =
"_SAL_" + str(nSal)
1125 oRanges = oDoc.NamedRanges
1126 oNamedRange=oRanges.getByName(nomearea).ReferredCells.RangeAddress
1129 iSheet = oSheet.RangeAddress.Sheet
1130 oTitles = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
1131 oTitles.Sheet = iSheet
1132 oTitles.StartRow = 0
1133 oSheet.setTitleRows(oTitles)
1134 oSheet.setPrintAreas((oNamedRange,))
1135 oSheet.setPrintTitleRows(
True)
1138 progress.setValue(8)
1152 oSheet = oDoc.CurrentController.ActiveSheet
1153 if oSheet.Name !=
"CONTABILITA":
1156 Text=
'Prima di procedere è consigliabile salvare il lavoro.\n\n'
1157 'Se continui, devi attendere il messaggio di procedura completata.\n'
1158 'Procedo senza salvare?') == 0:
1165 PL.GotoSheet(
'CONTABILITA')
1175 g_exportedScripts = GeneraAttiContabili