Ejemplo n.º 1
0
        public SummaryDocumentsLineType[] getSummaryDocumentsLine()
        {
            SummaryDocumentsLineType HILT = new SummaryDocumentsLineType();

            SummaryDocumentsLineType[] MILT = new SummaryDocumentsLineType[RBD.Count];

            for (int i = 0; i < RBD.Count; ++i)
            {
                MILT[i] = new SummaryDocumentsLineType();

                LineIDType LIT = new LineIDType();
                LIT.Value      = (i + 1).ToString();
                MILT[i].LineID = LIT;

                DocumentTypeCodeType DTCT = new DocumentTypeCodeType();
                DTCT.Value = RBD[i].TPO_CPE;
                MILT[i].DocumentTypeCode = DTCT;

                IdentifierType IT = new IdentifierType();
                IT.Value = RBD[i].DOC_SER;
                MILT[i].DocumentSerialID = IT;

                IT       = null; IT = new IdentifierType();
                IT.Value = RBD[i].NUM_INI.ToString();
                MILT[i].StartDocumentNumberID = IT;

                IT       = null; IT = new IdentifierType();
                IT.Value = RBD[i].NUM_FIN.ToString();
                MILT[i].EndDocumentNumberID = IT;

                AmountType1 AT1 = new AmountType1();
                AT1.Value           = RBD[i].MTO_TOT;
                AT1.currencyID      = CurrencyCodeContentType.PEN;
                MILT[i].TotalAmount = AT1;


                // START - IMPORTES
                PaymentType[]  PT = { null, null, null };
                PaidAmountType PAT; InstructionIDType IIT;



                // IMPORTES - GRAVADOS
                var ImpGravados = Convert.ToDecimal(RBD[i].MTO_GRA, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpGravados > 0)
                {
                    PAT                 = new PaidAmountType();
                    IIT                 = new InstructionIDType();
                    PT[0]               = new PaymentType();
                    PAT.Value           = Convert.ToDecimal(RBD[i].MTO_GRA, CultureInfo.CreateSpecificCulture("es-PE"));
                    PAT.currencyID      = CurrencyCodeContentType.PEN;
                    IIT.Value           = "01";
                    PT[0].PaidAmount    = PAT;
                    PT[0].InstructionID = IIT;
                    PAT                 = null; IIT = null;
                }

                // IMPORTES - EXONERADOS
                var ImpExonerado = Convert.ToDecimal(RBD[i].MTO_EXO, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpExonerado > 0)
                {
                    PAT                 = new PaidAmountType();
                    IIT                 = new InstructionIDType();
                    PT[1]               = new PaymentType();
                    PAT.Value           = Convert.ToDecimal(RBD[i].MTO_EXO, CultureInfo.CreateSpecificCulture("es-PE"));
                    PAT.currencyID      = CurrencyCodeContentType.PEN;
                    IIT.Value           = "02";
                    PT[1].PaidAmount    = PAT;
                    PT[1].InstructionID = IIT;
                    PAT                 = null; IIT = null;
                }


                // IMPORTES - INAFECTO
                var ImpInafecto = Convert.ToDecimal(RBD[i].MTO_INA, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpInafecto > 0)
                {
                    PAT                    = new PaidAmountType();
                    IIT                    = new InstructionIDType();
                    PT[2]                  = new PaymentType();
                    PAT.Value              = Convert.ToDecimal(RBD[i].MTO_INA, CultureInfo.CreateSpecificCulture("es-PE"));
                    PAT.currencyID         = CurrencyCodeContentType.PEN;
                    IIT.Value              = "03";
                    PT[2].PaidAmount       = PAT;
                    PT[2].InstructionID    = IIT;
                    PAT                    = null; IIT = null;
                    MILT[i].BillingPayment = PT;
                }

                // IMPORTES - OTROS CARGOS
                var ImpOtroCargos = Convert.ToDecimal(RBD[i].MTO_OCA, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpOtroCargos > 0)
                {
                    AllowanceChargeType[] ACT = { null };
                    ACT[0] = new AllowanceChargeType();

                    ChargeIndicatorType CIT = new ChargeIndicatorType();
                    CIT.Value = true;
                    ACT[0].ChargeIndicator = CIT;

                    AT1                     = null; AT1 = new AmountType1();
                    AT1.Value               = Convert.ToDecimal(RBD[i].MTO_OCA, CultureInfo.CreateSpecificCulture("es-PE"));
                    AT1.currencyID          = CurrencyCodeContentType.PEN;
                    ACT[0].Amount           = AT1;
                    MILT[i].AllowanceCharge = ACT;
                }
                // END - IMPORTES

                // START - TAXTOTAL
                TaxTotalType[]    TTP  = { null, null, null };
                TaxAmountType     TAT  = null;
                TaxSubtotalType[] TST  = { null };
                TaxSubtotalType[] TST2 = { null };
                TaxSubtotalType[] TST3 = { null };
                TaxCategoryType   TCT  = null;
                TaxSchemeType     THT  = null;
                IDType            IDT  = null;
                NameType1         TNT1 = null;
                TaxTypeCodeType   TTCT = null;


                // TOTAL IGV
                IDT        = new IDType();
                IDT.Value  = "1000";
                TNT1       = new NameType1();
                TNT1.Value = "IGV";
                TTCT       = new TaxTypeCodeType();
                TTCT.Value = "VAT";

                THT             = new TaxSchemeType();
                THT.ID          = IDT;
                THT.Name        = TNT1;
                THT.TaxTypeCode = TTCT;

                TCT           = new TaxCategoryType();
                TCT.TaxScheme = THT;

                TAT            = new TaxAmountType();
                TAT.currencyID = CurrencyCodeContentType.PEN;
                TAT.Value      = Convert.ToDecimal(RBD[i].IMP_IGV, CultureInfo.CreateSpecificCulture("es-PE"));

                TST[0]             = new TaxSubtotalType();
                TST[0].TaxAmount   = TAT;
                TST[0].TaxCategory = TCT;

                TTP[0]             = new TaxTotalType();
                TTP[0].TaxAmount   = TAT;
                TTP[0].TaxSubtotal = TST;

                TAT = null; TST = null; TCT = null; THT = null; IDT = null; TNT1 = null; TTCT = null;

                // TOTAL ISC
                IDT        = new IDType();
                IDT.Value  = "2000";
                TNT1       = new NameType1();
                TNT1.Value = "ISC";
                TTCT       = new TaxTypeCodeType();
                TTCT.Value = "EXC";

                THT             = new TaxSchemeType();
                THT.ID          = IDT;
                THT.Name        = TNT1;
                THT.TaxTypeCode = TTCT;

                TCT           = new TaxCategoryType();
                TCT.TaxScheme = THT;

                TAT            = new TaxAmountType();
                TAT.currencyID = CurrencyCodeContentType.PEN;
                TAT.Value      = Convert.ToDecimal(RBD[i].IMP_ISC, CultureInfo.CreateSpecificCulture("es-PE"));

                TST2[0]             = new TaxSubtotalType();
                TST2[0].TaxAmount   = TAT;
                TST2[0].TaxCategory = TCT;

                TTP[1]             = new TaxTotalType();
                TTP[1].TaxAmount   = TAT;
                TTP[1].TaxSubtotal = TST2;

                TAT = null; TST = null; TCT = null; THT = null; IDT = null; TNT1 = null; TTCT = null;

                // TOTAL OTH
                IDT        = new IDType();
                IDT.Value  = "9999";
                TNT1       = new NameType1();
                TNT1.Value = "OTROS";
                TTCT       = new TaxTypeCodeType();
                TTCT.Value = "OTH";

                THT             = new TaxSchemeType();
                THT.ID          = IDT;
                THT.Name        = TNT1;
                THT.TaxTypeCode = TTCT;

                TCT           = new TaxCategoryType();
                TCT.TaxScheme = THT;

                TAT            = new TaxAmountType();
                TAT.currencyID = CurrencyCodeContentType.PEN;
                TAT.Value      = Convert.ToDecimal(RBD[i].IMP_OTH, CultureInfo.CreateSpecificCulture("es-PE"));

                TST3[0]             = new TaxSubtotalType();
                TST3[0].TaxAmount   = TAT;
                TST3[0].TaxCategory = TCT;

                TTP[2]             = new TaxTotalType();
                TTP[2].TaxAmount   = TAT;
                TTP[2].TaxSubtotal = TST3;

                TAT = null; TST = null; TCT = null; THT = null; IDT = null; TNT1 = null; TTCT = null;

                MILT[i].TaxTotal = TTP;
                // END - TAXTOTAL
            }
            return(MILT);
        }
Ejemplo n.º 2
0
        private SummaryDocumentsLineType GetLineRC(RBoletasDetalle det, int i, string typerc)
        {
            detOk  = false;
            HILT_s = new SummaryDocumentsLineType();

            try
            {
                #region alter js

                LineIDType LIT = new LineIDType();
                LIT.Value = (i + 1).ToString();

                HILT_s.LineID = LIT;

                //tipo de documento (03, 07, 08)
                DocumentTypeCodeType DTCT = new DocumentTypeCodeType();
                DTCT.Value = RBD[i].TPO_CPE;
                HILT_s.DocumentTypeCode = DTCT;

                #region condition code

                StatusType        StatusTP  = new StatusType();
                ConditionCodeType Condition = new ConditionCodeType();
                RBD[i].ConditionCode = 0;

                if (RBD[i].ConditionCode == 0)
                {
                    if (typerc != "ANS")
                    {
                        Condition.Value = "1";
                    }
                    else
                    {
                        Condition.Value = "3";
                        #region other
                        //switch (RBD[i].SYSTEM_STATUS)
                        //{
                        //    case "XGN":
                        //        {
                        //            //Condition.Value = "1";
                        //            break;
                        //        }
                        //    case "ANS":
                        //        {
                        //            Condition.Value = "3";
                        //            //var res = ADE.Extras.Common.Method.Methods.Instance.DateCompare(DateTime.Now.ToString("yyyy-MM-dd"), RBD[i].FEC_EMIS.ToString("yyyy-MM-dd"));
                        //            //if (res == 1)
                        //            //{ Condition.Value = "3"; }
                        //            //else
                        //            ////{ Condition.Value = "4"; }
                        //            //{ Condition.Value = "3"; }
                        //            break;
                        //        }
                        //}
                        #endregion
                    }
                    ListDocs.Add(new Extras.Common.Method.UtilClass()
                    {
                        NUM_CE = RBD[i].NUM_CPE, STATUS_RC_DOC = int.Parse(Condition.Value)
                    });
                }


                StatusTP.ConditionCode = Condition;
                HILT_s.Status          = new StatusType();
                HILT_s.Status          = StatusTP;
                #endregion

                //ID (xxxx-xxxxxxxx)
                IDType IdDocumentType = new IDType();
                IdDocumentType.Value = RBD[i].ID;
                HILT_s.ID            = new IDType();
                HILT_s.ID            = IdDocumentType;

                //added js
                AmountType1 TotAmount = new AmountType1();
                TotAmount.Value      = RBD[i].MTO_TOT;
                TotAmount.currencyID = CurrencyCodeContentType.PEN;
                TotAmount.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;
                HILT_s.TotalAmount   = TotAmount;//total documento

                CustomerPartyType CPT = new CustomerPartyType();
                CPT.CustomerAssignedAccountID       = new CustomerAssignedAccountIDType();
                CPT.CustomerAssignedAccountID.Value = RBD[i].CustomerAssignedAccountID;

                AdditionalAccountIDType   AAID  = new AdditionalAccountIDType();
                AdditionalAccountIDType[] AAIDs = new AdditionalAccountIDType[1];

                AAID.Value = RBD[i].AdditionalAccountID;
                AAIDs[0]   = AAID;

                CPT.AdditionalAccountID = AAIDs;

                HILT_s.AccountingCustomerParty = CPT;

                PaymentType[] billingPayment = new PaymentType[4];

                PaymentType       bp_item        = new PaymentType();
                InstructionIDType idInsType      = new InstructionIDType();
                PaidAmountType    paidAmountType = new PaidAmountType();

                #region START - IMPORTES

                // IMPORTES - GRAVADO
                var ImpGravado = Convert.ToDecimal(RBD[i].MTO_GRA, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpGravado > 0)
                {
                    bp_item        = new PaymentType();
                    idInsType      = new InstructionIDType();
                    paidAmountType = new PaidAmountType();

                    idInsType.Value      = "01";
                    paidAmountType.Value = Convert.ToDecimal(RBD[i].MTO_GRA, CultureInfo.CreateSpecificCulture("es-PE"));
                    //paidAmountType.currencyID = CurrencyCodeContentType.PEN;
                    paidAmountType.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                    bp_item.PaidAmount    = paidAmountType;
                    bp_item.InstructionID = idInsType;

                    billingPayment[0] = bp_item;
                }

                // IMPORTES - EXONERADOS
                var ImpExonerado = Convert.ToDecimal(RBD[i].MTO_EXO, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpExonerado > 0)
                {
                    bp_item        = new PaymentType();
                    idInsType      = new InstructionIDType();
                    paidAmountType = new PaidAmountType();

                    idInsType.Value      = "02";
                    paidAmountType.Value = Convert.ToDecimal(RBD[i].MTO_EXO, CultureInfo.CreateSpecificCulture("es-PE"));
                    //paidAmountType.currencyID = CurrencyCodeContentType.PEN;
                    paidAmountType.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                    bp_item.PaidAmount    = paidAmountType;
                    bp_item.InstructionID = idInsType;

                    billingPayment[1] = bp_item;
                }

                // IMPORTES - INAFECTO
                var ImpInafecto = Convert.ToDecimal(RBD[i].MTO_INA, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpInafecto > 0)
                {
                    bp_item        = new PaymentType();
                    idInsType      = new InstructionIDType();
                    paidAmountType = new PaidAmountType();

                    idInsType.Value      = "03";
                    paidAmountType.Value = Convert.ToDecimal(RBD[i].MTO_INA, CultureInfo.CreateSpecificCulture("es-PE"));
                    //paidAmountType.currencyID = CurrencyCodeContentType.PEN;
                    paidAmountType.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                    bp_item.PaidAmount    = paidAmountType;
                    bp_item.InstructionID = idInsType;

                    billingPayment[2] = bp_item;
                }

                // IMPORTES - GRATUITAS
                var ImpGratuitas = Convert.ToDecimal(RBD[i].MON_GRAT, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpGratuitas > 0)
                {
                    bp_item        = new PaymentType();
                    idInsType      = new InstructionIDType();
                    paidAmountType = new PaidAmountType();

                    idInsType.Value      = "05";
                    paidAmountType.Value = Convert.ToDecimal(RBD[i].MON_GRAT, CultureInfo.CreateSpecificCulture("es-PE"));
                    //paidAmountType.currencyID = CurrencyCodeContentType.PEN;
                    paidAmountType.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                    bp_item.PaidAmount    = paidAmountType;
                    bp_item.InstructionID = idInsType;

                    billingPayment[3] = bp_item;
                }

                HILT_s.BillingPayment = billingPayment;

                // IMPORTES - OTROS CARGOS
                var ImpOtroCargos = Convert.ToDecimal(RBD[i].MTO_OCA, CultureInfo.CreateSpecificCulture("es-PE"));
                if (ImpOtroCargos > 0)
                {
                    AllowanceChargeType[] allowCharge = new AllowanceChargeType[1];
                    AmountType1           AT1         = new AmountType1();

                    ChargeIndicatorType CIT = new ChargeIndicatorType();
                    CIT.Value = true;


                    allowCharge[0] = new AllowanceChargeType();
                    allowCharge[0].ChargeIndicator = new ChargeIndicatorType();

                    allowCharge[0].ChargeIndicator = CIT;

                    AT1       = null; AT1 = new AmountType1();
                    AT1.Value = Convert.ToDecimal(RBD[i].MTO_OCA, CultureInfo.CreateSpecificCulture("es-PE"));
                    //AT1.currencyID = CurrencyCodeContentType.PEN;
                    AT1.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                    allowCharge[0].Amount = AT1;

                    HILT_s.AllowanceCharge    = new AllowanceChargeType[1];
                    HILT_s.AllowanceCharge[0] = new AllowanceChargeType();

                    HILT_s.AllowanceCharge[0] = allowCharge[0];
                }

                #endregion END IMPORTES

                #region START IMPUESTOS
                TaxTotalType[] TOTs;// = new TaxTotalType[3];
                TOTs = new TaxTotalType[3];

                TaxTotalType    TOT   = new TaxTotalType();
                TaxAmountType   TAT   = new TaxAmountType();
                TaxSubtotalType TST   = new TaxSubtotalType();
                TaxCategoryType TCT   = new TaxCategoryType();
                TaxSchemeType   TSchT = new TaxSchemeType();

                TaxSubtotalType[] TsTi;// = new TaxSubtotalType[3];


                IDType          IDsch    = new IDType();
                NameType1       nameType = new NameType1();
                TaxTypeCodeType tTCt     = new TaxTypeCodeType();


                //IMP IGV
                //var imp_igv = Convert.ToDecimal(RBD[i].IMP_IGV, CultureInfo.CreateSpecificCulture("es-PE"));
                //if (imp_igv > 0)
                //{
                TOT   = new TaxTotalType();
                TAT   = new TaxAmountType();
                TST   = new TaxSubtotalType();
                TCT   = new TaxCategoryType();
                TSchT = new TaxSchemeType();
                TsTi  = new TaxSubtotalType[1];

                //IDType IDsch = new IDType();
                //NameType1 nameType = new NameType1();
                //TaxTypeCodeType tTCt = new TaxTypeCodeType();

                IDsch    = new IDType();
                nameType = new NameType1();
                tTCt     = new TaxTypeCodeType();

                TAT.Value = Convert.ToDecimal(RBD[i].IMP_IGV, CultureInfo.CreateSpecificCulture("es-PE"));
                //TAT.currencyID = CurrencyCodeContentType.PEN;
                TAT.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                IDsch.Value    = "1000";
                nameType.Value = "IGV";
                tTCt.Value     = "VAT";

                TSchT.ID          = IDsch;
                TSchT.Name        = nameType;
                TSchT.TaxTypeCode = tTCt;
                TCT.TaxScheme     = TSchT;
                TST.TaxAmount     = TAT;
                TST.TaxCategory   = TCT;
                TOT.TaxAmount     = TAT;
                TsTi[0]           = TST;

                TOT.TaxSubtotal = TsTi;
                TOTs[0]         = TOT;

                //}

                //IMP ISC
                //var imp_isc = Convert.ToDecimal(RBD[i].IMP_ISC, CultureInfo.CreateSpecificCulture("es-PE"));
                //if (imp_isc > 0)
                //{
                TOT   = new TaxTotalType();
                TAT   = new TaxAmountType();
                TST   = new TaxSubtotalType();
                TCT   = new TaxCategoryType();
                TSchT = new TaxSchemeType();
                TsTi  = new TaxSubtotalType[1];

                //IDType IDsch = new IDType();
                //NameType1 nameType = new NameType1();
                //TaxTypeCodeType tTCt = new TaxTypeCodeType();

                IDsch    = new IDType();
                nameType = new NameType1();
                tTCt     = new TaxTypeCodeType();

                TAT.Value = Convert.ToDecimal(RBD[i].IMP_ISC, CultureInfo.CreateSpecificCulture("es-PE"));
                //TAT.currencyID = CurrencyCodeContentType.PEN;
                TAT.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                IDsch.Value    = "2000";
                nameType.Value = "ISC";
                tTCt.Value     = "EXC";

                TSchT.ID          = IDsch;
                TSchT.Name        = nameType;
                TSchT.TaxTypeCode = tTCt;
                TCT.TaxScheme     = TSchT;
                TST.TaxAmount     = TAT;
                TST.TaxCategory   = TCT;
                TOT.TaxAmount     = TAT;
                TsTi[0]           = TST;

                TOT.TaxSubtotal = TsTi;
                TOTs[1]         = TOT;

                //}

                //IMP OTH
                var imp_oth = Convert.ToDecimal(RBD[i].IMP_OTH, CultureInfo.CreateSpecificCulture("es-PE"));
                if (imp_oth > 0)
                {
                    TOT   = new TaxTotalType();
                    TAT   = new TaxAmountType();
                    TST   = new TaxSubtotalType();
                    TCT   = new TaxCategoryType();
                    TSchT = new TaxSchemeType();
                    TsTi  = new TaxSubtotalType[1];

                    //IDType IDsch = new IDType();
                    //NameType1 nameType = new NameType1();
                    //TaxTypeCodeType tTCt = new TaxTypeCodeType();

                    IDsch    = new IDType();
                    nameType = new NameType1();
                    tTCt     = new TaxTypeCodeType();

                    TAT.Value = Convert.ToDecimal(RBD[i].IMP_OTH, CultureInfo.CreateSpecificCulture("es-PE"));
                    //TAT.currencyID = CurrencyCodeContentType.PEN;
                    TAT.currencyID = RBD[i].MONEDA.ToUpper() == "USD" ? CurrencyCodeContentType.USD : CurrencyCodeContentType.PEN;

                    IDsch.Value    = "9999";
                    nameType.Value = "OTROS";
                    tTCt.Value     = "OTH";

                    TSchT.ID          = IDsch;
                    TSchT.Name        = nameType;
                    TSchT.TaxTypeCode = tTCt;
                    TCT.TaxScheme     = TSchT;
                    TST.TaxAmount     = TAT;
                    TST.TaxCategory   = TCT;
                    TOT.TaxAmount     = TAT;
                    TsTi[0]           = TST;

                    TOT.TaxSubtotal = TsTi;
                    TOTs[2]         = TOT;
                }

                HILT_s.TaxTotal = TOTs;

                #endregion END IMPUESTOS

                #region IF NOTE CREDI OR NOTE DEBIT
                if (RBD[i].TPO_CPE.Contains("07") || RBD[i].TPO_CPE.Contains("08"))
                {
                    string[] array_tpodoc_afec = RBD[i].TPO_DOC_AFEC.Split(',');
                    string[] array_nrodoc_afec = RBD[i].NRO_DOC_AFEC.Split(',');
                    if (array_tpodoc_afec.Length == array_nrodoc_afec.Length)
                    {
                        BillingReferenceType[] BRs    = new BillingReferenceType[array_nrodoc_afec.Length];
                        BillingReferenceType   BR     = new BillingReferenceType();
                        DocumentReferenceType  docRef = new DocumentReferenceType();
                        for (int af = 0; af < array_tpodoc_afec.Length; af++)
                        {
                            BR     = new BillingReferenceType();
                            docRef = new DocumentReferenceType();

                            IDType idref = new IDType();
                            idref.Value = array_nrodoc_afec[af];

                            DocumentTypeCodeType doctyperef = new DocumentTypeCodeType();
                            doctyperef.Value = array_tpodoc_afec[af];

                            docRef.ID = idref;
                            docRef.DocumentTypeCode = doctyperef;

                            BR.InvoiceDocumentReference = docRef;
                            BRs[af] = BR;
                        }
                        HILT_s.BillingReference = BRs;
                    }
                }
                #endregion

                //MILT[i] = HILT;


                #endregion
                detOk = true;
            }
            catch (Exception ex)
            {
                detOk = false;
            }
            return(HILT_s);
        }