public Address GetDefaultAddress(NetSuiteApi api) { return new Address { city = "-", zip = "-", addr1 = "México", addr2 = "-", attention = "-", country = Country._mexico, countrySpecified = true }; }
public CustomFieldRef[] GetCustomerFields(ContactDTO contact, LineDTO line, NetSuiteApi api) { return new CustomFieldRef[] { new StringCustomFieldRef { scriptId = "custentity_l54_tipo_documento", value = getDocumentType(contact, api) }, new StringCustomFieldRef { scriptId = "custentity_l54_nombre_legal", value = contact.ContactPerson }, new StringCustomFieldRef { scriptId = "custentity_l54_tipo_contribuyente", value = "1" // consumidor final }, new StringCustomFieldRef { scriptId = "custentity_l54_cuit_entity", value = getVatRegNumber(contact) // el cuit de vuelta, igual que vatregnumber }, new StringCustomFieldRef { scriptId = "custentity_clase_cuenta", value = "15" // consumidor final }, new StringCustomFieldRef { scriptId = "custentity_canal", value = "3" // consumidor final }, new StringCustomFieldRef { scriptId = "custentity_subcanal", value = "3" // mercadolibre }, new StringCustomFieldRef { scriptId = "custentity_tipocliente", value = this.getTypeOfClient(line, api) }, new StringCustomFieldRef { scriptId = "custentity_3k_usuarioweb", value = contact.Name }, }; }
public Address GetDefaultAddress(NetSuiteApi api) { return new Address { city = "-", zip = "-", addr1 = getCountry(api).Country.ToString(), addr2 = "-", attention = "-", country = getCountry(api).Country, countrySpecified = true, customFieldList = getCountry(api).GetAddressCustomFields(null) }; }
public CustomFieldRef[] GetOrderFields(SalesOrderRetrieveDTO salesOrder, NetSuiteApi api) { var fields = new List<CustomFieldRef> { new StringCustomFieldRef { scriptId="custentity_ibushak_id", value=salesOrder.Contact.ContactPerson ?? "?" }, new StringCustomFieldRef { scriptId="otherrefnum", value=salesOrder.Id }, new StringCustomFieldRef { scriptId="custitem1", value=salesOrder.Lines.First().Product.Brand ?? "?" }, new StringCustomFieldRef { scriptId="custbody5", value=salesOrder.Lines.First().Product.Brand ?? "?" }, new StringCustomFieldRef { scriptId="shipmethod", value="DHL" } }; if (salesOrder.HasShipments) { fields.Add( new StringCustomFieldRef { scriptId="custbody_guia", value=salesOrder.Shipments.First().Method.TrackingNumber ?? "?" } ); } if (salesOrder.HasPayments && salesOrder.Payments.First().Integration != null) { fields.Add( new StringCustomFieldRef { scriptId="custbody_refpag", value=salesOrder.Payments.First().Integration.IntegrationId } ); } return fields.ToArray(); }
public void TransformOrder(SalesOrder netSuiteOrder, SalesOrderRetrieveDTO salesOrder, NetSuiteApi api) { netSuiteOrder.tranId = salesOrder.Id; netSuiteOrder.orderStatus = SalesOrderOrderStatus._pendingApproval; netSuiteOrder.orderStatusSpecified = true; netSuiteOrder.otherRefNum = salesOrder.GetMeliIntegrationId(); netSuiteOrder.leadSource = new RecordRef { internalId = this.getLeadSourceId(api.Credentials.AccountName).ToString() }; }
private string getShippingProvider(ShipmentDTO shipment, NetSuiteApi api) { var genericProvider = getCountry(api).GenericShippingProvider; if (shipment.Method.Courier == null) return genericProvider; switch (shipment.Method.Courier.ToLowerInvariant()) { case "oca": return "10262"; case "motonorte": return "10263"; default: return genericProvider; } }
private string getLocation(LineDTO line, NetSuiteApi api) { switch (api.Credentials.AccountName) { case "EDIFIERCHILE": case "STADIO CHILE": return "5"; // Bodega Tiendas Web case "DIRECTO.LAT": return "20"; // Ecommerce_Salta case "TIENDAS STADIO": return "20"; // Ecommerce_Salta case "STADIO ARGENTINA": return "20"; // Ecommerce_Salta case "STADIOURUGUAY": return "6"; // BODEGA UES default: return "?"; } }
private GrupoIkonoCountry getCountry(NetSuiteApi api) { switch (api.Credentials.AccountName) { case "EDIFIERCHILE": case "STADIO CHILE": return new ChileGrupoIkonoCountry(); case "DIRECTO.LAT": case "TIENDAS STADIO": return new ArgentinaGrupoIkonoCountry(); case "STADIOURUGUAY": return new UruguayGrupoIkonoCountry(); default: return new ArgentinaGrupoIkonoCountry(); } }
public void TransformOrder(SalesOrder netSuiteOrder, SalesOrderRetrieveDTO salesOrder, NetSuiteApi api) { netSuiteOrder.@class = new RecordRef { internalId = this.getBusinessUnit(api) }; netSuiteOrder.orderStatus = SalesOrderOrderStatus._pendingFulfillment; // Una modificación, para la cuentas “TIENDAS STADIO” (todas las marcas, excepto Edifier) que apuntan // a la localización Stadio_Salta (13) deben tener la b.unit (campo class): Stadio B2C, Mercado Libre (id 10). if (this.getLocation(salesOrder.Lines.First(), api) == "13") // 13 = Stadio_Salta netSuiteOrder.@class = new RecordRef { internalId = "10" }; // Stadio B2C, Mercado Libre netSuiteOrder.department = new RecordRef {internalId = "18"}; // no aplica }
public void TransformCustomer(Customer netSuiteCustomer, ContactDTO contact, NetSuiteApi api) { netSuiteCustomer.firstName = contact.ContactPerson.ToUpper(); netSuiteCustomer.lastName = "."; netSuiteCustomer.category = new RecordRef { internalId = "15" }; // consumidor final netSuiteCustomer.salesRep = new RecordRef { internalId = "10260" }; // vendedor e-commerce netSuiteCustomer.campaignCategory = new RecordRef { internalId = "-4" }; netSuiteCustomer.subsidiary = new RecordRef { internalId = getCountry(api).Subsidiary }; netSuiteCustomer.leadSource = new RecordRef { internalId = "4" }; // mercadolibre netSuiteCustomer.priceLevel = new RecordRef { internalId = "14" }; // precio base netSuiteCustomer.terms = new RecordRef { internalId = "22" }; //mercadopago netSuiteCustomer.vatRegNumber = this.getVatRegNumber(contact); // ^ es válido poner 0 acá si en el custentity_l54_tipo_documento es 10 ("sin identificar") }
public string GetOrderLocation(IEnumerable<dynamic> items, SalesOrderRetrieveDTO salesOrder, NetSuiteApi api) { string salesOrderLocation = null; try { salesOrderLocation = items.First().preferredLocation.internalId; } catch { /* Is not an InventoryItem or it hasn't a preferred location */ try { salesOrderLocation = items.First().location.internalId; } catch { /* Is not a KitItem item or it hasn't a preferred location */ } } return salesOrderLocation ?? api.Locations.GetOrCreateLocation(salesOrder.Warehouse); }
public IEnumerable<NesuiInventoryItem> GetItems(NetSuiteApi api) { return api.Items.GetFullItems(); }
private string getPaymentMethod(string paymentMethod, NetSuiteApi api) { switch (paymentMethod) { case "Cash": return "1"; case "CreditCard": return "3"; case "BankTransfer": return "6"; case "Check": return "4"; case "MercadoPago": switch (api.Credentials.AccountName) { case "IBUSHAK": return "13"; case "CAVERNASH": return "14"; case "IBUSHAKADULTOS": return "15"; default: return "8"; } case "Debit": return "5"; case "BankDeposit": return "6"; default: return "1"; } }
private CustomFieldRef[] getPaymentFields(PaymentDTO payment, SalesOrder netSuiteOrder, NetSuiteApi api) { var fields = new List<CustomFieldRef> { new StringCustomFieldRef {scriptId = "custbody_mp_orden_venta_relacionada", value = netSuiteOrder.internalId}, new StringCustomFieldRef {scriptId = "custbody_mp_modo_pago", value = this.getPaymentMethod(payment.Method, api)}, new StringCustomFieldRef {scriptId = "custbody_mp_metodo_pago", value = this.getPaymentMethodForTheOTHERList(payment.Method)}, new StringCustomFieldRef {scriptId = "custbody_mp_numero_cuenta", value = "No Identificado"} }; if (payment.HasIntegration) { fields.Add(new StringCustomFieldRef { scriptId = "custbody_refpago", value = payment.Integration.IntegrationId }); } return fields.ToArray(); }
public CustomFieldRef[] GetCustomerFields(ContactDTO contact, LineDTO line, NetSuiteApi api) { return new CustomFieldRef[0]; }
public SalesOrderItem GetShipmentLineFor(double shippingCost, NetSuiteApi api) { var discountPercentage = getCountry(api).Iva / 100; var shippingCostWithoutIva = shippingCost / (discountPercentage + 1); return new SalesOrderItem { quantity = 1, quantitySpecified = true, amount = shippingCostWithoutIva, amountSpecified = true, item = new RecordRef { internalId = getCountry(api).ShipmentItem } }; }
public void TransformAddress(Address netSuiteAddress, LocationDTO location, NetSuiteApi api) { netSuiteAddress.addr1 = location.StreetName + " " + location.StreetNumber; netSuiteAddress.country = getCountry(api).Country; netSuiteAddress.countrySpecified = true; netSuiteAddress.customFieldList = getCountry(api).GetAddressCustomFields(location); netSuiteAddress.attention = null; netSuiteAddress.addr2 = location.AddressNotes; }
public NetSuitePriceLevelsApi(NetSuiteApi api) { this.api = api; }
public void TransformLine(SalesOrderItem netSuiteLine, LineDTO line, NetSuiteApi api) { netSuiteLine.location = new RecordRef { internalId = this.getLocation(line, api) }; }
public CustomFieldRef[] GetOrderFields(SalesOrderRetrieveDTO salesOrder, NetSuiteApi api) { var fields = new List<CustomFieldRef> { new StringCustomFieldRef { scriptId = "custbody_opcionesenvio", value = this.getShippingOptions(salesOrder) }, new StringCustomFieldRef { scriptId = "custbody_3k_store_web", value = api.Credentials.AccountName } }; if (salesOrder.HasShipments) { var shipment = salesOrder.Shipments.First(); fields.Add(new StringCustomFieldRef { scriptId = "custbody_3k_proveedor_envio", value = this.getShippingProvider(shipment, api) }); fields.Add(new StringCustomFieldRef { scriptId = "custbody_3k_link_etiqueta_envio", value = "http://mercadolibre.azurewebsites.net/shipments/label/pdf?access_token=" + api.Credentials.ProductecaToken + "&ids=" + shipment.Integration?.IntegrationId }); if (shipment.Method.TrackingNumber != null) { fields.Add(new StringCustomFieldRef { scriptId = "custbody_3k_nro_seguimiento", value = shipment.Method.TrackingNumber }); fields.Add(new StringCustomFieldRef { scriptId = "custbody_3k_nro_guia_envio", value = shipment.Method.TrackingNumber }); } } return fields.ToArray(); }
private string getBusinessUnit(NetSuiteApi api) { switch (api.Credentials.AccountName) { case "DIRECTO.LAT": return "2"; // Ecommerce : Directo case "TIENDAS STADIO": return "3"; // Ecommerce : Tiendas Oficiales ML case "STADIO ARGENTINA": return "10"; // Stadio B2C, Mercado Libre default: return "1"; // Ecommerce (default) } }
public string GetOrderLocation(IEnumerable<dynamic> items, SalesOrderRetrieveDTO salesOrder, NetSuiteApi api) { return this.getLocation(salesOrder.Lines.First(), api); }
private string getDocumentType(ContactDTO contact, NetSuiteApi api) { var cleanTaxId = getCleanTaxId(contact); var dniTypeByCountry = getCountry(api).DocumentType; var isACUIT = cleanTaxId.Length == 11; var isFromArgentina = getCountry(api).GetType() == typeof(ArgentinaGrupoIkonoCountry); if (cleanTaxId.Length == 0) return "10"; return isACUIT && isFromArgentina ? "2" : dniTypeByCountry; }
public Record GetPaymentFor(SalesOrder netSuiteOrder, PaymentDTO payment, string paymentId, NetSuiteApi api) { return new CustomerDeposit { salesOrder = new RecordRef { internalId= netSuiteOrder.internalId }, @class = new RecordRef { internalId = this.getBusinessUnit(api) }, payment = payment.Amount, paymentSpecified = true, customer = netSuiteOrder.entity, currency = new RecordRef { internalId = getCountry(api).Currency }, tranDate = payment.Date, memo = payment.Notes, externalId = paymentId, department = new RecordRef { internalId = "18" }, // no aplica customFieldList = new CustomFieldRef[] { new StringCustomFieldRef { scriptId = "custbody_refpago", value = payment.Integration.IntegrationId }, new StringCustomFieldRef {scriptId = "custbody_mp_numero_cuenta", value = "No Identificado"}, new StringCustomFieldRef {scriptId = "custbody_l54_letra", value = "6"}, // X new StringCustomFieldRef {scriptId = "custbody_l54_boca", value = "1"}, // 0001 } }; }
private string getSavedSearchForItems(NetSuiteApi api) { switch (api.Credentials.AccountName) { case "DIRECTO.LAT": return "customsearch_3k_producteca_art_stock_dir"; case "STADIO ARGENTINA": return "customsearch_3k_producteca_art_stock_sta"; default: return "customsearch_3k_producteca_art_stock_tof"; // TIENDAS STADIO } }
public double GetPriceOfLine(LineDTO line, dynamic netSuiteItem, NetSuiteApi api) { var discountPercentage = getCountry(api).GetIvaPercentage(netSuiteItem); return line.Price / (discountPercentage + 1); }
private string getTypeOfClient(LineDTO line, NetSuiteApi api) { switch (api.Credentials.AccountName) { case "EDIFIERCHILE": return "5"; // Edifier Chile case "STADIO CHILE": return "7"; // Stadio Chile case "DIRECTO.LAT": return "8"; // Directo Argentina case "TIENDAS STADIO": switch (line.Product.Brand) { case "Reloop": return "12"; // Reloop Argentina case "Presonus": return "14"; // PreSonus Argentina case "Ddrum": return "15"; // DDrum Argentina case "Ampeg": return "10"; // Ampeg Argentina case "Audix": return "13"; // Audix Argentina case "Edifier": return "4"; // Edifier Argentina case "Dean Guitars": return "11"; // Dean Guitars Argentina default: return "?"; } case "STADIOURUGUAY": switch (line.Product.Brand) { case "Mackie": return "17"; // Mackie Uruguay case "Ampeg": return "16"; // Ampeg Uruguay case "Presonus": return "18"; // PreSonus Uruguay default: return "?"; } case "STADIO ARGENTINA": return "6"; // Stadio Argentina default: return "?"; } }
public RecordRef GetRoleFor(NetSuiteApi api) { return new RecordRef { internalId = getCountry(api).RoleId }; }
public IEnumerable<NesuiInventoryItem> GetItems(NetSuiteApi api) { var country = getCountry(api); var search = new ItemSearchAdvanced { savedSearchScriptId = this.getSavedSearchForItems(api) }; return api.Search(search) .GroupBy(it => { var item = (ItemSearchRow) it; return item.basic.itemId[0].searchValue; }) .Select(items => { var item = (ItemSearchRow) items.First(); //var totalStock = items.Sum(it => { // var itemWithStock = (ItemSearchRow)it; // return itemWithStock.inventoryNumberJoin.quantityavailable?[0].searchValue ?? 0; //}); var totalStock = (items.FirstOrDefault(it => { var itemWithStock = (ItemSearchRow) it; return itemWithStock.inventoryNumberJoin.location[0].searchValue.internalId == LOCATION_FOR_STOCKS; }) as ItemSearchRow)?.inventoryNumberJoin.quantityavailable?[0].searchValue ?? 0; var customFields = (IEnumerable<SearchColumnCustomField>) item.basic.customFieldList; var iva = (SearchColumnDoubleCustomField) customFields.First(f => f.scriptId == country.IvaPercentageFieldName); var ivaFactor = iva.searchValue / 100 + 1; var price = item.pricingJoin.unitPrice[0].searchValue * ivaFactor; return new NesuiInventoryItem { Id = item.basic.itemId[0].searchValue, Barcode = item.basic.itemId[0].searchValue, Name = item.basic.salesDescription[0].searchValue, Price = price, Stocks = new List<NesuiLocationWithQuantity> { new NesuiLocationWithQuantity { LocationId = "Total", Quantity = totalStock } } }; }).ToList(); }
public void TransformLine(SalesOrderItem salesOrderItem, LineDTO line, NetSuiteApi api) { // nothing }