public Response CreateInvoice(SOPHeader header, SOPDetail[] detail, SOPDistribution[] distribution, SOPCommissions[] commissions, SOPTax[] tax, SopType soptype, string company) { var gpservices = new SOPTransactionClient(); Response response; response = gpservices.CreateSOPTransaction(header, detail, distribution, commissions, tax, soptype, company); gpservices.Close(); return(response); }
public Response TransactionCreate(SOPHeader header, List <SOPDetail> detail, List <SOPDistribution> distribution, List <SOPTax> taxes, List <SOPCommissions> commissions, SopType soptype, string company) { Response response; string server = ConfigKey.ReadSetting("SERVER"); string transactionXML = string.Empty; //var server = Properties.Settings.Default.SERVER.ToString(); string CNX = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096"; var eConnect = new eConnectRequest(); SOPTransactionType sopTranType = new SOPTransactionType(); var getnext = new GetNextDocNumbers(); getnext.RequireServiceProxy = false; string INVOICENUMBER; try { if (header.SOPNUMBE == string.Empty) { INVOICENUMBER = getnext.GetNextSOPNumber(IncrementDecrement.Increment, header.DOCID, soptype, CNX); } else { INVOICENUMBER = header.SOPNUMBE; } sopTranType.taSopHdrIvcInsert = SetHeaderValues(header, INVOICENUMBER); sopTranType.taSopLineIvcInsert_Items = SetDetailValues(detail, INVOICENUMBER); sopTranType.taSopDistribution_Items = SetDistributionValues(distribution, INVOICENUMBER); sopTranType.taSopLineIvcTaxInsert_Items = SetTaxValues(taxes, INVOICENUMBER); sopTranType.taSopCommissions_Items = SetCommissionValues(commissions, INVOICENUMBER); transactionXML = SerializeSOPTransaction(sopTranType); response = eConnect.CreateGPTransaction(CNX, transactionXML); return(response); } catch (Exception) { throw; } }
//public void DoWork() //{ //} /// <summary> /// Create Invoince /// </summary> /// <param name="header"></param> /// <param name="detail"></param> /// <param name="distribution"></param> /// <param name="commissions"></param> /// <param name="taxes"></param> /// <param name="company"></param> /// <returns></returns> public Response CreateSOPTransaction(SOPHeader header, List <SOPDetail> detail, List <SOPDistribution> distribution, List <SOPCommissions> commissions, List <SOPTax> taxes, SopType soptype, string company) { SOPTransactionCreate soptran = new SOPTransactionCreate(); return(soptran.TransactionCreate(header, detail, distribution, taxes, commissions, soptype, company)); }
private taSopHdrIvcInsert SetHeaderValues(SOPHeader header, string invoicenumber) { try { var sopHeaderInsert = new taSopHdrIvcInsert(); sopHeaderInsert.SOPTYPE = header.SOPTYPE; sopHeaderInsert.DOCID = header.DOCID; //sopHeaderInsert.DOCDATE = header.DOCDATE.ToString("dd/MM/yyyy"); sopHeaderInsert.DOCDATE = header.DOCDATE.ToString("yyyy-MM-dd"); sopHeaderInsert.SOPNUMBE = invoicenumber; sopHeaderInsert.ORIGNUMB = header.ORIGNUMB; sopHeaderInsert.ORIGTYPE = header.ORIGTYPE.GetValueOrDefault(); sopHeaderInsert.TAXSCHID = header.TAXSCHID; sopHeaderInsert.FRTSCHID = header.FRTSCHID; sopHeaderInsert.MSCSCHID = header.MSCSCHID; sopHeaderInsert.SHIPMTHD = header.SHIPMTHD; sopHeaderInsert.TAXAMNT = header.TAXAMNT.GetValueOrDefault(); sopHeaderInsert.LOCNCODE = header.LOCNCODE; sopHeaderInsert.FREIGHT = header.FREIGHT.GetValueOrDefault(); sopHeaderInsert.MISCAMNT = header.MISCAMNT.GetValueOrDefault(); sopHeaderInsert.TRDISAMT = header.TRDISAMT.GetValueOrDefault(); sopHeaderInsert.TRADEPCT = header.TRADEPCT.GetValueOrDefault(); sopHeaderInsert.DISTKNAM = header.DISTKNAM.GetValueOrDefault(); sopHeaderInsert.MRKDNAMT = header.MRKDNAMT.GetValueOrDefault(); sopHeaderInsert.CUSTNAME = header.CSTPONBR; sopHeaderInsert.ShipToName = header.ShipToName; sopHeaderInsert.ADDRESS1 = header.ADDRESS1; sopHeaderInsert.ADDRESS2 = header.ADDRESS2; sopHeaderInsert.ADDRESS3 = header.ADDRESS3; sopHeaderInsert.CNTCPRSN = header.CNTCPRSN; sopHeaderInsert.FAXNUMBR = header.FAXNUMBR; sopHeaderInsert.CITY = header.CITY; sopHeaderInsert.STATE = header.STATE; sopHeaderInsert.ZIPCODE = header.ZIPCODE; sopHeaderInsert.COUNTRY = header.COUNTRY; sopHeaderInsert.PHNUMBR1 = header.PHNUMBR1; sopHeaderInsert.PHNUMBR2 = header.PHNUMBR2; sopHeaderInsert.PHNUMBR3 = header.PHNUMBR3; sopHeaderInsert.Print_Phone_NumberGB = 0; sopHeaderInsert.Print_Phone_NumberGBSpecified = true; sopHeaderInsert.SUBTOTAL = header.SUBTOTAL.GetValueOrDefault(); sopHeaderInsert.DOCAMNT = header.DOCAMNT.GetValueOrDefault(); sopHeaderInsert.PYMTRCVD = header.PYMTRCVD.GetValueOrDefault(); sopHeaderInsert.SALSTERR = header.SALSTERR; sopHeaderInsert.SLPRSNID = header.SLPRSNID; sopHeaderInsert.UPSZONE = header.UPSZONE; sopHeaderInsert.USER2ENT = header.USER2ENT; sopHeaderInsert.BACHNUMB = header.BACHNUMB; sopHeaderInsert.PRBTADCD = header.PRBTADCD; sopHeaderInsert.PRSTADCD = header.PRSTADCD; sopHeaderInsert.FRTTXAMT = header.FRTTXAMT.GetValueOrDefault(); sopHeaderInsert.MSCTXAMT = header.MSCTXAMT.GetValueOrDefault(); if (header.ORDRDATE != null) { sopHeaderInsert.ORDRDATE = header.ORDRDATE.GetValueOrDefault().ToString("yyyy-MM-dd"); } sopHeaderInsert.MSTRNUMB = header.MSTRNUMB.GetValueOrDefault(); sopHeaderInsert.PYMTRMID = header.PYMTRMID; if (header.DUEDATE != null) { sopHeaderInsert.DUEDATE = header.DUEDATE.GetValueOrDefault().ToString("yyyy-MM-dd"); } if (header.DISCDATE != null) { sopHeaderInsert.DISCDATE = header.DISCDATE.GetValueOrDefault().ToString("yyyy-MM-dd"); } sopHeaderInsert.REFRENCE = header.REFRENCE; sopHeaderInsert.USINGHEADERLEVELTAXES = header.USINGHEADERLEVELTAXES.GetValueOrDefault(); sopHeaderInsert.BatchCHEKBKID = header.BatchCHEKBKID; sopHeaderInsert.CREATECOMM = header.CREATECOMM.GetValueOrDefault(); sopHeaderInsert.COMMAMNT = header.COMMAMNT; sopHeaderInsert.COMPRCNT = header.COMPRCNT; sopHeaderInsert.CREATEDIST = header.CREATEDIST.GetValueOrDefault(); sopHeaderInsert.CREATETAXES = header.CREATETAXES.GetValueOrDefault(); sopHeaderInsert.DEFTAXSCHDS = header.DEFTAXSCHDS.GetValueOrDefault(); sopHeaderInsert.CURNCYID = header.CURNCYID; sopHeaderInsert.XCHGRATE = header.XCHGRATE.GetValueOrDefault(); sopHeaderInsert.RATETPID = header.RATETPID; if (header.EXPNDATE != null) { sopHeaderInsert.EXPNDATE = header.EXPNDATE.GetValueOrDefault().ToString("yyyy-MM-dd"); } if (header.EXCHDATE != null) { sopHeaderInsert.EXCHDATE = header.EXCHDATE.GetValueOrDefault().ToString("yyyy-MM-dd"); } sopHeaderInsert.EXGTBDSC = header.EXGTBDSC; sopHeaderInsert.EXTBLSRC = header.EXTBLSRC; sopHeaderInsert.RATEEXPR = header.RATEEXPR.GetValueOrDefault(); sopHeaderInsert.DYSTINCR = header.DYSTINCR.GetValueOrDefault(); sopHeaderInsert.RATEVARC = header.RATEVARC.GetValueOrDefault(); sopHeaderInsert.TRXDTDEF = header.TRXDTDEF.GetValueOrDefault(); sopHeaderInsert.RTCLCMTD = header.RTCLCMTD.GetValueOrDefault(); sopHeaderInsert.PRVDSLMT = header.PRVDSLMT.GetValueOrDefault(); sopHeaderInsert.DATELMTS = header.DATELMTS.GetValueOrDefault(); if (header.TIME1 != null) { sopHeaderInsert.TIME1 = header.TIME1.GetValueOrDefault().ToString("yyyy-MM-dd"); } sopHeaderInsert.DISAVAMT = header.DISAVAMT.GetValueOrDefault(); sopHeaderInsert.DSCDLRAM = header.DSCDLRAM.GetValueOrDefault(); sopHeaderInsert.DSCPCTAM = header.DSCPCTAM.GetValueOrDefault(); sopHeaderInsert.FREIGTBLE = header.FREIGTBLE.GetValueOrDefault(); sopHeaderInsert.MISCTBLE = header.MISCTBLE.GetValueOrDefault(); sopHeaderInsert.COMMNTID = header.COMMNTID; sopHeaderInsert.COMMENT_1 = header.COMMENT_1; sopHeaderInsert.COMMENT_2 = header.COMMENT_2; sopHeaderInsert.COMMENT_3 = header.COMMENT_3; sopHeaderInsert.COMMENT_4 = header.COMMENT_4; sopHeaderInsert.GPSFOINTEGRATIONID = header.GPSFOINTEGRATIONID; sopHeaderInsert.INTEGRATIONSOURCE = header.INTEGRATIONSOURCE.GetValueOrDefault(); sopHeaderInsert.INTEGRATIONID = header.INTEGRATIONID; if (header.ReqShipDate != null) { sopHeaderInsert.ReqShipDate = header.ReqShipDate.GetValueOrDefault().ToString("yyyy-MM-dd"); } sopHeaderInsert.RequesterTrx = header.RequesterTrx.GetValueOrDefault(); sopHeaderInsert.CKCreditLimit = header.CKCreditLimit.GetValueOrDefault(); sopHeaderInsert.CKHOLD = header.CKHOLD.GetValueOrDefault(); sopHeaderInsert.UpdateExisting = header.UpdateExisting.GetValueOrDefault(); if (header.QUOEXPDA != null) { sopHeaderInsert.QUOEXPDA = header.QUOEXPDA.GetValueOrDefault().ToShortDateString(); } if (header.QUOTEDAT != null) { sopHeaderInsert.QUOTEDAT = header.QUOTEDAT.GetValueOrDefault().ToShortDateString(); } if (header.INVODATE != null) { sopHeaderInsert.INVODATE = header.INVODATE.GetValueOrDefault().ToShortDateString(); } if (header.BACKDATE != null) { sopHeaderInsert.BACKDATE = header.BACKDATE.GetValueOrDefault().ToShortDateString(); } if (header.RETUDATE != null) { sopHeaderInsert.RETUDATE = header.RETUDATE.GetValueOrDefault().ToShortDateString(); } sopHeaderInsert.CMMTTEXT = header.CMMTTEXT; sopHeaderInsert.PRCLEVEL = header.PRCLEVEL; sopHeaderInsert.DEFPRICING = header.DEFPRICING.GetValueOrDefault(); sopHeaderInsert.TAXEXMT1 = header.TAXEXMT1; sopHeaderInsert.TAXEXMT2 = header.TAXEXMT2; sopHeaderInsert.TXRGNNUM = header.TXRGNNUM; sopHeaderInsert.REPTING = header.REPTING.GetValueOrDefault(); sopHeaderInsert.TRXFREQU = header.TRXFREQU.GetValueOrDefault(); sopHeaderInsert.TIMETREP = header.TIMETREP.GetValueOrDefault(); sopHeaderInsert.QUOTEDYSTINCR = header.QUOTEDYSTINCR.GetValueOrDefault(); sopHeaderInsert.NOTETEXT = header.NOTETEXT; sopHeaderInsert.CUSTNMBR = header.CUSTNMBR; return(sopHeaderInsert); } catch (Exception) { throw; } }