Line 34... |
Line 34... |
34 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
34 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
35 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
35 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
36 |
import org.openconcerto.sql.Configuration;
|
36 |
import org.openconcerto.sql.Configuration;
|
37 |
import org.openconcerto.sql.element.SQLElement;
|
37 |
import org.openconcerto.sql.element.SQLElement;
|
38 |
import org.openconcerto.sql.model.FieldPath;
|
38 |
import org.openconcerto.sql.model.FieldPath;
|
- |
|
39 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
- |
|
40 |
import org.openconcerto.sql.model.SQLBackgroundTableCacheItem;
|
39 |
import org.openconcerto.sql.model.SQLField;
|
41 |
import org.openconcerto.sql.model.SQLField;
|
40 |
import org.openconcerto.sql.model.SQLRow;
|
42 |
import org.openconcerto.sql.model.SQLRow;
|
41 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
43 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
42 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
44 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
43 |
import org.openconcerto.sql.model.SQLRowValues;
|
45 |
import org.openconcerto.sql.model.SQLRowValues;
|
Line 1736... |
Line 1738... |
1736 |
}
|
1738 |
}
|
1737 |
|
1739 |
|
1738 |
}
|
1740 |
}
|
1739 |
|
1741 |
|
1740 |
Collection<? extends SQLRowAccessor> cacheRemise = null;
|
1742 |
Collection<? extends SQLRowAccessor> cacheRemise = null;
|
- |
|
1743 |
Collection<? extends SQLRowAccessor> cacheRemiseFamille = null;
|
1741 |
|
1744 |
|
1742 |
protected BigDecimal getTarifRemiseClient(SQLRowAccessor article, BigDecimal pv) {
|
1745 |
protected BigDecimal getTarifRemiseClient(SQLRowAccessor article, BigDecimal pv) {
|
1743 |
if (cacheRemise != null) {
|
1746 |
if (cacheRemise != null) {
|
1744 |
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
|
1747 |
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
|
1745 |
for (SQLRowAccessor sqlRowAccessor : cacheRemise) {
|
1748 |
for (SQLRowAccessor sqlRowAccessor : cacheRemise) {
|
Line 1754... |
Line 1757... |
1754 |
}
|
1757 |
}
|
1755 |
return pv;
|
1758 |
return pv;
|
1756 |
}
|
1759 |
}
|
1757 |
|
1760 |
|
1758 |
protected Acompte getRemiseClient(SQLRowAccessor article) {
|
1761 |
protected Acompte getRemiseClient(SQLRowAccessor article) {
|
- |
|
1762 |
Acompte remise = null;
|
- |
|
1763 |
if (this.cacheRemiseFamille != null) {
|
- |
|
1764 |
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
|
- |
|
1765 |
if (article.getForeign("ID_FAMILLE_ARTICLE") != null && !article.isForeignEmpty("ID_FAMILLE_ARTICLE")) {
|
- |
|
1766 |
Integer fID = article.getForeignID("ID_FAMILLE_ARTICLE");
|
- |
|
1767 |
|
- |
|
1768 |
remise = getRemiseFamille(fID);
|
- |
|
1769 |
// TODO faire une fonction recursive avec un test pour eviter les boucles
|
- |
|
1770 |
if (remise == null) {
|
- |
|
1771 |
SQLBackgroundTableCacheItem cacheTableFamille = SQLBackgroundTableCache.getInstance().getCacheForTable(article.getTable().getForeignTable("ID_FAMILLE_ARTICLE"));
|
- |
|
1772 |
SQLRow rowFamille = cacheTableFamille.getRowFromId(fID);
|
- |
|
1773 |
if (rowFamille != null && rowFamille.getObject("ID_FAMILLE_ARTICLE_PERE") != null && !rowFamille.isForeignEmpty("ID_FAMILLE_ARTICLE_PERE")) {
|
- |
|
1774 |
Integer fIDPere = rowFamille.getForeignID("ID_FAMILLE_ARTICLE_PERE");
|
1759 |
Acompte remise = new Acompte(BigDecimal.ZERO, BigDecimal.ZERO);
|
1775 |
remise = getRemiseFamille(fIDPere);
|
- |
|
1776 |
if (remise == null) {
|
- |
|
1777 |
SQLRow rowFamille2 = cacheTableFamille.getRowFromId(fIDPere);
|
- |
|
1778 |
if (rowFamille2 != null && rowFamille2.getObject("ID_FAMILLE_ARTICLE_PERE") != null && !rowFamille2.isForeignEmpty("ID_FAMILLE_ARTICLE_PERE")) {
|
- |
|
1779 |
Integer fIDPere2 = rowFamille2.getForeignID("ID_FAMILLE_ARTICLE_PERE");
|
- |
|
1780 |
remise = getRemiseFamille(fIDPere2);
|
- |
|
1781 |
}
|
- |
|
1782 |
}
|
- |
|
1783 |
}
|
- |
|
1784 |
|
- |
|
1785 |
}
|
- |
|
1786 |
}
|
- |
|
1787 |
}
|
- |
|
1788 |
}
|
1760 |
if (this.cacheRemise != null) {
|
1789 |
if (this.cacheRemise != null) {
|
1761 |
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
|
1790 |
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
|
1762 |
for (SQLRowAccessor sqlRowAccessor : this.cacheRemise) {
|
1791 |
for (SQLRowAccessor sqlRowAccessor : this.cacheRemise) {
|
1763 |
if (!sqlRowAccessor.isForeignEmpty("ID_ARTICLE") && sqlRowAccessor.getForeignID("ID_ARTICLE") == article.getID()) {
|
1792 |
if (!sqlRowAccessor.isForeignEmpty("ID_ARTICLE") && sqlRowAccessor.getForeignID("ID_ARTICLE") == article.getID()) {
|
1764 |
BigDecimal r = sqlRowAccessor.getBigDecimal("POURCENT_REMISE");
|
1793 |
BigDecimal r = sqlRowAccessor.getBigDecimal("POURCENT_REMISE");
|
1765 |
if (remise != null) {
|
- |
|
1766 |
remise = new Acompte(r, null);
|
1794 |
remise = new Acompte(r, null);
|
- |
|
1795 |
break;
|
- |
|
1796 |
}
|
- |
|
1797 |
}
|
1767 |
}
|
1798 |
}
|
1768 |
}
|
1799 |
}
|
- |
|
1800 |
if (remise == null) {
|
- |
|
1801 |
return new Acompte(BigDecimal.ZERO, BigDecimal.ZERO);
|
- |
|
1802 |
} else {
|
- |
|
1803 |
return remise;
|
- |
|
1804 |
}
|
1769 |
}
|
1805 |
}
|
- |
|
1806 |
|
- |
|
1807 |
private Acompte getRemiseFamille(int fID) {
|
- |
|
1808 |
Acompte remise = null;
|
- |
|
1809 |
for (SQLRowAccessor sqlRowAccessor : this.cacheRemiseFamille) {
|
- |
|
1810 |
if (!sqlRowAccessor.isForeignEmpty("ID_FAMILLE_ARTICLE") && sqlRowAccessor.getForeignID("ID_FAMILLE_ARTICLE") == fID) {
|
- |
|
1811 |
BigDecimal r = sqlRowAccessor.getBigDecimal("POURCENT_REMISE");
|
- |
|
1812 |
remise = new Acompte(r, null);
|
- |
|
1813 |
break;
|
1770 |
}
|
1814 |
}
|
1771 |
}
|
1815 |
}
|
1772 |
return remise;
|
1816 |
return remise;
|
1773 |
}
|
1817 |
}
|
1774 |
|
1818 |
|
Line 1917... |
Line 1961... |
1917 |
public void setClient(SQLRowAccessor rowClient, boolean ask) {
|
1961 |
public void setClient(SQLRowAccessor rowClient, boolean ask) {
|
1918 |
if (rowClient == null || getRowClient() == null || rowClient.getID() != getRowClient().getID()) {
|
1962 |
if (rowClient == null || getRowClient() == null || rowClient.getID() != getRowClient().getID()) {
|
1919 |
super.setClient(rowClient, ask);
|
1963 |
super.setClient(rowClient, ask);
|
1920 |
if (getRowClient() != null && !getRowClient().isUndefined()) {
|
1964 |
if (getRowClient() != null && !getRowClient().isUndefined()) {
|
1921 |
this.cacheRemise = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_ARTICLE_CLIENT"));
|
1965 |
this.cacheRemise = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_ARTICLE_CLIENT"));
|
- |
|
1966 |
this.cacheRemiseFamille = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_FAMILLE_ARTICLE_CLIENT"));
|
1922 |
if (ask && this.cacheRemise.size() > 0 && getRowValuesTable().getRowCount() > 0
|
1967 |
if (ask && (!this.cacheRemise.isEmpty() || !this.cacheRemiseFamille.isEmpty()) && getRowValuesTable().getRowCount() > 0
|
1923 |
&& JOptionPane.showConfirmDialog(null, "Appliquer les remises associées au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {
|
1968 |
&& JOptionPane.showConfirmDialog(null, "Appliquer les remises associées au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {
|
1924 |
int nbRows = this.table.getRowCount();
|
1969 |
int nbRows = this.table.getRowCount();
|
1925 |
for (int i = 0; i < nbRows; i++) {
|
1970 |
for (int i = 0; i < nbRows; i++) {
|
1926 |
SQLRowValues rowVals = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(i);
|
1971 |
SQLRowValues rowVals = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(i);
|
1927 |
|
1972 |
|
Line 1941... |
Line 1986... |
1941 |
}
|
1986 |
}
|
1942 |
}
|
1987 |
}
|
1943 |
}
|
1988 |
}
|
1944 |
} else {
|
1989 |
} else {
|
1945 |
this.cacheRemise = null;
|
1990 |
this.cacheRemise = null;
|
- |
|
1991 |
this.cacheRemiseFamille = null;
|
1946 |
}
|
1992 |
}
|
1947 |
}
|
1993 |
}
|
1948 |
}
|
1994 |
}
|
1949 |
|
1995 |
|
1950 |
@Override
|
1996 |
@Override
|