public JFrame createFrame() { SQLElement element = Configuration.getInstance().getDirectory().getElement("SAISIE_ACHAT"); ListeGestCommEltPanel panel = new ListeGestCommEltPanel(element); panel.setAddVisible(true); IListFrame frame = new IListFrame(panel); IListTotalPanel total = new IListTotalPanel( frame.getPanel().getListe(), Arrays.asList( element.getTable().getField("MONTANT_HT"), element.getTable().getField("MONTANT_TTC"))); GridBagConstraints c = new DefaultGridBagConstraints(); c.gridy = 3; c.weightx = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; frame.getPanel().add(total, c); // Date panel Map<IListe, SQLField> map = new HashMap<IListe, SQLField>(); map.put(frame.getPanel().getListe(), element.getTable().getField("DATE")); IListFilterDatePanel datePanel = new IListFilterDatePanel(map, IListFilterDatePanel.getDefaultMap()); c.gridy = 4; c.anchor = GridBagConstraints.CENTER; c.weighty = 0; datePanel.setFilterOnDefault(); frame.getPanel().add(datePanel, c); return frame; }
// Lettre la ligne passée en parametre private void actionLettrage(int[] rowIndex) { String codeLettre = this.codeLettrage.getText().trim(); List<SQLRow> rowsSelected = new ArrayList<SQLRow>(rowIndex.length); long solde = 0; for (int i = 0; i < rowIndex.length; i++) { int id = this.ecriturePanel.getListe().idFromIndex(rowIndex[i]); SQLRow row = this.tableEcr.getRow(id); rowsSelected.add(row); solde += ((Long) row.getObject("DEBIT")).longValue(); solde -= ((Long) row.getObject("CREDIT")).longValue(); } if (solde == 0) { for (SQLRow row2 : rowsSelected) { SQLRowValues rowVals = new SQLRowValues(this.tableEcr); // Lettrage // On lettre ou relettre la ligne avec le code saisi if (codeLettre.length() > 0) { // Si la ligne est en brouillard on valide le mouvement associé if (this.boxValidEcriture.isSelected() && (!row2.getBoolean("VALIDE"))) { EcritureSQLElement.validationEcritures(row2.getInt("ID_MOUVEMENT")); } rowVals.put("LETTRAGE", codeLettre); rowVals.put("DATE_LETTRAGE", this.dateLettrage.getDate()); try { rowVals.update(row2.getID()); } catch (SQLException e1) { e1.printStackTrace(); } } } // Mise à jour du code de lettrage SQLElement elt = Configuration.getInstance().getDirectory().getElement("NUMEROTATION_AUTO"); SQLRowValues rowVals = elt.getTable().getRow(2).createEmptyUpdateRow(); rowVals.put("CODE_LETTRAGE", codeLettre); try { rowVals.update(); } catch (SQLException e) { e.printStackTrace(); } this.codeLettrage.setText(NumerotationAutoSQLElement.getNextCodeLettrage()); this.model.updateTotauxCompte(); } }
@Override protected SQLRowValues createDefaults() { System.err.println("Create defaults"); setSiteEnabled(false, Type_Diff.DONNEUR_ORDRE); setSiteEnabled(false, Type_Diff.SITE); // Numero incremental auto final SQLRowValues rowVals = new SQLRowValues(getTable()); rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class)); // User // final SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase()); final SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL"); final int idUser = UserManager.getInstance().getCurrentUser().getId(); // // sel.addSelect(eltComm.getTable().getKey()); // sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser)); // final List<SQLRow> rowsComm = (List<SQLRow>) // Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new // SQLRowListRSH(eltComm.getTable())); SQLRow rowsComm = SQLBackgroundTableCache.getInstance() .getCacheForTable(eltComm.getTable()) .getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON")); if (rowsComm != null) { rowVals.put("ID_COMMERCIAL", rowsComm.getID()); } if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) { rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE); } else { SQLRowValues foreign = UndefinedRowValuesCache.getInstance().getDefaultRowValues(getTable()); if (foreign != null && !foreign.isUndefined()) { rowVals.put("ID_ETAT_DEVIS", foreign.getObject("ID_ETAT_DEVIS")); } else { rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE); } } rowVals.put("T_HT", Long.valueOf(0)); rowVals.put("T_TVA", Long.valueOf(0)); rowVals.put("T_SERVICE", Long.valueOf(0)); rowVals.put("T_TTC", Long.valueOf(0)); if (getTable().getFieldsName().contains("DATE_VALIDITE")) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, 1); rowVals.put("DATE_VALIDITE", cal.getTime()); } return rowVals; }
/** * Création d'un devis à partir d'un devis existant * * @param idDevis */ public void loadDevisExistant(final int idDevis) { final SQLElement devis = Configuration.getInstance().getDirectory().getElement("DEVIS"); final SQLElement devisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT"); // On duplique le devis if (idDevis > 1) { final SQLRow row = devis.getTable().getRow(idDevis); final SQLRowValues rowVals = new SQLRowValues(devis.getTable()); rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT")); rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class)); this.select(rowVals); } // On duplique les elements de devis final List<SQLRow> myListItem = devis.getTable().getRow(idDevis).getReferentRows(devisElt.getTable()); if (myListItem.size() != 0) { this.table.getModel().clearRows(); for (final SQLRow rowElt : myListItem) { final SQLRowValues rowVals = rowElt.createUpdateRow(); rowVals.clearPrimaryKeys(); this.table.getModel().addRow(rowVals); final int rowIndex = this.table.getModel().getRowCount() - 1; this.table.getModel().fireTableModelModified(rowIndex); } } else { this.table.getModel().clearRows(); } this.table.getModel().fireTableDataChanged(); this.table.repaint(); }
private ListPanelEcheancesClients(final SQLElement elem) { super(elem, new IListe(elem.getTableSource(true))); setListe(); }
public ExportPanel() { super(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.gridwidth = 4; this.add(new JLabelBold("Export des écritures comptables"), c); // Fichier de destination final JPanel panelFichier = new JPanel(new GridBagLayout()); final GridBagConstraints cFic = new DefaultGridBagConstraints(); cFic.insets.left = 0; cFic.insets.bottom = 0; cFic.gridx++; cFic.weightx = 1; panelFichier.add(this.textDestination, cFic); final JButton buttonChoose = new JButton("..."); cFic.gridx++; cFic.weightx = 0; cFic.fill = GridBagConstraints.NONE; panelFichier.add(buttonChoose, cFic); this.buttonGen.setEnabled(false); this.textDestination.setEditable(false); this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); buttonChoose.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final int answer = ExportPanel.this.fileChooser.showSaveDialog(ExportPanel.this); if (answer == JFileChooser.APPROVE_OPTION) { ExportPanel.this.textDestination.setText( ExportPanel.this.fileChooser.getSelectedFile().getAbsolutePath()); } ExportPanel.this.buttonGen.setEnabled(answer == JFileChooser.APPROVE_OPTION); } }); c.gridy++; c.gridx = 0; c.gridwidth = 1; this.add(new JLabel("Dossier de destination", SwingUtilities.RIGHT), c); c.gridx++; c.weightx = 1; c.gridwidth = 4; this.add(panelFichier, c); c.gridx = 0; c.gridwidth = 1; c.gridy++; c.weightx = 0; c.anchor = GridBagConstraints.EAST; this.add(new JLabel("Période du", SwingUtilities.RIGHT), c); c.gridx++; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; this.du = new JDate(true); this.add(this.du, c); c.gridx++; this.add(new JLabel("au"), c); c.gridx++; this.au = new JDate(true); this.add(this.au, c); this.boxExport.setSelected(true); c.gridy++; c.gridx = 0; c.gridwidth = 3; this.add(this.boxExport, c); final SQLElement elt = Configuration.getInstance().getDirectory().getElement(JournalSQLElement.class); final ComboSQLRequest comboRequest = elt.getComboRequest(true); comboRequest.setUndefLabel("Tous"); this.boxJournal.init(elt, comboRequest); c.gridy++; c.gridx = 0; c.weightx = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel("Ecritures du journal", SwingUtilities.RIGHT), c); c.gridx++; c.weightx = 1; c.gridwidth = 4; c.fill = GridBagConstraints.NONE; this.boxJournal.setValue(JournalSQLElement.VENTES); this.add(this.boxJournal, c); c.gridy++; c.gridx = 0; c.weightx = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel("Type d'export", SwingUtilities.RIGHT), c); c.gridx++; c.weightx = 1; c.gridwidth = 4; final JComboBox comboType = new JComboBox(ExportType.values()); comboType.setRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent( list, ((ExportType) value).getLabel(), index, isSelected, cellHasFocus); } }); c.fill = GridBagConstraints.NONE; comboType.setSelectedIndex(0); this.add(comboType, c); final JPanel p = new JPanel(new GridBagLayout()); GridBagConstraints c2 = new DefaultGridBagConstraints(); c2.gridx = 0; c2.weightx = 1; c2.gridwidth = GridBagConstraints.REMAINDER; c2.fill = GridBagConstraints.HORIZONTAL; p.add(new TitledSeparator("Option export relation expert", true), c2); c2.gridy++; c2.gridx = 0; c2.weightx = 0; c2.gridwidth = 3; c2.fill = GridBagConstraints.HORIZONTAL; p.add( new JLabel( "Formater les numéros de compte suivant le nombre de caractères suivants", SwingUtilities.RIGHT), c2); c2.gridx += 3; c2.weightx = 1; c2.gridwidth = 1; p.add(this.spinNbChar, c2); c2.gridy++; c2.gridx = 0; c2.weightx = 0; c2.gridwidth = 3; c2.fill = GridBagConstraints.HORIZONTAL; p.add( new JLabel("Limiter le nombre de caractéres des numéros compte à", SwingUtilities.RIGHT), c2); c2.gridx += 3; c2.weightx = 1; c2.gridwidth = 1; p.add(this.spinNbCharLimit, c2); c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; this.add(p, c); c.gridy++; c.weightx = 1; c.gridx = 0; c.gridwidth = 1; final JPanel panelButton = new JPanel(); panelButton.add(this.buttonGen); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.SOUTHEAST; c.weightx = 0; c.weighty = 1; this.add(panelButton, c); this.buttonGen.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { export((ExportType) comboType.getSelectedItem()); } }); p.setVisible(false); comboType.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { p.setVisible((ExportType) comboType.getSelectedItem() == ExportType.RelationExpert); } }); }
JPanel createAllOrderPanel() { final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT"); final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true); final List<RowAction> allowedActions = new ArrayList<RowAction>(); // Transfert vers facture PredicateRowAction bonAction = new PredicateRowAction( new AbstractAction() { public void actionPerformed(ActionEvent e) { transfertBonLivraisonClient(IListe.get(e).copySelectedRows()); } }, false, "sales.order.create.deliverynote"); // Transfert vers facture RowAction factureAction = new RowAction( new AbstractAction() { public void actionPerformed(ActionEvent e) { transfertFactureClient(IListe.get(e).copySelectedRows()); } }, false, "sales.order.create.invoice") { @Override public boolean enabledFor(List<SQLRowAccessor> selection) { if (selection.isEmpty()) { return false; } else if (selection.size() > 1) { return true; } else { BigDecimal d = getAvancement(selection.get(0)); return d.signum() == 0; } } }; // Transfert vers facture intermédiaire RowAction acompteAction = new RowAction( new AbstractAction("Créer une facture intermédiaire") { public void actionPerformed(ActionEvent e) { transfertAcompteClient(IListe.get(e).copySelectedRows()); } }, false, "sales.order.create.account") { BigDecimal cent = BigDecimal.ONE.movePointRight(2); @Override public boolean enabledFor(List<SQLRowAccessor> selection) { if (selection.isEmpty() || selection.size() > 1) { return false; } else { BigDecimal d = getAvancement(selection.get(0)); return NumberUtils.compare(d, cent) != 0; } } }; // Transfert vers facture solde RowAction soldeAction = new RowAction( new AbstractAction("Facturer le solde") { public void actionPerformed(ActionEvent e) { transfertSoldeClient(IListe.get(e).copySelectedRows()); } }, false, "sales.order.create.account.solde") { BigDecimal cent = BigDecimal.ONE.movePointRight(2); @Override public boolean enabledFor(List<SQLRowAccessor> selection) { if (selection.isEmpty() || selection.size() > 1) { return false; } else { BigDecimal d = getAvancement(selection.get(0)); return NumberUtils.compare(d, cent) != 0 && NumberUtils.compare(d, BigDecimal.ZERO) != 0; } } }; // Transfert vers commande PredicateRowAction cmdAction = new PredicateRowAction( new AbstractAction() { public void actionPerformed(ActionEvent e) { final int selectedId = IListe.get(e).getSelectedId(); ComptaPropsConfiguration.getInstanceCompta() .getNonInteractiveSQLExecutor() .execute( new Runnable() { @Override public void run() { final CommandeClientSQLElement elt = (CommandeClientSQLElement) Configuration.getInstance() .getDirectory() .getElement("COMMANDE_CLIENT"); elt.transfertCommande(selectedId); } }); } }, false, "sales.order.create.supplier.order"); cmdAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); allowedActions.add(bonAction); allowedActions.add(factureAction); allowedActions.add(acompteAction); allowedActions.add(soldeAction); allowedActions.add(cmdAction); this.colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) { @Override protected Object show_(SQLRowAccessor r) { return getAvancement(r); } @Override public Set<FieldPath> getPaths() { final Path p = new PathBuilder(eltCmd.getTable()) .addTable("TR_COMMANDE_CLIENT") .addTable("SAISIE_VENTE_FACTURE") .build(); return CollectionUtils.createSet(new FieldPath(p, "T_HT")); } }; tableSource.getColumns().add(this.colAvancement); this.colAvancement.setRenderer(new PercentTableCellRenderer()); final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions); return panel; }
private ListeAddPanel getPanel( final SQLElement eltCmd, final SQLTableModelSourceOnline tableSource, final List<RowAction> allowedActions) { final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource)) { @Override protected void createUI() { super.createUI(); this.btnMngr.setAdditional( this.buttonEffacer, new ITransformer<JButton, String>() { @Override public String transformChecked(JButton input) { SQLRowAccessor row = getListe().fetchSelectedRow(); BigDecimal b = getAvancement(row); if (b.signum() != 0) { return "Vous ne pouvez pas supprimer une commande facturée !"; } return null; } }); this.btnMngr.setAdditional( this.buttonModifier, new ITransformer<JButton, String>() { @Override public String transformChecked(JButton input) { SQLRowAccessor row = getListe().fetchSelectedRow(); BigDecimal b = getAvancement(row); if (b.signum() != 0) { return "Vous ne pouvez pas modifier une commande facturée !"; } return null; } }); } }; final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2); fields.add( Tuple2.create( panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")), IListTotalPanel.Type.SOMME)); fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC)); final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, null, "Total des commandes de la liste"); final GridBagConstraints c = new DefaultGridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.EAST; c.weightx = 1; c.gridy = 4; // Date panel final IListFilterDatePanel datePanel = new IListFilterDatePanel( panel.getListe(), eltCmd.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap()); panel .getListe() .addIListeActions( new MouseSheetXmlListeListener(CommandeClientXmlSheet.class) { @Override public List<RowAction> addToMenu() { return allowedActions; } }.getRowActions()); datePanel.setFilterOnDefault(); final JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); bottomPanel.setOpaque(false); final GridBagConstraints c2 = new DefaultGridBagConstraints(); c2.fill = GridBagConstraints.NONE; c2.weightx = 1; bottomPanel.add(datePanel, c2); c2.gridx++; c2.weightx = 0; c2.anchor = GridBagConstraints.EAST; bottomPanel.add(totalPanel, c2); panel.add(bottomPanel, c); return panel; }