Line 22... |
Line 22... |
22 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
22 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
23 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
|
23 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
|
24 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
|
24 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
|
25 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
25 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
26 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
|
26 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
|
- |
|
27 |
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
|
27 |
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable;
|
28 |
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable;
|
28 |
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonItemSQLElement;
|
29 |
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonItemSQLElement;
|
29 |
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonSQLElement;
|
30 |
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonSQLElement;
|
30 |
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
|
31 |
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
|
31 |
import org.openconcerto.erp.core.sales.shipment.ui.BonDeLivraisonItemTable;
|
32 |
import org.openconcerto.erp.core.sales.shipment.ui.BonDeLivraisonItemTable;
|
Line 34... |
Line 35... |
34 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
35 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
35 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
36 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
36 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
37 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
37 |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
|
38 |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
|
38 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
39 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
- |
|
40 |
import org.openconcerto.erp.utils.TM;
|
39 |
import org.openconcerto.sql.Configuration;
|
41 |
import org.openconcerto.sql.Configuration;
|
40 |
import org.openconcerto.sql.element.SQLElement;
|
42 |
import org.openconcerto.sql.element.SQLElement;
|
41 |
import org.openconcerto.sql.model.SQLRow;
|
43 |
import org.openconcerto.sql.model.SQLRow;
|
42 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
44 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
43 |
import org.openconcerto.sql.model.SQLRowValues;
|
45 |
import org.openconcerto.sql.model.SQLRowValues;
|
Line 128... |
Line 130... |
128 |
}
|
130 |
}
|
129 |
if (getTable().contains("ID_TAXE_PORT")) {
|
131 |
if (getTable().contains("ID_TAXE_PORT")) {
|
130 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
132 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
131 |
rowVals.put("ID_TAXE_PORT", taxeDefault.getID());
|
133 |
rowVals.put("ID_TAXE_PORT", taxeDefault.getID());
|
132 |
}
|
134 |
}
|
- |
|
135 |
if (getTable().contains("ID_TAXE_FRAIS_DOCUMENT")) {
|
- |
|
136 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
- |
|
137 |
rowVals.put("ID_TAXE_FRAIS_DOCUMENT", taxeDefault.getID());
|
- |
|
138 |
}
|
133 |
return rowVals;
|
139 |
return rowVals;
|
134 |
}
|
140 |
}
|
135 |
|
141 |
|
136 |
public void addViews() {
|
142 |
public void addViews() {
|
137 |
this.textTotalHT.setOpaque(false);
|
143 |
this.textTotalHT.setOpaque(false);
|
Line 349... |
Line 355... |
349 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
355 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
350 |
|
356 |
|
351 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
357 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
352 |
int idClient = rowClient.getID();
|
358 |
int idClient = rowClient.getID();
|
353 |
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient));
|
359 |
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient));
|
- |
|
360 |
if (rowClient.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowClient.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
|
- |
|
361 |
tableBonItem.setRowCatComptable(rowClient.getForeign("ID_CATEGORIE_COMPTABLE"));
|
- |
|
362 |
} else {
|
- |
|
363 |
tableBonItem.setRowCatComptable(null);
|
- |
|
364 |
}
|
354 |
} else {
|
365 |
} else {
|
355 |
comboContact.getRequest().setWhere(Where.FALSE);
|
366 |
comboContact.getRequest().setWhere(Where.FALSE);
|
- |
|
367 |
tableBonItem.setRowCatComptable(null);
|
356 |
// DevisSQLComponent.this.table.setTarif(null, false);
|
368 |
// DevisSQLComponent.this.table.setTarif(null, false);
|
357 |
}
|
369 |
}
|
358 |
}
|
370 |
}
|
359 |
});
|
371 |
});
|
360 |
|
372 |
|
Line 378... |
Line 390... |
378 |
//
|
390 |
//
|
379 |
// }
|
391 |
// }
|
380 |
// tableBonItem.setTarif(foreignRow, true);
|
392 |
// tableBonItem.setTarif(foreignRow, true);
|
381 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
393 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
382 |
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
|
394 |
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
|
383 |
&& JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client?") == JOptionPane.YES_OPTION) {
|
395 |
&& JOptionPane.showConfirmDialog(null, TM.tr("deliveryForm.applyClientRates")) == JOptionPane.YES_OPTION) { //$NON-NLS-1$
|
384 |
boxTarif.setValue(foreignRow.getID());
|
396 |
boxTarif.setValue(foreignRow.getID());
|
385 |
// SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
|
397 |
// SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
|
386 |
// true);
|
398 |
// true);
|
387 |
} else {
|
399 |
} else {
|
388 |
boxTarif.setValue(foreignRow.getID());
|
400 |
boxTarif.setValue(foreignRow.getID());
|
Line 391... |
Line 403... |
391 |
}
|
403 |
}
|
392 |
}
|
404 |
}
|
393 |
});
|
405 |
});
|
394 |
|
406 |
|
395 |
// Bouton tout livrer
|
407 |
// Bouton tout livrer
|
396 |
JButton boutonAll = new JButton("Tout livrer");
|
408 |
JButton boutonAll = new JButton(TM.tr("deliveryForm.shipAll")); //$NON-NLS-1$
|
397 |
|
409 |
|
398 |
boutonAll.addActionListener(new ActionListener() {
|
410 |
boutonAll.addActionListener(new ActionListener() {
|
399 |
public void actionPerformed(ActionEvent e) {
|
411 |
public void actionPerformed(ActionEvent e) {
|
400 |
RowValuesTableModel m = BonDeLivraisonSQLComponent.this.tableBonItem.getModel();
|
412 |
RowValuesTableModel m = BonDeLivraisonSQLComponent.this.tableBonItem.getModel();
|
401 |
|
413 |
|
Line 509... |
Line 521... |
509 |
this.allowEditable("TOTAL_TVA", false);
|
521 |
this.allowEditable("TOTAL_TVA", false);
|
510 |
this.allowEditable("TOTAL_TTC", false);
|
522 |
this.allowEditable("TOTAL_TTC", false);
|
511 |
this.allowEditable("TOTAL_POIDS", false);
|
523 |
this.allowEditable("TOTAL_POIDS", false);
|
512 |
final TotalPanel panelTotal = new TotalPanel(tableBonItem, fieldEco, textTotalHT, textTotalTVA, textTotalTTC, textPortHT, textRemiseHT, fieldService, fieldHA, fieldDevise, this.textPoidsTotal,
|
524 |
final TotalPanel panelTotal = new TotalPanel(tableBonItem, fieldEco, textTotalHT, textTotalTVA, textTotalTTC, textPortHT, textRemiseHT, fieldService, fieldHA, fieldDevise, this.textPoidsTotal,
|
513 |
null, (getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
|
525 |
null, (getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
|
514 |
|
- |
|
515 |
// if (b) {
|
526 |
// if (b) {
|
516 |
JPanel panel = new JPanel(new GridBagLayout());
|
527 |
JPanel panel = new JPanel(new GridBagLayout());
|
517 |
GridBagConstraints cFrais = new DefaultGridBagConstraints();
|
528 |
GridBagConstraints cFrais = new DefaultGridBagConstraints();
|
518 |
panel.add(new JLabel(getLabelFor("TOTAL_POIDS")), cFrais);
|
529 |
panel.add(new JLabel(getLabelFor("TOTAL_POIDS")), cFrais);
|
519 |
|
530 |
|
Line 724... |
Line 735... |
724 |
}
|
735 |
}
|
725 |
}
|
736 |
}
|
726 |
final String num = this.textNumeroUnique.getText();
|
737 |
final String num = this.textNumeroUnique.getText();
|
727 |
if (attempt == JUniqueTextField.RETRY_COUNT) {
|
738 |
if (attempt == JUniqueTextField.RETRY_COUNT) {
|
728 |
idBon = getSelectedID();
|
739 |
idBon = getSelectedID();
|
729 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de bon existant.");
|
740 |
ExceptionHandler.handle(TM.tr("deliveryForm.cannotAdd.existingNumber")); //$NON-NLS-1$
|
730 |
final Object root = SwingUtilities.getRoot(this);
|
741 |
final Object root = SwingUtilities.getRoot(this);
|
731 |
if (root instanceof EditFrame) {
|
742 |
if (root instanceof EditFrame) {
|
732 |
final EditFrame frame = (EditFrame) root;
|
743 |
final EditFrame frame = (EditFrame) root;
|
733 |
frame.getPanel().setAlwaysVisible(true);
|
744 |
frame.getPanel().setAlwaysVisible(true);
|
734 |
}
|
745 |
}
|
735 |
} else {
|
746 |
} else {
|
- |
|
747 |
if (getTable().getDBRoot().contains("TARIF_AGENCE")) {
|
- |
|
748 |
final List<ProductComponent> comps = checkStock();
|
- |
|
749 |
if (comps.size() > 0) {
|
- |
|
750 |
String article = "";
|
- |
|
751 |
for (ProductComponent comp : comps) {
|
- |
|
752 |
article += "\n " + comp.getProduct().getString("CODE") + " --- " + comp.getProduct().getString("NOM");
|
- |
|
753 |
}
|
- |
|
754 |
JOptionPane.showMessageDialog(null, TM.tr("deliveryForm.cannotCreate.notInStock") + article); //$NON-NLS-1$
|
- |
|
755 |
final Object root = SwingUtilities.getRoot(this);
|
- |
|
756 |
if (root instanceof EditFrame) {
|
- |
|
757 |
final EditFrame frame = (EditFrame) root;
|
- |
|
758 |
frame.getPanel().setAlwaysVisible(true);
|
- |
|
759 |
}
|
- |
|
760 |
return -1;
|
- |
|
761 |
}
|
- |
|
762 |
}
|
736 |
idBon = super.insert(order);
|
763 |
idBon = super.insert(order);
|
737 |
if (this.tableBonReliquatItem != null) {
|
764 |
if (this.tableBonReliquatItem != null) {
|
738 |
this.tableBonReliquatItem.updateField("ID_BON_DE_LIVRAISON_ORIGINE", idBon);
|
765 |
this.tableBonReliquatItem.updateField("ID_BON_DE_LIVRAISON_ORIGINE", idBon);
|
739 |
}
|
766 |
}
|
740 |
this.tableBonItem.updateField("ID_BON_DE_LIVRAISON", idBon);
|
767 |
this.tableBonItem.updateField("ID_BON_DE_LIVRAISON", idBon);
|
741 |
this.tableBonItem.createArticle(idBon, this.getElement());
|
768 |
this.tableBonItem.createArticle(idBon, this.getElement());
|
- |
|
769 |
final List<Object> cmdDourceTrRowsFrom = ((BonDeLivraisonSQLElement) getElement()).getSourceTrRowsFrom(idBon, "COMMANDE_CLIENT_ELEMENT", "COMMANDE_CLIENT");
|
742 |
((BonDeLivraisonSQLElement) getElement()).updateCmdClientElement(((BonDeLivraisonSQLElement) getElement()).getCmdClientFrom(idBon), idBon);
|
770 |
((BonDeLivraisonSQLElement) getElement()).updateQteLivree(cmdDourceTrRowsFrom, "COMMANDE_CLIENT_ELEMENT", "COMMANDE_CLIENT");
|
- |
|
771 |
final List<Object> devisSourceTrRowsFrom = ((BonDeLivraisonSQLElement) getElement()).getSourceTrRowsFrom(idBon, "DEVIS_ELEMENT", "DEVIS");
|
- |
|
772 |
((BonDeLivraisonSQLElement) getElement()).updateQteLivree(devisSourceTrRowsFrom, "DEVIS_ELEMENT", "DEVIS");
|
743 |
// generation du document
|
773 |
// generation du document
|
744 |
BonLivraisonXmlSheet bSheet = new BonLivraisonXmlSheet(getTable().getRow(idBon));
|
774 |
BonLivraisonXmlSheet bSheet = new BonLivraisonXmlSheet(getTable().getRow(idBon));
|
745 |
bSheet.createDocumentAsynchronous();
|
775 |
bSheet.createDocumentAsynchronous();
|
746 |
bSheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
|
776 |
bSheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
|
747 |
|
777 |
|
Line 771... |
Line 801... |
771 |
}
|
801 |
}
|
772 |
// updateQte(idBon);
|
802 |
// updateQte(idBon);
|
773 |
if (attempt > 0) {
|
803 |
if (attempt > 0) {
|
774 |
SwingUtilities.invokeLater(new Runnable() {
|
804 |
SwingUtilities.invokeLater(new Runnable() {
|
775 |
public void run() {
|
805 |
public void run() {
|
776 |
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
|
806 |
JOptionPane.showMessageDialog(null, TM.tr("deliveryForm.numberRefreshed", num)); //$NON-NLS-1$
|
777 |
}
|
807 |
}
|
778 |
});
|
808 |
});
|
779 |
}
|
809 |
}
|
780 |
}
|
810 |
}
|
781 |
|
811 |
|
782 |
return idBon;
|
812 |
return idBon;
|
783 |
}
|
813 |
}
|
784 |
|
814 |
|
- |
|
815 |
private List<ProductComponent> checkStock() {
|
- |
|
816 |
List<ProductComponent> comps = new ArrayList<ProductComponent>();
|
- |
|
817 |
final RowValuesTableModel rowValuesTableModel = this.tableBonItem.getRowValuesTable().getRowValuesTableModel();
|
- |
|
818 |
|
- |
|
819 |
for (int i = 0; i < rowValuesTableModel.getRowCount(); i++) {
|
- |
|
820 |
final SQLRowValues rowValuesAt = rowValuesTableModel.getRowValuesAt(i);
|
- |
|
821 |
if (rowValuesAt.getInt("QTE_LIVREE") > 0 && rowValuesAt != null && rowValuesAt.getObject("ID_ARTICLE") != null && !rowValuesAt.isForeignEmpty("ID_ARTICLE")) {
|
- |
|
822 |
SQLRowAccessor article = rowValuesAt.getForeign("ID_ARTICLE");
|
- |
|
823 |
if (article.getBoolean("GESTION_STOCK")) {
|
- |
|
824 |
ProductComponent comp = ProductComponent.createFrom(rowValuesAt);
|
- |
|
825 |
if (comp.getStock() != null && !comp.getStock().isUndefined() && comp.getStock().getFloat("QTE_REEL") < 0) {
|
- |
|
826 |
comps.add(comp);
|
- |
|
827 |
}
|
- |
|
828 |
}
|
- |
|
829 |
}
|
- |
|
830 |
}
|
- |
|
831 |
return comps;
|
- |
|
832 |
}
|
- |
|
833 |
|
785 |
@Override
|
834 |
@Override
|
786 |
public void select(SQLRowAccessor r) {
|
835 |
public void select(SQLRowAccessor r) {
|
787 |
if (r == null || r.getIDNumber() == null)
|
836 |
if (r == null || r.getIDNumber() == null)
|
788 |
super.select(r);
|
837 |
super.select(r);
|
789 |
else {
|
838 |
else {
|
Line 806... |
Line 855... |
806 |
}
|
855 |
}
|
807 |
|
856 |
|
808 |
@Override
|
857 |
@Override
|
809 |
public void update() {
|
858 |
public void update() {
|
810 |
if (!this.textNumeroUnique.checkValidation()) {
|
859 |
if (!this.textNumeroUnique.checkValidation()) {
|
811 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de bon de livraison existant.");
|
860 |
ExceptionHandler.handle(TM.tr("deliveryForm.cannotAdd.existingNumber")); //$NON-NLS-1$
|
812 |
Object root = SwingUtilities.getRoot(this);
|
861 |
Object root = SwingUtilities.getRoot(this);
|
813 |
if (root instanceof EditFrame) {
|
862 |
if (root instanceof EditFrame) {
|
814 |
EditFrame frame = (EditFrame) root;
|
863 |
EditFrame frame = (EditFrame) root;
|
815 |
frame.getPanel().setAlwaysVisible(true);
|
864 |
frame.getPanel().setAlwaysVisible(true);
|
816 |
}
|
865 |
}
|
Line 818... |
Line 867... |
818 |
}
|
867 |
}
|
819 |
super.update();
|
868 |
super.update();
|
820 |
if (tableBonReliquatItem != null) {
|
869 |
if (tableBonReliquatItem != null) {
|
821 |
this.tableBonReliquatItem.updateField("ID_BON_DE_LIVRAISON_ORIGINE", getSelectedID());
|
870 |
this.tableBonReliquatItem.updateField("ID_BON_DE_LIVRAISON_ORIGINE", getSelectedID());
|
822 |
}
|
871 |
}
|
- |
|
872 |
final List<Object> cmdClientFrom = ((BonDeLivraisonSQLElement) getElement()).getSourceTrRowsFrom(getSelectedID(), "COMMANDE_CLIENT_ELEMENT", "COMMANDE_CLIENT");
|
823 |
final List<Object> cmdClientFrom = ((BonDeLivraisonSQLElement) getElement()).getCmdClientFrom(getSelectedID());
|
873 |
final List<Object> devisFrom = ((BonDeLivraisonSQLElement) getElement()).getSourceTrRowsFrom(getSelectedID(), "DEVIS_ELEMENT", "DEVIS");
|
824 |
this.tableBonItem.updateField("ID_BON_DE_LIVRAISON", getSelectedID());
|
874 |
this.tableBonItem.updateField("ID_BON_DE_LIVRAISON", getSelectedID());
|
825 |
this.tableBonItem.createArticle(getSelectedID(), this.getElement());
|
875 |
this.tableBonItem.createArticle(getSelectedID(), this.getElement());
|
826 |
((BonDeLivraisonSQLElement) getElement()).updateCmdClientElement(cmdClientFrom, getSelectedID());
|
876 |
((BonDeLivraisonSQLElement) getElement()).updateQteLivree(devisFrom, "DEVIS_ELEMENT", "DEVIS");
|
- |
|
877 |
((BonDeLivraisonSQLElement) getElement()).updateQteLivree(cmdClientFrom, "COMMANDE_CLIENT_ELEMENT", "COMMANDE_CLIENT");
|
827 |
|
878 |
|
828 |
// generation du document
|
879 |
// generation du document
|
829 |
BonLivraisonXmlSheet bSheet = new BonLivraisonXmlSheet(getTable().getRow(getSelectedID()));
|
880 |
BonLivraisonXmlSheet bSheet = new BonLivraisonXmlSheet(getTable().getRow(getSelectedID()));
|
830 |
bSheet.createDocumentAsynchronous();
|
881 |
bSheet.createDocumentAsynchronous();
|
831 |
bSheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
|
882 |
bSheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
|
832 |
|
883 |
|
833 |
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
|
884 |
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
|
834 |
SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
|
- |
|
835 |
if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
|
885 |
if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
|
836 |
|
886 |
|
837 |
try {
|
887 |
try {
|
838 |
updateStock(getSelectedID());
|
888 |
updateStock(getSelectedID());
|
839 |
} catch (SQLException e) {
|
889 |
} catch (SQLException e) {
|
Line 846... |
Line 896... |
846 |
/**
|
896 |
/**
|
847 |
* Chargement des qtés restantes à livrer
|
897 |
* Chargement des qtés restantes à livrer
|
848 |
*
|
898 |
*
|
849 |
* @param l
|
899 |
* @param l
|
850 |
*/
|
900 |
*/
|
851 |
public void loadQuantity(List<SQLRowValues> l) {
|
901 |
public void loadQuantity(List<SQLRowValues> l, final String fromTableElt) {
|
852 |
Map<Integer, SQLRowValues> map = new HashMap<Integer, SQLRowValues>();
|
902 |
Map<Integer, SQLRowValues> map = new HashMap<Integer, SQLRowValues>();
|
853 |
for (SQLRowValues sqlRowValues : l) {
|
903 |
for (SQLRowValues sqlRowValues : l) {
|
- |
|
904 |
// On ne prend en compte que les articles ou les lignes différentes de 0, autres lignes
|
- |
|
905 |
// considérées comme commentaires
|
- |
|
906 |
if (!sqlRowValues.isForeignEmpty("ID_ARTICLE") || sqlRowValues.getBigDecimal("PV_HT").signum() != 0) {
|
854 |
if (!sqlRowValues.isForeignEmpty("ID_ARTICLE")) {
|
907 |
if (!sqlRowValues.isForeignEmpty("ID_" + fromTableElt)) {
|
855 |
final int foreignID = sqlRowValues.getForeignID("ID_ARTICLE");
|
908 |
final int foreignID = sqlRowValues.getForeignID("ID_" + fromTableElt);
|
856 |
if (!map.containsKey(foreignID)) {
|
909 |
if (!map.containsKey(foreignID)) {
|
857 |
map.put(foreignID, sqlRowValues);
|
910 |
map.put(foreignID, sqlRowValues);
|
858 |
} else {
|
911 |
} else {
|
859 |
SQLRowValues vals = map.get(foreignID);
|
912 |
SQLRowValues vals = map.get(foreignID);
|
860 |
if (sqlRowValues.getInt("QTE_LIVREE") > 0) {
|
913 |
if (sqlRowValues.getInt("QTE_LIVREE") > 0) {
|
Line 865... |
Line 918... |
865 |
}
|
918 |
}
|
866 |
}
|
919 |
}
|
867 |
}
|
920 |
}
|
868 |
}
|
921 |
}
|
869 |
}
|
922 |
}
|
- |
|
923 |
}
|
870 |
int count = this.tableBonItem.getModel().getRowCount();
|
924 |
int count = this.tableBonItem.getModel().getRowCount();
|
871 |
for (int i = 0; i < count; i++) {
|
925 |
for (int i = 0; i < count; i++) {
|
872 |
final SQLRowValues rowValuesAt = this.tableBonItem.getModel().getRowValuesAt(i);
|
926 |
final SQLRowValues rowValuesAt = this.tableBonItem.getModel().getRowValuesAt(i);
|
873 |
rowValuesAt.put("QTE_LIVREE", rowValuesAt.getObject("QTE"));
|
927 |
rowValuesAt.put("QTE_LIVREE", rowValuesAt.getObject("QTE"));
|
874 |
}
|
928 |
}
|
875 |
|
929 |
|
876 |
for (int i = 0; i < count; i++) {
|
930 |
for (int i = 0; i < count; i++) {
|
877 |
SQLRowValues r = this.tableBonItem.getModel().getRowValuesAt(i);
|
931 |
SQLRowValues r = this.tableBonItem.getModel().getRowValuesAt(i);
|
878 |
SQLRowValues rowTR = map.get(r.getForeignID("ID_ARTICLE"));
|
932 |
SQLRowValues rowTR = map.get(r.getForeignID("ID_" + fromTableElt));
|
879 |
if (rowTR != null && !rowTR.isUndefined()) {
|
933 |
if (rowTR != null && !rowTR.isUndefined()) {
|
880 |
if (r.getInt("QTE_LIVREE") > 0 && rowTR.getInt("QTE_LIVREE") > 0) {
|
934 |
if (r.getInt("QTE_LIVREE") > 0 && rowTR.getInt("QTE_LIVREE") > 0) {
|
881 |
if (NumberUtils.areNumericallyEqual(r.getBigDecimal("QTE_UNITAIRE"), BigDecimal.ONE) || r.getInt("QTE_LIVREE") > 1) {
|
935 |
if (NumberUtils.areNumericallyEqual(r.getBigDecimal("QTE_UNITAIRE"), BigDecimal.ONE) || r.getInt("QTE_LIVREE") > 1) {
|
882 |
this.tableBonItem.getModel().putValue(r.getInt("QTE_LIVREE") - rowTR.getInt("QTE_LIVREE"), i, "QTE_LIVREE");
|
936 |
this.tableBonItem.getModel().putValue(r.getInt("QTE_LIVREE") - rowTR.getInt("QTE_LIVREE"), i, "QTE_LIVREE");
|
883 |
} else {
|
937 |
} else {
|
Line 896... |
Line 950... |
896 |
* @param idBon id du bon de livraison
|
950 |
* @param idBon id du bon de livraison
|
897 |
* @throws SQLException
|
951 |
* @throws SQLException
|
898 |
*/
|
952 |
*/
|
899 |
public void updateQte(int idBon) throws SQLException {
|
953 |
public void updateQte(int idBon) throws SQLException {
|
900 |
|
954 |
|
901 |
SQLTable tableFactureElem = new SaisieVenteFactureItemSQLElement().getTable();
|
955 |
SQLTable tableFactureElem = getDirectory().getElement(SaisieVenteFactureItemSQLElement.class).getTable();
|
902 |
SQLSelect selBonItem = new SQLSelect(getTable().getBase());
|
956 |
SQLSelect selBonItem = new SQLSelect();
|
903 |
BonDeLivraisonItemSQLElement bonElt = new BonDeLivraisonItemSQLElement();
|
957 |
BonDeLivraisonItemSQLElement bonElt = getDirectory().getElement(BonDeLivraisonItemSQLElement.class);
|
904 |
selBonItem.addSelect(bonElt.getTable().getField("ID_SAISIE_VENTE_FACTURE_ELEMENT"));
|
958 |
selBonItem.addSelect(bonElt.getTable().getField("ID_SAISIE_VENTE_FACTURE_ELEMENT"));
|
905 |
selBonItem.addSelect(bonElt.getTable().getField("QTE_LIVREE"));
|
959 |
selBonItem.addSelect(bonElt.getTable().getField("QTE_LIVREE"));
|
906 |
selBonItem.setWhere(bonElt.getTable().getField("ID_BON_DE_LIVRAISON"), "=", idBon);
|
960 |
selBonItem.setWhere(bonElt.getTable().getField("ID_BON_DE_LIVRAISON"), "=", idBon);
|
907 |
|
961 |
|
908 |
String reqBonItem = selBonItem.asString();
|
962 |
String reqBonItem = selBonItem.asString();
|
Line 927... |
Line 981... |
927 |
* @param idBon id du bon de livraison
|
981 |
* @param idBon id du bon de livraison
|
928 |
* @throws SQLException
|
982 |
* @throws SQLException
|
929 |
*/
|
983 |
*/
|
930 |
public void cancelUpdateQte(int idBon) throws SQLException {
|
984 |
public void cancelUpdateQte(int idBon) throws SQLException {
|
931 |
|
985 |
|
932 |
SQLTable tableFactureElem = new SaisieVenteFactureItemSQLElement().getTable();
|
986 |
SQLTable tableFactureElem = getDirectory().getElement(SaisieVenteFactureItemSQLElement.class).getTable();
|
933 |
SQLSelect selBonItem = new SQLSelect(getTable().getBase());
|
987 |
SQLSelect selBonItem = new SQLSelect();
|
934 |
BonDeLivraisonItemSQLElement bonElt = new BonDeLivraisonItemSQLElement();
|
988 |
BonDeLivraisonItemSQLElement bonElt = getDirectory().getElement(BonDeLivraisonItemSQLElement.class);
|
935 |
selBonItem.addSelect(bonElt.getTable().getField("ID_SAISIE_VENTE_FACTURE_ELEMENT"));
|
989 |
selBonItem.addSelect(bonElt.getTable().getField("ID_SAISIE_VENTE_FACTURE_ELEMENT"));
|
936 |
selBonItem.addSelect(bonElt.getTable().getField("QTE_LIVREE"));
|
990 |
selBonItem.addSelect(bonElt.getTable().getField("QTE_LIVREE"));
|
937 |
selBonItem.setWhere(bonElt.getTable().getField("ID_BON_DE_LIVRAISON"), "=", idBon);
|
991 |
selBonItem.setWhere(bonElt.getTable().getField("ID_BON_DE_LIVRAISON"), "=", idBon);
|
938 |
|
992 |
|
939 |
String reqBonItem = selBonItem.asString();
|
993 |
String reqBonItem = selBonItem.asString();
|
Line 984... |
Line 1038... |
984 |
|
1038 |
|
985 |
stockUpdater.update();
|
1039 |
stockUpdater.update();
|
986 |
}
|
1040 |
}
|
987 |
}
|
1041 |
}
|
988 |
|
1042 |
|
- |
|
1043 |
public void duplicate(final int idCmd) {
|
- |
|
1044 |
|
- |
|
1045 |
final SQLElement cmd = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
|
- |
|
1046 |
final SQLElement cmdElt = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON_ELEMENT");
|
- |
|
1047 |
|
- |
|
1048 |
if (idCmd > 1) {
|
- |
|
1049 |
final SQLRow row = cmd.getTable().getRow(idCmd);
|
- |
|
1050 |
final SQLRowValues rowVals = new SQLRowValues(cmd.getTable());
|
- |
|
1051 |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT"));
|
- |
|
1052 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
|
- |
|
1053 |
|
- |
|
1054 |
this.select(rowVals);
|
- |
|
1055 |
}
|
- |
|
1056 |
|
- |
|
1057 |
final List<SQLRow> myListItem = cmd.getTable().getRow(idCmd).getReferentRows(cmdElt.getTable());
|
- |
|
1058 |
|
- |
|
1059 |
if (myListItem.size() != 0) {
|
- |
|
1060 |
getRowValuesTable().getRowValuesTableModel().clearRows();
|
- |
|
1061 |
|
- |
|
1062 |
for (final SQLRow rowElt : myListItem) {
|
- |
|
1063 |
|
- |
|
1064 |
final SQLRowValues rowVals = rowElt.createUpdateRow();
|
- |
|
1065 |
rowVals.clearPrimaryKeys();
|
- |
|
1066 |
rowVals.putEmptyLink("ID_COMMANDE_CLIENT_ELEMENT");
|
- |
|
1067 |
getRowValuesTable().getRowValuesTableModel().addRow(rowVals);
|
- |
|
1068 |
final int rowIndex = getRowValuesTable().getRowValuesTableModel().getRowCount() - 1;
|
- |
|
1069 |
getRowValuesTable().getRowValuesTableModel().fireTableModelModified(rowIndex);
|
- |
|
1070 |
}
|
- |
|
1071 |
} else {
|
- |
|
1072 |
getRowValuesTable().getRowValuesTableModel().clearRows();
|
- |
|
1073 |
}
|
- |
|
1074 |
getRowValuesTable().getRowValuesTableModel().fireTableDataChanged();
|
- |
|
1075 |
getRowValuesTable().repaint();
|
- |
|
1076 |
|
- |
|
1077 |
}
|
- |
|
1078 |
|
989 |
public void loadFromReliquat(List<SQLRowValues> l) {
|
1079 |
public void loadFromReliquat(List<SQLRowValues> l) {
|
990 |
this.tableBonItem.insertFromReliquat(l);
|
1080 |
this.tableBonItem.insertFromReliquat(l);
|
991 |
this.tableBonItem.setEnabled(false);
|
1081 |
this.tableBonItem.setEnabled(false);
|
992 |
}
|
1082 |
}
|
993 |
|
1083 |
|