private void CreateReceivablesCreditMemo(int KeyCompany, DataTable tblVenta, string sCultureName, int RecordPos, string sChequera) { Context Context = new Context(); Context.OrganizationKey = (OrganizationKey) new CompanyKey() { Id = KeyCompany }; Context.CultureName = sCultureName; ReceivablesDocumentKey receivablesDocumentKey = new ReceivablesDocumentKey(); CustomerKey customerKey = new CustomerKey(); customerKey.Id = Convert.ToString(tblVenta.Rows[RecordPos]["idCliente"]); BatchKey batchKey = new BatchKey(); batchKey.Id = tblVenta.Rows[RecordPos]["IDLote"].ToString(); MoneyAmount moneyAmount = new MoneyAmount(); moneyAmount.Currency = Convert.ToString(tblVenta.Rows[RecordPos]["IDMoneda"]); moneyAmount.Value = Convert.ToDecimal(tblVenta.Rows[RecordPos]["MontoXCobrar"]); ReceivablesCreditMemo receivablesCreditMemo = new ReceivablesCreditMemo(); string str = tblVenta.Rows[RecordPos]["NoDocumento"].ToString(); receivablesDocumentKey.Id = str; receivablesCreditMemo.Key = receivablesDocumentKey; if (tblVenta.Rows[RecordPos]["Fecha"].ToString() != "") { receivablesCreditMemo.Date = new DateTime?(Convert.ToDateTime(tblVenta.Rows[RecordPos]["Fecha"])); } receivablesCreditMemo.BatchKey = batchKey; receivablesCreditMemo.CustomerKey = customerKey; receivablesCreditMemo.SalesAmount = moneyAmount; Policy policyByOperation = this.wsDynamicsGP.GetPolicyByOperation("CreateReceivablesCreditMemo", Context); this.wsDynamicsGP.CreateReceivablesCreditMemo(receivablesCreditMemo, Context, policyByOperation); }
private void CreateReceivablesInvoice(int KeyCompany, DataTable tblVenta, string sCultureName, int RecordPos, string sChequera) { Context Context = new Context(); Context.OrganizationKey = (OrganizationKey) new CompanyKey() { Id = KeyCompany }; Context.CultureName = sCultureName; ReceivablesDocumentKey receivablesDocumentKey = new ReceivablesDocumentKey(); CustomerKey customerKey = new CustomerKey(); customerKey.Id = Convert.ToString(tblVenta.Rows[RecordPos]["idCliente"]); BatchKey batchKey = new BatchKey(); batchKey.Id = tblVenta.Rows[RecordPos]["IDLote"].ToString(); MoneyAmount moneyAmount1 = new MoneyAmount(); MoneyAmount moneyAmount2 = new MoneyAmount(); moneyAmount2.Currency = Convert.ToString(tblVenta.Rows[RecordPos]["IDMoneda"]); moneyAmount2.Value = Convert.ToDecimal(tblVenta.Rows[RecordPos]["MontoXCobrar"]); MoneyAmount moneyAmount3 = new MoneyAmount(); moneyAmount3.Currency = Convert.ToString(tblVenta.Rows[RecordPos]["IDMoneda"]); if (tblVenta.Rows[RecordPos]["CostoCobrar"].ToString() != "") { moneyAmount3.Value = Convert.ToDecimal(tblVenta.Rows[RecordPos]["CostoCobrar"]); } MoneyAmount moneyAmount4 = new MoneyAmount(); moneyAmount4.Currency = Convert.ToString(tblVenta.Rows[RecordPos]["IDMoneda"].ToString()); if (tblVenta.Rows[RecordPos]["Impuestos"].ToString() != "") { moneyAmount4.Value = Convert.ToDecimal(tblVenta.Rows[RecordPos]["Impuestos"]); } ReceivablesInvoice receivablesInvoice = new ReceivablesInvoice(); string str = tblVenta.Rows[RecordPos]["NoDocumento"].ToString(); receivablesDocumentKey.Id = str; receivablesInvoice.Key = receivablesDocumentKey; if (tblVenta.Rows[RecordPos]["Fecha"].ToString() != "") { receivablesInvoice.Date = new DateTime?(Convert.ToDateTime(tblVenta.Rows[RecordPos]["Fecha"])); } receivablesInvoice.BatchKey = batchKey; receivablesInvoice.CustomerKey = customerKey; receivablesInvoice.PaymentTermsKey = new PaymentTermsKey() { Id = "NETO 30" }; if (Convert.ToString(tblVenta.Rows[RecordPos]["NoOrden"]) != "") { receivablesInvoice.CustomerPONumber = Convert.ToString(tblVenta.Rows[RecordPos]["NoOrden"]); } receivablesInvoice.CostAmount = moneyAmount3; receivablesInvoice.TaxAmount = moneyAmount4; receivablesInvoice.SalesAmount = moneyAmount2; if (Convert.ToString(tblVenta.Rows[RecordPos]["MontoRecibido"]) != "" && Convert.ToDecimal(tblVenta.Rows[RecordPos]["MontoRecibido"]) != new Decimal(0)) { moneyAmount1.Currency = Convert.ToString(tblVenta.Rows[RecordPos]["IDMoneda"]); moneyAmount1.Value = Convert.ToDecimal(tblVenta.Rows[RecordPos]["MontoRecibido"]); receivablesInvoice.Payment = new ReceivablesPayment(); receivablesInvoice.Payment.Cash = new CashDetail(); receivablesInvoice.Payment.Cash.Amount = moneyAmount1; receivablesInvoice.Payment.Cash.BankAccountKey = new BankAccountKey(); receivablesInvoice.Payment.Cash.BankAccountKey.Id = sChequera; receivablesInvoice.Payment.Cash.Date = new DateTime?(Convert.ToDateTime(tblVenta.Rows[RecordPos]["Fecha"])); receivablesInvoice.Payment.Cash.Number = str; } Policy policyByOperation = this.wsDynamicsGP.GetPolicyByOperation("CreateReceivablesInvoice", Context); this.wsDynamicsGP.CreateReceivablesInvoice(receivablesInvoice, Context, policyByOperation); }