public SupplierPartyType getSupplierPartyType() { PartyType HPT = new PartyType(); NameType1 HNT1 = new NameType1(); HNT1.Value = $"<![CDATA[{MS.Emp.RazonSocial}]]>"; PartyNameType HPNT = new PartyNameType(); PartyNameType[] MPNT = { HPNT }; MPNT[0].Name = HNT1; IDType HIT = new IDType(); AddressType HAT = new AddressType(); AddressType[] MAT = { HAT }; HIT.Value = MS.Emp.Ubigeo; StreetNameType HSNT = new StreetNameType(); HSNT.Value = MS.Emp.DomicilioFiscal; CountryType HCT = new CountryType(); IdentificationCodeType HICT = new IdentificationCodeType(); HICT.listID = "PE"; HCT.IdentificationCode = HICT; PartyLegalEntityType HPLET = new PartyLegalEntityType(); PartyLegalEntityType[] MPLET = { HPLET }; RegistrationNameType HRNT = new RegistrationNameType(); HRNT.Value = $"<![CDATA[{MS.Emp.RazonSocial}]]>"; MPLET[0].RegistrationName = HRNT; HAT.ID = HIT; HAT.StreetName = HSNT; HAT.Country = HCT; HPT.PartyLegalEntity = MPLET; AdditionalAccountIDType HAAIT = new AdditionalAccountIDType(); AdditionalAccountIDType[] MAAIT = { HAAIT }; MAAIT[0].Value = "6"; CustomerAssignedAccountIDType CAAIDT = new CustomerAssignedAccountIDType(); CAAIDT.Value = MS.Emp.Ruc; SupplierPartyType HSPT = new SupplierPartyType(); HSPT.Party = HPT; HSPT.AdditionalAccountID = MAAIT; HSPT.CustomerAssignedAccountID = CAAIDT; return(HSPT); }
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); }