ORKESTRA

ORKESTRA

  orkestra orkestra.com.tr
  Sohbet   İndirme Merkezi

E-Fatura Betik Kodları ( Orkestra Scripts )

2. Birim Eklemek İçin Betik (İrsaliye Tasarımına)


Not: Tasarım yapılırken 2. birim alanına "BuyersItemIdentification" seçilmeli.

tring sql     = "SELECT fat.LOGICALREF as FATURA_REF,satir.AMOUNT as MIKTAR,satir.LINETYPE,urun.LOGICALREF as URUN_REF,urun.CODE AS URUN_KOD,urun.NAME AS URUN_ADI,urun.UNITSETREF AS URUN_UNIT,unit1.CODE AS URUN_UNIT_CODE,unit1.CODE AS URUN_UNIT_NAME,unit2.LOGICALREF AS SATIR_UNIT_REF,unit2.CODE AS SATIR_UNIT_CODE,unit2.CONVFACT1 as SATIR_F1,unit2.CONVFACT2 as SATIR_F2,unit3.LOGICALREF AS SATIR_ALTUNIT_REF,unit3.CODE AS SATIR_ALTUNIT_CODE,unit3.CONVFACT1 as SATIR_ALT_F1,unit3.CONVFACT2 as SATIR_ALT_F2 ";
sql = sql + " FROM $SN$LG_$F$_$P$_STLINE satir ";
sql = sql + " LEFT OUTER JOIN $SN$LG_$F$_$P$_STFICHE fat ON fat.LOGICALREF=satir.STFICHEREF";
sql = sql + " LEFT OUTER JOIN $SN$LG_$F$_ITEMS urun ON urun.LOGICALREF=satir.STOCKREF";
sql = sql + " LEFT OUTER JOIN $SN$LG_$F$_UNITSETF unit1 ON unit1.LOGICALREF=urun.UNITSETREF";
sql = sql + " LEFT OUTER JOIN $SN$LG_$F$_UNITSETL unit2 ON unit2.LOGICALREF=satir.UOMREF";
sql = sql + " LEFT OUTER JOIN $SN$LG_$F$_UNITSETL unit3 ON (unit3.UNITSETREF=unit2.UNITSETREF AND unit3.LOGICALREF!=unit2.LOGICALREF)";
sql = sql + " WHERE ";
sql = sql + " satir.LINETYPE=0 AND";
sql = sql + " satir.STFICHEREF>0 AND";
sql = sql + " satir.LOGICALREF="+line.getItemField("reference");

//sql = "(SELECT T1.LOGICALREF, T1.CODE, T1.NAME, T2.CONVFACT1, T5.CONVFACT2, T6.CODE FROM $SN$LG_$F$_ITEMS T1, $SN$LG_$F$_ITMUNITA T2, $SN$LG_$F$_ITMUNITA T5, $SN$LG_$F$_UNITSETL T6 WHERE T1.LOGICALREF = T2.ITEMREF AND T2.LINENR = (SELECT MAX(T3.LINENR) FROM $SN$LG_$F$_ITMUNITA T3, $SN$LG_$F$_ITEMS T4 WHERE T4.CODE=T1.CODE AND T4.LOGICALREF=T3.ITEMREF) AND T6.LINENR=(SELECT MAX(I3.LINENR) FROM $SN$LG_$F$_UNITSETL I3, $SN$LG_$F$_ITEMS I4 WHERE I3.UNITSETREF=I4.UNITSETREF AND I4.LOGICALREF=T1.LOGICALREF) AND T1.UNITSETREF=T6.UNITSETREF AND T1.LOGICALREF = T5.ITEMREF AND T5.LINENR = 2) UNION (SELECT T6.LOGICALREF, T6.CODE, T6.NAME, 1, 1, T7.CODE FROM $SN$LG_$F$_ITEMS T6, $SN$LG_$F$_UNITSETL T7 WHERE T6.LOGICALREF NOT IN (SELECT T1.LOGICALREF FROM $SN$LG_$F$_ITEMS T1, $SN$LG_$F$_ITMUNITA T2, $SN$LG_$F$_ITMUNITA T5 WHERE T1.LOGICALREF = T2.ITEMREF AND T2.LINENR = (SELECT MAX(T3.LINENR) FROM $SN$LG_$F$_ITMUNITA T3, $SN$LG_$F$_ITEMS T4 WHERE T4.CODE=T1.CODE AND T4.LOGICALREF=T3.ITEMREF) AND T1.LOGICALREF = T5.ITEMREF AND T5.LINENR = 2) AND T7.LINENR=(SELECT MAX(I3.LINENR) FROM $SN$LG_$F$_UNITSETL I3, $SN$LG_$F$_ITEMS I4 WHERE I3.UNITSETREF=I4.UNITSETREF AND I4.LOGICALREF=T6.LOGICALREF) AND T6.UNITSETREF=T7.UNITSETREF AND T1.LOGICALREF="+line.getItemField("stockref")+")";

String sql2 = "SELECT T1.LOGICALREF, T1.CODE, T1.NAME, T2.CONVFACT1, T5.CONVFACT2, T6.CODE as BIRIMKODU, T6.LOGICALREF as BIRIMREF  FROM $SN$LG_$F$_ITEMS T1, $SN$LG_$F$_ITMUNITA T2, $SN$LG_$F$_ITMUNITA T5, $SN$LG_$F$_UNITSETL T6 WHERE T1.LOGICALREF = T2.ITEMREF AND T2.LINENR = (SELECT MAX(T3.LINENR) FROM $SN$LG_$F$_ITMUNITA T3, $SN$LG_$F$_ITEMS T4 WHERE T4.CODE=T1.CODE AND T4.LOGICALREF=T3.ITEMREF) AND T6.LINENR=(SELECT MAX(I3.LINENR) FROM $SN$LG_$F$_UNITSETL I3, $SN$LG_$F$_ITEMS I4 WHERE I3.UNITSETREF=I4.UNITSETREF AND I4.LOGICALREF=T1.LOGICALREF) AND T1.UNITSETREF=T6.UNITSETREF AND T1.LOGICALREF = T5.ITEMREF AND T5.LINENR = 2  AND T1.LOGICALREF="+line.getItemField("stockref")+"";

Console.println("LINE REF : "+line.getItemField("reference"));
Console.println("SQL : "+sql2);
Object tanimli = executeSql(createSql(sql2));
Object tanimli2 = executeSql(createSql(sql));
if (tanimli != null){
 Console.println("TANIMLI OK !");
 Console.println("----------------- SQL OK --------------");
///    Console.println("ALTERNATIF BIRIM : "+tanimli.getString("BIRIMKODU2"));
    Console.println("ALTERNATIF CODE : "+tanimli.getString("BIRIMKODU2"));
    
 BigDecimal sifir  = MathUtil.bigDecimal(0);
 BigDecimal miktar = MathUtil.bigDecimal(line.getItemField("amount"));
 BigDecimal carpan1 = tanimli.getBigDecimal("CONVFACT1");
 BigDecimal carpan2 = tanimli.getBigDecimal("CONVFACT2");
 if(carpan1>sifir && carpan2>sifir){
  Console.println("MIKTAR : "+MathUtil.format(miktar,"#,###.##")+" "+tanimli2.getString("SATIR_UNIT_CODE") );
  BigDecimal yeniMiktar = miktar.multiply(MathUtil.bigDecimal(1));
  yeniMiktar = miktar.divide(carpan2,10,0);
  //Console.println("CARPAN :"+MathUtil.format(carpan1,"#,###.##")+" / "+MathUtil.format(carpan2,"#,###.##"));
  Console.println("MIKTAR2 : "+MathUtil.format(yeniMiktar,"#,###.##")+" "+tanimli2.getString("SATIR_ALTUNIT_CODE") );
  if(yeniMiktar>sifir){
           //line.setUblValue("Item/Description","=",MathUtil.format(yeniMiktar,"#,###.##")+" "+tanimli.getString("SATIR_ALTUNIT_CODE"));
   line.setIdentification("seller",MathUtil.format(miktar,"#,###.##")+" "+tanimli2.getString("SATIR_UNIT_CODE"));
   line.setIdentification("buyer",MathUtil.format(yeniMiktar,"#,###.##")+" "+tanimli2.getString("SATIR_ALTUNIT_CODE"));
  }
 
 }else{
  Console.println("CARPAN BULUNAMADI !"+MathUtil.format(carpan1,"#,###.##")+" / "+MathUtil.format(carpan2,"#,###.##"));
 }
}else{
 Console.println("----------------- SQL NOT OK --------------");