void LlenarDetalle(En_ComprobanteElectronico Comprobante, ref DebitNoteType debitNote) { List <DebitNoteLineType> oListaDetalle = new List <DebitNoteLineType>(); foreach (En_ComprobanteDetalle oDet in Comprobante.ComprobanteDetalle) { List <DescriptionType> oListaDescripcion = new List <DescriptionType>(); DescriptionType oDescripcion = new DescriptionType(); oDescripcion.Value = oDet.Descripcion; oListaDescripcion.Add(oDescripcion); foreach (string oDes in oDet.MultiDescripcion) { DescriptionType oDescrip = new DescriptionType(); oDescrip.Value = oDes.ToString(); oListaDescripcion.Add(oDescrip); } List <TaxSubtotalType> oListaSubtotal = new List <TaxSubtotalType>(); foreach (En_ComprobanteDetalleImpuestos odetImpuesto in oDet.ComprobanteDetalleImpuestos) { TaxSubtotalType oSubTotal = new TaxSubtotalType(); oSubTotal = LlenarSubTotalDetalle(odetImpuesto.MontoBase, odetImpuesto.MontoTotalImpuesto, Comprobante.Moneda.Trim(), odetImpuesto.Porcentaje, odetImpuesto.CodigoInternacionalTributo, odetImpuesto.NombreTributo, odetImpuesto.CodigoTributo, odetImpuesto.AfectacionIGV); oListaSubtotal.Add(oSubTotal); } DebitNoteLineType oInvoiceLine = new DebitNoteLineType { ID = new IDType { Value = oDet.Item.ToString() }, DebitedQuantity = new DebitedQuantityType { unitCode = oDet.UnidadMedida.Trim().ToUpper(), unitCodeListAgencyName = "United Nations Economic Commission for Europe", unitCodeListID = "UN/ECE rec 20", Value = oDet.Cantidad }, LineExtensionAmount = new LineExtensionAmountType { Value = oDet.Total, currencyID = Comprobante.Moneda.Trim() }, PricingReference = new PricingReferenceType { AlternativeConditionPrice = new PriceType[] { new PriceType { PriceAmount = new PriceAmountType { Value = oDet.ValorVentaUnitarioIncIgv, currencyID = Comprobante.Moneda.Trim() }, PriceTypeCode = new PriceTypeCodeType { Value = oDet.CodigoTipoPrecio, listAgencyName = "PE:SUNAT", listName = "Tipo de Precio", listURI = "urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16" } } } }, TaxTotal = new TaxTotalType[] { new TaxTotalType { TaxAmount = new TaxAmountType { Value = oDet.ImpuestoTotal, currencyID = Comprobante.Moneda.Trim() }, TaxSubtotal = oListaSubtotal.ToArray() } }, Price = new PriceType { PriceAmount = new PriceAmountType { Value = oDet.ValorVentaUnitario, currencyID = Comprobante.Moneda.Trim() } }, Item = new ItemType { Description = oListaDescripcion.ToArray(), SellersItemIdentification = new ItemIdentificationType { ID = new IDType { Value = oDet.Codigo } }, CommodityClassification = new CommodityClassificationType[] { new CommodityClassificationType { CommodityCode = new CommodityCodeType { listAgencyName = "GS1 US", listID = "UNSPSC", listName = "Item Classification", Value = oDet.CodigoSunat } } } } }; oListaDetalle.Add(oInvoiceLine); } ; debitNote.DebitNoteLine = oListaDetalle.ToArray(); }
public DebitNoteLineType[] getDebitNoteLine() { DebitNoteLineType HILT = new DebitNoteLineType(); DebitNoteLineType[] MILT = new DebitNoteLineType[VD.li]; for (int i = 0; i < VD.li; ++i) { MILT[i] = new DebitNoteLineType(); IDType HIT = new IDType(); HIT.Value = (i + 1).ToString(); MILT[i].ID = HIT; DebitedQuantityType HIQT = new DebitedQuantityType(); HIQT.unitCode = Interface["LnUndMed" + (i + 1)]; HIQT.unitCodeSpecified = true; HIQT.Value = Interface["LnCantidad" + (i + 1)]; MILT[i].DebitedQuantity = HIQT; LineExtensionAmountType HLEAT = new LineExtensionAmountType(); HLEAT.currencyID = Interface["Tmoneda"]; HLEAT.Value = Interface["LnValVta" + (i + 1)]; MILT[i].LineExtensionAmount = HLEAT; PricingReferenceType HPRT = new PricingReferenceType(); PricingReferenceType[] MRPT = { HPRT, HPRT }; PriceType HPCT = new PriceType(); PriceType[] MPCT = null; PriceAmountType HXPT = new PriceAmountType(); if (Interface["LnCodAfecIGV" + (i + 1)] == "10" || Interface["LnCodAfecIGV" + (i + 1)] == "20" || Interface["LnCodAfecIGV" + (i + 1)] == "30" || Interface["LnCodAfecIGV" + (i + 1)] == "40") { MPCT = new PriceType[] { new PriceType() { PriceAmount = new PriceAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntPrcVta" + (i + 1)] }, PriceTypeCode = new PriceTypeCodeType() { Value = "01" } } }; } else { MPCT = new PriceType[] { new PriceType() { PriceAmount = new PriceAmountType() { currencyID = Interface["Tmoneda"], Value = "0.00" }, PriceTypeCode = new PriceTypeCodeType() { Value = "01" } }, new PriceType() { PriceAmount = new PriceAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntPrcVta" + (i + 1)] }, PriceTypeCode = new PriceTypeCodeType() { Value = "02" } }, }; } MRPT[0].AlternativeConditionPrice = MPCT; MILT[i].PricingReference = MRPT[0]; // TAX TOTAL double o = 0; double.TryParse(Interface["LnMntISC" + (i + 1)], out o); var igvPercent = Interface["LnIgvPercentage" + (i + 1)]; if (igvPercent == null || igvPercent.Length == 0) { igvPercent = "18.00"; } if (o > 0) { MILT[i].TaxTotal = new TaxTotalType[] { new TaxTotalType() { TaxAmount = new TaxAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntIGV" + (i + 1)] }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType() { TaxableAmount = new TaxableAmountType() { currencyID = Interface["Tmoneda"], Value = "0.00" }, TaxAmount = new TaxAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntIGV" + (i + 1)] }, Percent = new PercentType() { //Value = "18.00" Value = igvPercent }, TaxCategory = new TaxCategoryType() { TaxExemptionReasonCode = new TaxExemptionReasonCodeType() { Value = Interface["LnCodAfecIGV" + (i + 1)] }, TaxScheme = new TaxSchemeType() { ID = new IDType() { Value = "1000" }, Name = new NameType1() { Value = "IGV" }, TaxTypeCode = new TaxTypeCodeType() { Value = "VAT" } } } } } }, new TaxTotalType() { TaxAmount = new TaxAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntISC" + (i + 1)] }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType() { TaxableAmount = new TaxableAmountType() { currencyID = Interface["Tmoneda"], Value = "0.00" }, TaxAmount = new TaxAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntISC" + (i + 1)] }, TaxCategory = new TaxCategoryType() { TaxExemptionReasonCode = new TaxExemptionReasonCodeType() { Value = "" }, TierRange = new TierRangeType() { Value = Interface["LnCodSisISC" + (i + 1)] }, TaxScheme = new TaxSchemeType() { ID = new IDType() { Value = "2000" }, Name = new NameType1() { Value = "ISC" }, TaxTypeCode = new TaxTypeCodeType() { Value = "EXC" } } } } } } }; } else { MILT[i].TaxTotal = new TaxTotalType[] { new TaxTotalType() { TaxAmount = new TaxAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntIGV" + (i + 1)] }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType() { TaxableAmount = new TaxableAmountType() { currencyID = Interface["Tmoneda"], Value = "0.00" }, TaxAmount = new TaxAmountType() { currencyID = Interface["Tmoneda"], Value = Interface["LnMntIGV" + (i + 1)] }, Percent = new PercentType() { //Credit note value //Value = "18.00" Value = igvPercent }, TaxCategory = new TaxCategoryType() { TaxExemptionReasonCode = new TaxExemptionReasonCodeType() { Value = Interface["LnCodAfecIGV" + (i + 1)] }, TaxScheme = new TaxSchemeType() { ID = new IDType() { Value = "1000" }, Name = new NameType1() { Value = "IGV" }, TaxTypeCode = new TaxTypeCodeType() { Value = "VAT" } } } } } } }; } // PRICE HPCT = null; HPCT = new PriceType(); HXPT = null; HXPT = new PriceAmountType(); HXPT.currencyID = Interface["Tmoneda"]; HXPT.Value = Interface["LnValUnit" + (i + 1)]; HPCT.PriceAmount = HXPT; MILT[i].Price = HPCT; // ITEM ItemType HIMT = new ItemType(); DescriptionType HDT = new DescriptionType(); DescriptionType[] MDT = { HDT }; MDT[0].Value = "<![CDATA[" + Interface["LnDescrip" + (i + 1)] + "]]>"; ItemIdentificationType HIIT = new ItemIdentificationType(); HIT = null; HIT = new IDType(); HIT.Value = "<![CDATA[" + Interface["LnCodProd" + (i + 1)] + "]]>"; HIIT.ID = HIT; HIMT.Description = MDT; HIMT.SellersItemIdentification = HIIT; MILT[i].Item = HIMT; } return(MILT); }