Package sn.unitech.stock.metier

Source Code of sn.unitech.stock.metier.SysAdherEvtTaxM

package sn.unitech.stock.metier;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import sn.unitech.common.dao.ReadProperties;
import sn.unitech.stock.dao.SysAdherEvtTaxDao;
import sn.unitech.stock.dao.iface.ISysAdherEvtTaxDao;
import sn.unitech.stock.entity.Compte;
import sn.unitech.stock.entity.DetailEvent;
import sn.unitech.stock.entity.Events;
import sn.unitech.stock.entity.IUniversel;
import sn.unitech.stock.entity.Stock;
import sn.unitech.stock.entity.SysAdherEvtTax;
import sn.unitech.stock.entity.SysEvents;
import sn.unitech.stock.entity.SysProduit;
import sn.unitech.stock.entity.SysTaxe;
import sn.unitech.stock.entity.SysUsers;
import sn.unitech.stock.entity.SysUsersId;
import sn.unitech.stock.entity.SysValeurTaxe;
import sn.unitech.stock.entity.Taxes;
import sn.unitech.stock.metier.iface.ISysAdherEvtTaxM;

@SuppressWarnings("unchecked")
public class SysAdherEvtTaxM<E>  implements ISysAdherEvtTaxM<SysAdherEvtTax>{
      ISysAdherEvtTaxDao<E> iSysAdherEvtTaxDao=new SysAdherEvtTaxDao();
      List<IUniversel> listIcro;
        List<SysAdherEvtTax>listSysTaxes;
        Map<Integer,Object> params;
        Events events;
       
    public SysAdherEvtTaxM(List<IUniversel> listIcro,Events events) {
      this.events=events;
      this.listIcro=listIcro;
      params=new LinkedHashMap<Integer,Object>();
      params.put(0,events.getSysUsers().getId().getIdAdherent());
      params.put(1,events.getSysEvents().getIdEvent());
      this.listSysTaxes=this.iSysAdherEvtTaxDao.getAlltaxes(ReadProperties.getReadProperties().read("SysTaxe.allTaxes"),null, params);
      if(this.listSysTaxes==null)this.listSysTaxes=new ArrayList<SysAdherEvtTax>()
       }
   
       private Double getValeurCurrentTaxe(SysTaxe sysTaxe,Double montant){
      params.clear();
      params.put(0, sysTaxe.getIdTaxe());
      params.put(1,montant);
      params.put(2,montant);
      try{
      SysValeurTaxe sysValeurTaxe=(SysValeurTaxe)this.iSysAdherEvtTaxDao.getValeurTaxe(ReadProperties.getReadProperties().read("SysTaxe.valueTaxe"),null, params);
      Double valeur=sysValeurTaxe.getValeur();
      if(sysTaxe.getMethode().trim().equals(ToolsMetier.METHODE_FIXE)) return new Double(Math.round(valeur));
      else if(sysTaxe.getMethode().trim().equals(ToolsMetier.METHODE_PROPORTIONNEL)) return new Double(Math.round( valeur > 1 ? (montant*valeur)/100 : montant*valeur));
      else return new Double(Math.round(sysValeurTaxe.getInite()+ (montant / sysValeurTaxe.getBasef()) * sysValeurTaxe.getTranche()));
      }
      catch(Exception e){   
      return (0d)
      }
      }
     
      public List<Taxes> getTaxesAndValues(){
      List<Taxes> listTaxesAndValues=new ArrayList<Taxes>()
      for (int i=0;(this.listSysTaxes!=null)&&(i<this.listSysTaxes.size());i++){
       Double totalDeCetteTaxe=(0d)
       Double prixTotal=0d;
        for (int j=0; j < this.listIcro.size();j++){
          prixTotal+=(listIcro.get(j).getQteContenant()*listIcro.get(j).getPrixUnitc())+
              (listIcro.get(j).getQteDetail()*listIcro.get(j).getPrixUnitd());
        totalDeCetteTaxe+=this.getValeurCurrentTaxe(this.listSysTaxes.get(i).getSysTaxe(),prixTotal)
        }
        Taxes taxes=new Taxes();
        taxes.setCodEvent(events.getSysEvents().getIdEvent());
        taxes.setIdAdherent(events.getSysUsers().getId().getIdAdherent());
        taxes.setIdTaxe(this.listSysTaxes.get(i).getSysTaxe().getIdTaxe());
        taxes.setLibelle("TOTAL: "+this.listSysTaxes.get(i).getSysTaxe().getLibelle());
        taxes.setValeur(totalDeCetteTaxe);
        taxes.setCptTaxe(this.listSysTaxes.get(i).getCompte().getIdCompte());
        taxes.setCptContrePartie(this.listSysTaxes.get(i).getSysChamp().getIdChamp());
        taxes.setNatureTaxe(this.listSysTaxes.get(i).getSysTaxe().getSysRefTaxe().getIdDesignation());
        taxes.setSensTaxe(this.listSysTaxes.get(i).getSens());
        listTaxesAndValues.add(taxes)
      }
      return listTaxesAndValues;
      }
     
      public static void main(String args[]){
        List<DetailEvent> listDetailEvent=new ArrayList<DetailEvent>();
        DetailEvent detailEvent=new DetailEvent();
        Stock stock=new Stock();
        SysProduit sysProduit=new SysProduit();
        sysProduit.setCompte(new Compte());
        sysProduit.getCompte().setIdCompte("1");
        stock.setSysProduit(sysProduit);
        detailEvent.setStock(stock);
        detailEvent.setEvents(new Events());
        detailEvent.getEvents().setMntTot(new Double(100000));
        detailEvent.setPrixTot(new Double(40000));
        SysUsers sysUsers=new SysUsers();
        sysUsers.setCompte(new Compte());
        sysUsers.getCompte().setIdCompte("2");
        sysUsers.setId(new SysUsersId());
        sysUsers.getId().setIdAdherent("1");
        detailEvent.getEvents().setSysUsers(sysUsers);
        detailEvent.getEvents().setSysEvents(new SysEvents());
        detailEvent.getEvents().getSysEvents().setIdEvent("VT");
        listDetailEvent.add(detailEvent);
        //SysEcritsDao sysEcritsDao=new SysEcritsDao(listDetailEvent,null,null);
        //SysAdherEvtTaxM sysAdherEvtTaxM=new SysAdherEvtTaxM(listDetailEvent);
        //sysAdherEvtTaxM.getTaxesAndValues();
        try {
         
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        //System.out.println("taille liste"+sysAdherEvtTaxM.listSysTaxes.size());
       
          }

}
TOP

Related Classes of sn.unitech.stock.metier.SysAdherEvtTaxM

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.