Example #1
0
        public CreditNoteLineType[] getCreditNoteLine()
        {
            CreditNoteLineType HILT = new CreditNoteLineType();

            CreditNoteLineType[] MILT = new CreditNoteLineType[VD.li];

            for (int i = 0; i < VD.li; ++i)
            {
                MILT[i] = new CreditNoteLineType();

                IDType HIT = new IDType();
                HIT.Value  = (i + 1).ToString();
                MILT[i].ID = HIT;

                CreditedQuantityType HIQT = new CreditedQuantityType();
                HIQT.unitCode            = Interface["LnUndMed" + (i + 1)];
                HIQT.unitCodeSpecified   = true;
                HIQT.Value               = Interface["LnCantidad" + (i + 1)];
                MILT[i].CreditedQuantity = 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()
                                    {
                                        //credit note igv
                                        //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 igv
                                        //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);
        }
        /// <summary>
        ///  Mühtahsil Makbuz (Credit Note) UBL'inin DespatchLine alanlarını oluşturma.Birden fazla
        /// CreditNoteLine alanı oluşturulabilir.
        /// </summary>
        /// <returns>DespatchLine Listesi</returns>
        private CreditNoteLineType[] GetCreditNoteLine(int kalemSayisi)
        {
            List <CreditNoteLineType> list = new List <CreditNoteLineType>();

            for (int i = 1; i <= kalemSayisi; i++)
            {
                CreditNoteLineType creditNoteLine = new CreditNoteLineType()
                {
                    ID = new IDType {
                        Value = i.ToString()
                    },
                    Note = new[] { new NoteType {
                                       Value = ""
                                   } },
                    CreditedQuantity = new CreditedQuantityType {
                        unitCode = "C62", Value = 10
                    },
                    Price = new PriceType {
                        PriceAmount = new PriceAmountType {
                            currencyID = "TRY", Value = 3M
                        }
                    },
                    Delivery            = new DeliveryType[] {},
                    LineExtensionAmount = new LineExtensionAmountType {
                        currencyID = "TRY", Value = 30m
                    },
                    DeliveryTerms = new DeliveryTermsType[] { },
                    PaymentTerms  = new PaymentTermsType[] {  },
                    TaxTotal      = new TaxTotalType[] { new TaxTotalType {
                                                             TaxAmount = new TaxAmountType
                                                             {
                                                                 currencyID = "TRY",
                                                                 Value      = 0.30M
                                                             },

                                                             TaxSubtotal = new[]
                                                             {
                                                                 new TaxSubtotalType
                                                                 {
                                                                     TaxableAmount = new TaxableAmountType
                                                                     {
                                                                         currencyID = "TRY",
                                                                         Value      = 30.00M
                                                                     },

                                                                     TaxAmount = new TaxAmountType
                                                                     {
                                                                         currencyID = "TRY",
                                                                         Value      = 0.30M
                                                                     },
                                                                     CalculationSequenceNumeric = new CalculationSequenceNumericType
                                                                     {
                                                                         Value = 1
                                                                     },

                                                                     Percent = new PercentType1 {
                                                                         Value = 1
                                                                     },

                                                                     TaxCategory = new TaxCategoryType
                                                                     {
                                                                         TaxScheme = new TaxSchemeType
                                                                         {
                                                                             Name = new NameType1 {
                                                                                 Value = "KDV"
                                                                             },
                                                                             TaxTypeCode = new TaxTypeCodeType {
                                                                                 Value = "0015"
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         } },
                    AllowanceCharge = new AllowanceChargeType[] { new AllowanceChargeType
                                                                  {
                                                                      ChargeIndicator = new ChargeIndicatorType {
                                                                          Value = false
                                                                      },
                                                                      MultiplierFactorNumeric = new MultiplierFactorNumericType {
                                                                          Value = 0
                                                                      },

                                                                      Amount = new AmountType2
                                                                      {
                                                                          currencyID = "TRY",
                                                                          Value      = 0.00M
                                                                      },

                                                                      BaseAmount = new BaseAmountType
                                                                      {
                                                                          currencyID = "TRY",
                                                                          Value      = 0
                                                                      }
                                                                  } },

                    Item = new ItemType
                    {
                        Name = new NameType1 {
                            Value = "ELMA TOHUMU"
                        },
                        SellersItemIdentification = new ItemIdentificationType
                        {
                            ID = new IDType {
                                Value = "APP1234"
                            }
                        }
                    }
                };

                list.Add(creditNoteLine);
            }

            return(list.ToArray());
        }
Example #3
0
        void LlenarDetalle(En_ComprobanteElectronico Comprobante, ref CreditNoteType creditNote)
        {
            List <CreditNoteLineType> oListaDetalle = new List <CreditNoteLineType>();

            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);
                }

                CreditNoteLineType oInvoiceLine = new CreditNoteLineType
                {
                    ID = new IDType
                    {
                        Value = oDet.Item.ToString()
                    },
                    CreditedQuantity = new CreditedQuantityType
                    {
                        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);
            }
            ;
            creditNote.CreditNoteLine = oListaDetalle.ToArray();
        }