public void createGJ_DIST(GJ_DIST oGJ_DIST) { string sCons = string.Empty; try { if (oGJ_DIST.AMOUNT > 0) { string query = MapeoQuerySql.ObtenerPorId("AdminGeneralJournal.createGJ_DIST"); sCons = string.Format(query, oGJ_DIST.GJ_ID , oGJ_DIST.DIST_NO , oGJ_DIST.ENTRY_NO , oGJ_DIST.AMOUNT , oGJ_DIST.AMOUNT_TYPE , oGJ_DIST.GL_ACCOUNT_ID , oGJ_DIST.NATIVE_AMOUNT , oGJ_DIST.POSTING_DATE , oGJ_DIST.POSTING_STATUS , oGJ_DIST.CREATE_DATE , oGJ_DIST.SITE_ID , oGJ_DIST.CURRENCY_ID , oGJ_DIST.NATIVE); _trace.AppendLine(sCons); _oSQL.EjecutarDML(sCons); } } catch (Exception ex) { throw new Exception("Error al insertar en GJ_DIST. Detalle: " + ex.Message); } }
private GJ_DIST getGJ_DIST_TRACK(int pEntry_No, double pAmount, string pAmountType, string sAccount, string pCurrency) { GJ_DIST oGJ_DIST_TRACK = new GJ_DIST(); oGJ_DIST_TRACK.GJ_ID = ID; oGJ_DIST_TRACK.DIST_NO = "1"; oGJ_DIST_TRACK.ENTRY_NO = pEntry_No.ToString(); oGJ_DIST_TRACK.AMOUNT = pAmount; oGJ_DIST_TRACK.AMOUNT_TYPE = pAmountType; oGJ_DIST_TRACK.GL_ACCOUNT_ID = sAccount; oGJ_DIST_TRACK.NATIVE_AMOUNT = "0"; oGJ_DIST_TRACK.POSTING_DATE = POSTING_DATE; oGJ_DIST_TRACK.POSTING_STATUS = "U"; oGJ_DIST_TRACK.CREATE_DATE = CREATE_DATE; oGJ_DIST_TRACK.ENTITY_ID = ENTITY_ID; oGJ_DIST_TRACK.CURRENCY_ID = pCurrency; oGJ_DIST_TRACK.NATIVE = "N"; return(oGJ_DIST_TRACK); }
private GJ_DIST getGJ_DIST_NATIVE(int pEntry_No, double pAmount, string pAmountType, string sAccount) { GJ_DIST oGJ_DIST = new GJ_DIST(); oGJ_DIST.GJ_ID = ID; oGJ_DIST.DIST_NO = "1"; oGJ_DIST.ENTRY_NO = pEntry_No.ToString(); oGJ_DIST.AMOUNT = pAmount; oGJ_DIST.AMOUNT_TYPE = pAmountType; oGJ_DIST.GL_ACCOUNT_ID = sAccount; oGJ_DIST.NATIVE_AMOUNT = "0"; oGJ_DIST.POSTING_DATE = POSTING_DATE; oGJ_DIST.POSTING_STATUS = "U"; oGJ_DIST.CREATE_DATE = CREATE_DATE; oGJ_DIST.ENTITY_ID = ENTITY_ID; oGJ_DIST.CURRENCY_ID = CURRENCY_ID; oGJ_DIST.NATIVE = "Y"; return(oGJ_DIST); }
public List <GJ_DIST> getListGJ_DIST() { List <GJ_DIST> lstGJ_DIST = new List <GJ_DIST>(); int iEntry_No = 1; double dMontoFactura = 0; double dMontoPago = 0; double dMonto_tipoCambio = 0; if (TipoCambio.Equals("FACTURA")) { foreach (DataRow item in _dtVMX_IVATRASTEMP.Rows) { GJ_DIST oGJ_DIST = new GJ_DIST(); dMontoFactura = double.Parse(item["MONTO"].ToString()); oGJ_DIST = getGJ_DIST_NATIVE(iEntry_No++, dMontoFactura, "DR", item["CUENTA_ORIGEN"].ToString()); lstGJ_DIST.Add(oGJ_DIST); oGJ_DIST = getGJ_DIST_NATIVE(iEntry_No++, dMontoFactura, "CR", item["CUENTA_DESTINO"].ToString()); lstGJ_DIST.Add(oGJ_DIST); } // Monedas rastreables foreach (DataRow item in _dtVMX_IVATRASTEMP.Rows) { foreach (MonedaRastreo moneda in _lstCurrencyTracking) { GJ_DIST oGJ_DIST_TRACK = new GJ_DIST(); dMontoFactura = double.Parse(item["MONTO"].ToString()); dMonto_tipoCambio = Math.Round((dMontoFactura / moneda.SELL_RATE), 2); oGJ_DIST_TRACK = getGJ_DIST_TRACK(iEntry_No++, dMonto_tipoCambio, "DR", item["CUENTA_DESTINO"].ToString(), moneda.ID); lstGJ_DIST.Add(oGJ_DIST_TRACK); oGJ_DIST_TRACK = getGJ_DIST_TRACK(iEntry_No++, dMonto_tipoCambio, "CR", item["CUENTA_ORIGEN"].ToString(), moneda.ID); lstGJ_DIST.Add(oGJ_DIST_TRACK); } } } else { // 1 - Moneda del sistema foreach (DataRow item in _dtVMX_IVATRASTEMP.Rows) { GJ_DIST oGJ_DIST = new GJ_DIST(); dMontoFactura = double.Parse(item["MONTO"].ToString()); dMontoPago = double.Parse(item["MONTO_IVA_DEPOSITO"].ToString()); oGJ_DIST = getGJ_DIST_NATIVE(iEntry_No++, dMontoFactura, "DR", item["CUENTA_ORIGEN"].ToString()); lstGJ_DIST.Add(oGJ_DIST); oGJ_DIST = getGJ_DIST_NATIVE(iEntry_No++, dMontoPago, "CR", item["CUENTA_DESTINO"].ToString()); lstGJ_DIST.Add(oGJ_DIST); // Perdida Ganancia PerdidaGanancia oPG = new PerdidaGanancia(); string sCta_Origen = item["CUENTA_ORIGEN"].ToString(); string sCta_Destino = item["CUENTA_DESTINO"].ToString(); oPG = oPG.getPerdidaGanancia(_dtDetalla_IVA, sCta_Origen, sCta_Destino); if (oPG.Ganancia > 0) { oGJ_DIST = getGJ_DIST_NATIVE(iEntry_No++, oPG.Ganancia, "DR", oPG.CuentaGanancia); lstGJ_DIST.Add(oGJ_DIST); } if (oPG.Perdida > 0) { oGJ_DIST = getGJ_DIST_NATIVE(iEntry_No++, oPG.Perdida, "CR", oPG.CuentaPerdida); lstGJ_DIST.Add(oGJ_DIST); } } // 2- Monedas rastreables foreach (DataRow item in _dtVMX_IVATRASTEMP.Rows) { dMontoFactura = double.Parse(item["MONTO"].ToString()); dMontoPago = double.Parse(item["MONTO_IVA_DEPOSITO"].ToString()); foreach (MonedaRastreo moneda in _lstCurrencyTracking) { GJ_DIST oGJ_DIST_TRACK = new GJ_DIST(); dMonto_tipoCambio = Math.Round((dMontoFactura / moneda.SELL_RATE), 2); oGJ_DIST_TRACK = getGJ_DIST_TRACK(iEntry_No++, dMonto_tipoCambio, "DR", item["CUENTA_DESTINO"].ToString(), moneda.ID); lstGJ_DIST.Add(oGJ_DIST_TRACK); dMonto_tipoCambio = Math.Round((dMontoPago / moneda.SELL_RATE), 2); oGJ_DIST_TRACK = getGJ_DIST_TRACK(iEntry_No++, dMonto_tipoCambio, "CR", item["CUENTA_ORIGEN"].ToString(), moneda.ID); lstGJ_DIST.Add(oGJ_DIST_TRACK); // Perdida Ganancia PerdidaGanancia oPG = new PerdidaGanancia(); string sCta_Origen = item["CUENTA_ORIGEN"].ToString(); string sCta_Destino = item["CUENTA_DESTINO"].ToString(); oPG = oPG.getPerdidaGanancia(_dtDetalla_IVA, sCta_Origen, sCta_Destino); if (oPG.Ganancia > 0) { dMonto_tipoCambio = Math.Round((oPG.Ganancia / moneda.SELL_RATE), 2); oGJ_DIST_TRACK = getGJ_DIST_TRACK(iEntry_No++, dMonto_tipoCambio, "DR", oPG.CuentaGanancia, moneda.ID); lstGJ_DIST.Add(oGJ_DIST_TRACK); } if (oPG.Perdida > 0) { dMonto_tipoCambio = Math.Round((oPG.Perdida / moneda.SELL_RATE), 2); oGJ_DIST_TRACK = getGJ_DIST_TRACK(iEntry_No++, dMonto_tipoCambio, "CR", oPG.CuentaPerdida, moneda.ID); lstGJ_DIST.Add(oGJ_DIST_TRACK); } } } } return(lstGJ_DIST); }