/// <summary> /// Set values for each Distribution class /// </summary> /// <param name="Dist"></param> /// <param name="VCHRNUMBER"></param> /// <returns></returns> private taPMDistribution_ItemsTaPMDistribution[] SetDistributionValues(PMTransactionDist[] Dist, string VCHRNUMBER) { int index = 0; try { taPMDistribution_ItemsTaPMDistribution[] TransactionDist = new taPMDistribution_ItemsTaPMDistribution[Dist.Length]; foreach (PMTransactionDist distribution in Dist) { var TransactionDistribution = new taPMDistribution_ItemsTaPMDistribution { DOCTYPE = distribution.DOCTYPE, VCHRNMBR = VCHRNUMBER, VENDORID = distribution.VENDORID, DSTSQNUM = distribution.DSTSQNUM, DISTTYPE = distribution.DISTTYPE, DistRef = distribution.DistRef, ACTINDX = distribution.ACTINDX, ACTNUMST = distribution.ACTNUMST, DEBITAMT = distribution.DEBITAMT, CRDTAMNT = distribution.CRDTAMNT, RequesterTrx = distribution.RequesterTrx.GetValueOrDefault() }; TransactionDist[index] = TransactionDistribution; index++; } return(TransactionDist); } catch (Exception) { throw; } }
/// <summary> /// Arma la distribución contable de la factura PM en objeto econnect. /// </summary> /// <param name="param"></param> public void armaDistribucionPmEconn(Parametros param) { try { if (facturaPm.DOCTYPE <= 3) { _distribucionPm[0] = new taPMDistribution_ItemsTaPMDistribution() { DOCTYPE = facturaPm.DOCTYPE, VCHRNMBR = facturaPm.VCHNUMWK, VENDORID = facturaPm.VENDORID, DISTTYPE = 6, DistRef = facturaPm.TRXDSCRN, ACTNUMST = param.DistribucionPmCuentaDebe, DEBITAMT = facturaPm.DOCAMNT, CRDTAMNT = 0 }; _distribucionPm[1] = new taPMDistribution_ItemsTaPMDistribution() { DOCTYPE = facturaPm.DOCTYPE, VCHRNMBR = facturaPm.VCHNUMWK, VENDORID = facturaPm.VENDORID, DISTTYPE = 2, DistRef = facturaPm.TRXDSCRN, ACTNUMST = param.DistribucionPmCuentaHaber, DEBITAMT = 0, CRDTAMNT = facturaPm.DOCAMNT }; } else { _distribucionPm[0] = new taPMDistribution_ItemsTaPMDistribution() { DOCTYPE = facturaPm.DOCTYPE, VCHRNMBR = facturaPm.VCHNUMWK, VENDORID = facturaPm.VENDORID, DISTTYPE = 2, DistRef = facturaPm.TRXDSCRN, ACTNUMST = param.DistribucionPmCuentaHaber, DEBITAMT = facturaPm.DOCAMNT, CRDTAMNT = 0 }; _distribucionPm[1] = new taPMDistribution_ItemsTaPMDistribution() { DOCTYPE = facturaPm.DOCTYPE, VCHRNMBR = facturaPm.VCHNUMWK, VENDORID = facturaPm.VENDORID, DISTTYPE = 6, DistRef = facturaPm.TRXDSCRN, ACTNUMST = param.DistribucionPmCuentaDebe, DEBITAMT = 0, CRDTAMNT = facturaPm.DOCAMNT }; } } catch (Exception errorGral) { throw new ArgumentException(errorGral.Message, "param"); } }
private static void SerializeObject(string filename) { // Create a datetime format object DateTimeFormatInfo dateFormat = new CultureInfo("en-US").DateTimeFormat; try { taPMTransactionInsert PurchInvoice = new taPMTransactionInsert(); PurchInvoice.BACHNUMB = "SAVE"; PurchInvoice.VENDORID = "ACETRAVE0001"; PurchInvoice.DOCAMNT = 500m; PurchInvoice.DOCNUMBR = "15444445"; PurchInvoice.DOCTYPE = 1; PurchInvoice.VCHNUMWK = "8914985"; PurchInvoice.DOCDATE = "01/06/2017"; //System.DateTime.Today.ToString("MM/dd/yyyy", dateFormat); PurchInvoice.PRCHAMNT = 500m; PurchInvoice.MSCCHAMT = 0; PurchInvoice.TAXAMNT = 0; PurchInvoice.FRTAMNT = 0; PurchInvoice.TRDISAMT = 0; PurchInvoice.CHRGAMNT = 500m; PurchInvoice.CREATEDIST = 1; // PurchInvoice.DISAMTAV = 0; taPMDistribution_ItemsTaPMDistribution[] LineItems = new taPMDistribution_ItemsTaPMDistribution[2]; taPMDistribution_ItemsTaPMDistribution invLines = new taPMDistribution_ItemsTaPMDistribution(); invLines.DOCTYPE = 1; // invLines.ACTNUMST = "000-1410-00"; invLines.DEBITAMT = 500m; invLines.DISTTYPE = 6; invLines.VCHRNMBR = PurchInvoice.VCHNUMWK; invLines.VENDORID = PurchInvoice.VENDORID; invLines.ACTINDX = 10; LineItems[0] = invLines; invLines = new taPMDistribution_ItemsTaPMDistribution(); invLines.DOCTYPE = 1; invLines.DISTTYPE = 2; invLines.VCHRNMBR = PurchInvoice.VCHNUMWK; invLines.VENDORID = PurchInvoice.VENDORID; invLines.CRDTAMNT = PurchInvoice.DOCAMNT; invLines.ACTINDX = 35; //Reset the lines LineItems[1] = invLines; PMTransactionType crInvoice = new PMTransactionType(); crInvoice.taPMTransactionInsert = PurchInvoice; crInvoice.taPMDistribution_Items = LineItems; PMTransactionType[] myPMTrancationType = { crInvoice }; eConnectType eConnect = new eConnectType(); eConnect.PMTransactionType = myPMTrancationType; FileStream fs = new FileStream(filename, FileMode.Create); XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding()); // Serialize the eConnect document object to the file using the XmlTextWriter. XmlSerializer serializer = new XmlSerializer(eConnect.GetType()); serializer.Serialize(writer, eConnect); writer.Close(); } //If an eConnect exception occurs, notify the user catch (eConnectException ex) { Console.Write(ex.ToString()); } }