public BusinessPartnerResponse SetCustomerFromBusinessPartner(BusinessPartnerRequest customer, string billingCountry, string externalId) { var query = new CustomerBundleMaintainRequestMessage_sync_V1(); CustomerMaintainRequestBundleCustomer_V1 sapCustomer = new CustomerMaintainRequestBundleCustomer_V1(); sapCustomer.InternalID = externalId; sapCustomer.CreateFromBusinessPartnerIndicator = true; sapCustomer.CreateFromBusinessPartnerIndicatorSpecified = true; sapCustomer.actionCode = ActionCode.Item02; sapCustomer.actionCodeSpecified = true; sapCustomer.directResponsibilityListCompleteTransmissionIndicator = true; sapCustomer.directResponsibilityListCompleteTransmissionIndicatorSpecified = true; sapCustomer.DirectResponsibility = new CustomerMaintainRequestBundleDirectResponsibility[1]; sapCustomer.DirectResponsibility[0] = new CustomerMaintainRequestBundleDirectResponsibility(); sapCustomer.DirectResponsibility[0].PartyRoleCode = "142"; sapCustomer.DirectResponsibility[0].EmployeeID = new AccountManageCustomerService.EmployeeID(); sapCustomer.DirectResponsibility[0].EmployeeID.Value = customer.BpDetails.Ownership.LeadOwner.ExternalId; _sapOrgs = _sapService.SetOrgsFromDb(); sapCustomer.salesArrangementListCompleteTransmissionIndicatorSpecified = true; sapCustomer.salesArrangementListCompleteTransmissionIndicator = true; sapCustomer.SalesArrangement = new CustomerMaintainRequestBundleSalesArrangement[_sapOrgs.Sales.Count]; //sapCustomer.PaymentData = new CustomerMaintainRequestBundlePaymentData[_sapOrgs.Sales.Count]; foreach (var sales in _sapOrgs.Sales) { int index = _sapOrgs.Sales.IndexOf(sales); //sales arrangement var salesArrangement = new CustomerMaintainRequestBundleSalesArrangement(); salesArrangement.SalesOrganisationID = sales; salesArrangement.DistributionChannelCode = new AccountManageCustomerService.DistributionChannelCode(); salesArrangement.DistributionChannelCode.Value = "01"; salesArrangement.CompleteDeliveryRequestedIndicator = false; salesArrangement.CompleteDeliveryRequestedIndicatorSpecified = true; //payment data //var paymentData = new CustomerMaintainRequestBundlePaymentData(); //paymentData.CompanyID = company.Company; //paymentData.AccountDeterminationDebtorGroupCode = new AccountManageCustomerService.AccountDeterminationDebtorGroupCode(); //paymentData.AccountDeterminationDebtorGroupCode.Value = company.CountryCode == billingCountry ? "4010" : "4020"; //paymentData.PaymentForm = new CustomerMaintainRequestBundlePaymentDataPaymentForm[1]; //paymentData.PaymentForm[0] = new CustomerMaintainRequestBundlePaymentDataPaymentForm(); //paymentData.PaymentForm[0].PaymentFormCode = "06"; //sapCustomer.PaymentData[index] = paymentData; sapCustomer.SalesArrangement[index] = salesArrangement; } sapCustomer.generalProductTaxExemptionListCompleteTransmissionIndicator = true; sapCustomer.generalProductTaxExemptionListCompleteTransmissionIndicatorSpecified = true; sapCustomer.GeneralProductTaxExemption = new CustomerMaintainRequestBundleGeneralProductTaxExemption[1]; sapCustomer.GeneralProductTaxExemption[0] = new CustomerMaintainRequestBundleGeneralProductTaxExemption(); sapCustomer.GeneralProductTaxExemption[0].CountryCode = "US"; sapCustomer.GeneralProductTaxExemption[0].TaxTypeCode = new AccountManageCustomerService.TaxTypeCode { listID = "US", Value = "1" }; sapCustomer.GeneralProductTaxExemption[0].ReasonCode = new AccountManageCustomerService.TaxExemptionReasonCode { listID = "US", Value = "O" }; //shipping instructions //sapCustomer.Text = new CustomerMaintainRequestBundleText[1]; //sapCustomer.Text[0] = new CustomerMaintainRequestBundleText(); //sapCustomer.textListCompleteTransmissionIndicator = true; //sapCustomer.textListCompleteTransmissionIndicatorSpecified = true; //sapCustomer.Text[0].ContentText = customer.BpDetails.ShippingInstructions; CustomerMaintainRequestBundleCustomer_V1[] customerArray = new CustomerMaintainRequestBundleCustomer_V1[1]; customerArray[0] = sapCustomer; query.Customer = customerArray; CustomerBundleMaintainConfirmationMessage_sync_V1 sapResponse = _manageClient.MaintainBundle_V1(query); return(CreateSetCustomerResponse(sapResponse)); }
public BusinessPartnerResponse SetSupplierFromBusinessPartner(string externalId, string billingCountry) { var query = new SupplierBundleMaintainRequestMessage_sync_V1(); SupplierMaintainRequestBundleSupplier_V1 supplier = new SupplierMaintainRequestBundleSupplier_V1(); supplier.InternalID = externalId; supplier.CreateFromBusinessPartnerIndicator = true; supplier.CreateFromBusinessPartnerIndicatorSpecified = true; supplier.actionCode = ActionCode.Item02; supplier.actionCodeSpecified = true; _sapOrgs = _sapService.SetOrgsFromDb(); //supplier.paymentDataListCompleteTransmissionIndicator = true; //supplier.paymentDataListCompleteTransmissionIndicatorSpecified = true; //supplier.PaymentData = new SupplierMaintainRequestBundlePaymentData[_sapOrgs.Sales.Count]; foreach (var company in _sapOrgs.Companies) { //int index = _sapOrgs.Companies.IndexOf(company); //var paymentData = new SupplierMaintainRequestBundlePaymentData(); //paymentData.CompanyID = company.Company; //paymentData.AccountDeterminationCreditorGroupCode = new SupplierManageService.AccountDeterminationCreditorGroupCode(); // paymentData.AccountDeterminationCreditorGroupCode.Value = company.CountryCode == billingCountry ? "4010" : "4020"; ; //paymentData.PaymentForm = new SupplierMaintainRequestBundlePaymentForm[1]; //paymentData.PaymentForm[0] = new SupplierMaintainRequestBundlePaymentForm(); //paymentData.PaymentForm[0].PaymentFormCode = "06"; //supplier.PaymentData[index] = paymentData; } supplier.generalProductTaxExemptionListCompleteTransmissionIndicator = true; supplier.generalProductTaxExemptionListCompleteTransmissionIndicatorSpecified = true; supplier.GeneralProductTaxExemption = new SupplierMaintainRequestBundleGeneralProductTaxExemption[1]; supplier.GeneralProductTaxExemption[0] = new SupplierMaintainRequestBundleGeneralProductTaxExemption(); supplier.GeneralProductTaxExemption[0].CountryCode = "US"; supplier.GeneralProductTaxExemption[0].TaxTypeCode = new SupplierManageService.TaxTypeCode { listID = "US", Value = "1" }; supplier.GeneralProductTaxExemption[0].ReasonCode = new SupplierManageService.TaxExemptionReasonCode { listID = "US", Value = "O" }; supplier.communicationArrangementListCompleteTransmissionIndicator = true; supplier.communicationArrangementListCompleteTransmissionIndicatorSpecified = true; supplier.CommunicationArrangement = new SupplierMaintainRequestBundleCommunicationArrangement[1]; supplier.CommunicationArrangement[0] = new SupplierMaintainRequestBundleCommunicationArrangement(); supplier.CommunicationArrangement[0].CommunicationMediumTypeCode = new SupplierManageService.CommunicationMediumTypeCode(); supplier.CommunicationArrangement[0].CommunicationMediumTypeCode.Value = "PRT"; supplier.CommunicationArrangement[0].OutputCopyNumberValueSpecified = true; supplier.CommunicationArrangement[0].OutputCopyNumberValue = 1; SupplierMaintainRequestBundleSupplier_V1[] supplierArray = new SupplierMaintainRequestBundleSupplier_V1[1]; supplierArray[0] = supplier; query.Supplier = supplierArray; SupplierBundleMaintainConfirmationMessage_sync_V1 sapResponse = _manageClient.MaintainBundle_V1(query); return(CreateSetSupplierResponse(sapResponse)); }
public MaterialResponse SetMaterial(MaterialRequest material) { var checkExisting = QueryMaterial(material.PartNumber); if (!string.IsNullOrEmpty(checkExisting.ExternalId)) { return(checkExisting); } var request = new MaterialMaintainRequestBundleMessage_sync_V1(); request.Material = new MaterialMaintainRequestBundleMaterial_sync_V1[1]; var sapMaterial = new MaterialMaintainRequestBundleMaterial_sync_V1(); sapMaterial.descriptionListCompleteTransmissionIndicator = true; sapMaterial.descriptionListCompleteTransmissionIndicatorSpecified = true; sapMaterial.detailListCompleteTransmissionIndicator = true; sapMaterial.detailListCompleteTransmissionIndicatorSpecified = true; sapMaterial.ProductCategoryID = material.CommodityExternalID; sapMaterial.BaseMeasureUnitCode = "EA"; sapMaterial.IdentifiedStockTypeCode = new MaterialManageService.IdentifiedStockTypeCode(); sapMaterial.IdentifiedStockTypeCode.Value = "04"; sapMaterial.Description = new MaterialMaintainRequestBundleDescription[1]; sapMaterial.Description[0] = new MaterialMaintainRequestBundleDescription(); sapMaterial.Description[0].Description = new MaterialManageService.SHORT_Description(); var truncatedString = material.PartNumber + " {" + material.Mfg; truncatedString = truncatedString.Substring(0, (truncatedString.Length > 39 ? 39 : truncatedString.Length)); sapMaterial.Description[0].Description.Value = truncatedString + "}"; if (!string.IsNullOrEmpty(material.Description)) { sapMaterial.Detail = new MaterialBundleMaintainRequestText[1]; sapMaterial.Detail[0] = new MaterialBundleMaintainRequestText(); sapMaterial.Detail[0].ContentText = new MaterialManageService.Text(); sapMaterial.Detail[0].ContentText.Value = material.Description; } sapMaterial.Purchasing = new MaterialMaintainRequestBundlePurchasing(); sapMaterial.Purchasing.LifeCycleStatusCodeSpecified = true; sapMaterial.Purchasing.LifeCycleStatusCode = MaterialManageService.ProductProcessUsabilityLifeCycleStatusCode.Item2; sapMaterial.Purchasing.PurchasingMeasureUnitCode = "EA"; _sapOrgs = _sapService.SetOrgsFromDb(); sapMaterial.Planning = SetPlanningData(_sapOrgs.Planning); sapMaterial.AvailabilityConfirmation = SetAvailabilityData(_sapOrgs.Availability); sapMaterial.Sales = SetSalesData(_sapOrgs.Sales); sapMaterial.Logistics = SetLogisticsData(_sapOrgs.Logistics); sapMaterial.MFGPartNumber = material.PartNumber; sapMaterial.Manufacturer = material.Mfg; sapMaterial.ECCN = material.ECCN; sapMaterial.StrippedPartNumber = material.PartNumberStrip; sapMaterial.DatasheetURL = material.DatasheetURL; sapMaterial.IHSID = material.SourceDataID.ToString(); sapMaterial.MSL = material.MSL; sapMaterial.EURoHSSpecified = true; sapMaterial.EURoHS = material.EURoHS; sapMaterial.HTSCode = material.HTS; if (!string.IsNullOrEmpty(material.ExternalId)) { sapMaterial.InternalID = new MaterialManageService.ProductInternalID(); sapMaterial.InternalID.Value = material.ExternalId; } request.Material[0] = sapMaterial; var xmlParser = SapXmlExtractor.GetXmlString(request); var setResponse = ParseManageResponse(_manageClient.MaintainBundle_V1(request)); if (string.IsNullOrEmpty(setResponse.ExternalId)) { return(setResponse); } return(SetMaterialValuationData(setResponse.ExternalId)); }