public bool SavePaymentMethod(PaymentMethodEntity method) { using (var connection = _connectionFactory()) { return(connection.InsertOrReplace(method) != -1); } }
public bool Delete(string PayId) { bool toReturn = false; using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter()) { PaymentMethodEntity _PaymentMethodEntity = new PaymentMethodEntity(PayId); if (adapter.FetchEntity(_PaymentMethodEntity)) { adapter.DeleteEntity(_PaymentMethodEntity); toReturn = true; } } return toReturn; }
private void Generate_Save_NetSuiteLst(List <FoodicsOrder> OrderLstAll, int Subsidiary_Id) { try { int Exe_length = 5; int lstend = Exe_length; Setting objSetting = new GenericeDAO <Setting>().GetWhere("Subsidiary_Netsuite_Id=" + Subsidiary_Id).FirstOrDefault(); if (OrderLstAll.Count > 0) { for (int Index = 0; Index < OrderLstAll.Count; Index += Exe_length) { if (Index + Exe_length >= OrderLstAll.Count) { lstend = OrderLstAll.Count - Index; } List <FoodicsOrder> OrderLst = OrderLstAll.GetRange(Index, lstend); if (OrderLst.Count > 0) { List <PaymentMethod> PaymentMethodLst = new GenericeDAO <PaymentMethod>().GetAll(); List <Invoice> Invoicelst = new List <Invoice>(); List <InvoiceItem> InvoiceItemlst = new List <InvoiceItem>(); List <PaymentMethodEntity> PaymentMethodEntitylst = new List <PaymentMethodEntity>(); foreach (var Foodicsitem in OrderLst) { //List<Invoice> invoiceLst = new GenericeDAO<Invoice>().GetWhere(" Foodics_Id = '" + Foodicsitem.id + "' AND Date = '" + Foodicsitem.business_date.ToString("yyyy-MM-dd") + "'"); List <Invoice> invoiceLst = new GenericeDAO <Invoice>().GetWhere(" Foodics_Id = '" + Foodicsitem.id + "' AND ISNULL(Netsuite_Id,0) > 0"); if (invoiceLst.Count <= 0) { Invoice Netsuiteitem = new Invoice(); //barcode Netsuiteitem.Foodics_Id = Foodicsitem.id; Netsuiteitem.Order_Status = Foodicsitem.status; Netsuiteitem.Subsidiary_Id = Subsidiary_Id; if (Foodicsitem.original_order != null && !string.IsNullOrEmpty(Foodicsitem.original_order.id)) { Netsuiteitem.Original_Foodics_Id = Foodicsitem.original_order.id; } else { Netsuiteitem.Original_Foodics_Id = "0"; } if (Foodicsitem.Customer != null && !string.IsNullOrEmpty(Foodicsitem.Customer.Id)) { Customer obj = new GenericeDAO <Customer>().GetByFoodicsId(Foodicsitem.Customer.Id); if (obj != null && Utility.ConvertToInt(obj.Id) > 0) { Netsuiteitem.Customer_Id = Utility.ConvertToInt(obj.Id); Netsuiteitem.Customer_Netsuite_Id = obj.Netsuite_Id; } } else { Netsuiteitem.Customer_Id = 0; Netsuiteitem.Customer_Netsuite_Id = 0; } if (Foodicsitem.Branch != null && !string.IsNullOrEmpty(Foodicsitem.Branch.id)) { Location obj = new GenericeDAO <Location>().GetByFoodicsId(Foodicsitem.Branch.id); Netsuiteitem.Location_Id = obj.Netsuite_Id; } else { Netsuiteitem.Location_Id = 0; } //Invoice Discount if (Foodicsitem.discount != null && !string.IsNullOrEmpty(Foodicsitem.discount.id)) { Discount obj = new GenericeDAO <Discount>().GetByFoodicsId(Foodicsitem.discount.id); if (obj != null && obj.Netsuite_Id > 0) { Netsuiteitem.Discount_Id = obj.Netsuite_Id; } } //Foodics Source if (Foodicsitem.source > 0) { Netsuiteitem.Source = Enum.GetName(typeof(InvoiceSource), Foodicsitem.source); } //Foodics CreatedBY if (Foodicsitem.creator != null && !string.IsNullOrEmpty(Foodicsitem.creator.id)) { Netsuiteitem.CreatedBy = Foodicsitem.creator.name; } Netsuiteitem.Invoice_Discount_Type = Foodicsitem.discount_type; Netsuiteitem.Total_Discount = (float)Foodicsitem.discount_amount; Netsuiteitem.Date = Foodicsitem.business_date; Netsuiteitem.CreateAt = Foodicsitem.created_at; Netsuiteitem.OpenAt = Foodicsitem.opened_at; Netsuiteitem.CloseAt = Foodicsitem.closed_at; Netsuiteitem.UpdateAt = Foodicsitem.updated_at; Netsuiteitem.Interval_Note = Foodicsitem.kitchen_notes + Foodicsitem.customer_notes; Netsuiteitem.Notes = Netsuiteitem.Interval_Note; Netsuiteitem.Paid = (float)Foodicsitem.total_price; Netsuiteitem.Net_Payable = (float)Foodicsitem.subtotal_price; Netsuiteitem.BarCode = Foodicsitem.reference; Netsuiteitem.Number = Foodicsitem.number.ToString(); //Products foreach (var prodobj in Foodicsitem.Products) { GetProducts(objSetting, InvoiceItemlst, Foodicsitem, prodobj, "", ""); } if (Foodicsitem.combos != null) { foreach (var Comboobj in Foodicsitem.combos) { foreach (var prodobj in Comboobj.Products) { GetProducts(objSetting, InvoiceItemlst, Foodicsitem, prodobj, Comboobj.combo_size.name, Comboobj.combo_size.combo.name); } } } if (Foodicsitem.charges != null) { foreach (var objCharges in Foodicsitem.charges) { Product objproduct = new Product(); Products objProds = new Products(); objProds.quantity = 1; objProds.unit_price = objCharges.amount; objProds.Product = objproduct; objProds.status = 3; foreach (var objCharge in objCharges.charge) { objproduct.id = objCharge.id; objproduct.name = objCharge.name; GetProducts(objSetting, InvoiceItemlst, Foodicsitem, objProds, "", ""); } } } //payment methods foreach (var payobj in Foodicsitem.payments) { PaymentMethod PaymentMethodobj = PaymentMethodLst.Where(x => x.Foodics_Id == payobj.payment_method.id).FirstOrDefault(); PaymentMethodEntity paymethod = new PaymentMethodEntity(); paymethod.Foodics_Id = Foodicsitem.id; paymethod.Entity_Type = 1; paymethod.Amount = (float)payobj.amount; paymethod.Ref = payobj.payment_method.name; paymethod.Notes = payobj.payment_method.name; paymethod.Business_Date = payobj.Business_Date; if (PaymentMethodobj != null && PaymentMethodobj.Netsuite_Id > 0) { paymethod.Payment_Method = PaymentMethodobj.Name_En; paymethod.Payment_Method_Id = PaymentMethodobj.Netsuite_Id; paymethod.Payment_Method_Percentage = PaymentMethodobj.Percentage; } else { paymethod.Payment_Method = "Cash"; paymethod.Payment_Method_Id = 1; paymethod.Payment_Method_Percentage = 0; } paymethod.Payment_Method_Type = 0; paymethod.Payment_Method_Type_Netsuite_Id = 0; PaymentMethodEntitylst.Add(paymethod); } Invoicelst.Add(Netsuiteitem); } } new GenericeDAO <Invoice>().InvoiceDetailsDelete(Invoicelst); new GenericeDAO <Invoice>().ListInsertOnly(Invoicelst); new GenericeDAO <InvoiceItem>().ListInsertOnly(InvoiceItemlst); new GenericeDAO <PaymentMethodEntity>().ListInsertOnly(PaymentMethodEntitylst); //new CustomDAO().InvoiceRelatedUpdate(); } } } } catch (Exception ex) { LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } }
public override Int64 Set(string parametersArr) { List <Foodics.NetSuite.Shared.Model.PaymentMethodEntity> lstitemsAll = new CustomDAO().SelectCustomerPayment(4); int Exe_length = 200; int lstend = Exe_length; if (lstitemsAll.Count > 0) { for (int Index = 0; Index < lstitemsAll.Count; Index += Exe_length) { if (Index + Exe_length >= lstitemsAll.Count) { lstend = lstitemsAll.Count - Index; } List <Foodics.NetSuite.Shared.Model.PaymentMethodEntity> invoiceMethodLst = lstitemsAll.GetRange(Index, lstend); try { if (invoiceMethodLst.Count > 0) { List <Record> cps = new List <Record>(); bool is_valid = false; try { for (int f = 0; f < invoiceMethodLst.Count; f++) { PaymentMethodEntity payobj = invoiceMethodLst[f]; Foodics.NetSuite.Shared.Model.Invoice invoiceobj = new GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice>().GetWhere(" Foodics_Id = '" + payobj.Foodics_Id + "'").FirstOrDefault(); Setting objSetting = new GenericeDAO <Setting>().GetWhere("Subsidiary_Netsuite_Id=" + invoiceobj.Subsidiary_Id).FirstOrDefault(); #region Accept Payment CustomerPaymentApplyList AplyList = new CustomerPaymentApplyList(); CustomerPaymentCreditList CreditList = new CustomerPaymentCreditList(); CustomerPaymentDepositList DepositList = new CustomerPaymentDepositList(); List <CustomerPaymentApply> payApplylst = new List <CustomerPaymentApply>(); CustomerPaymentApply payApply; CustomerPayment cp = new CustomerPayment(); cp.autoApply = false; is_valid = false; #region Payment Properties //customer RecordRef customer = new RecordRef(); customer.internalId = invoiceobj.Customer_Netsuite_Id > 0 ? invoiceobj.Customer_Netsuite_Id.ToString() : objSetting.Customer_Netsuite_Id.ToString(); customer.type = RecordType.customer; cp.customer = customer; //currency RecordRef currency = new RecordRef(); currency.internalId = objSetting.Currency_Netsuite_Id.ToString();//payobj.Currency_Id.ToString(); currency.type = RecordType.currency; cp.currency = currency; StringCustomFieldRef FoodicsRef, FoodicsNumb; // memo cp.memo = payobj.Notes; //tranDate cp.tranDate = TimeZoneInfo.ConvertTimeToUtc(payobj.Business_Date, TimeZoneInfo.Local); cp.tranDateSpecified = true; //cp.subsidiary RecordRef subsidiary = new RecordRef(); subsidiary.internalId = objSetting.Subsidiary_Netsuite_Id.ToString(); //payobj.Subsidiary_Id.ToString(); subsidiary.type = RecordType.subsidiary; cp.subsidiary = subsidiary; //cp.location RecordRef location = new RecordRef(); location.internalId = invoiceobj.Location_Id.ToString();//objSetting.Location_Netsuite_Id.ToString();//payobj.Location_Id.ToString(); location.type = RecordType.location; cp.location = location; // payment amount cp.payment = payobj.Amount; cp.paymentSpecified = true; #region Payment Custom Attributes DoubleCustomFieldRef payPercent = new DoubleCustomFieldRef(); payPercent.scriptId = "custbody_da_payment_method_percentage"; payPercent.value = payobj.Payment_Method_Percentage; DoubleCustomFieldRef PayPercentAmount = new DoubleCustomFieldRef(); PayPercentAmount.scriptId = "custbody_da_payment_method_amount"; PayPercentAmount.value = (payobj.Payment_Method_Percentage * payobj.Amount) / 100; LongCustomFieldRef trans_id = new LongCustomFieldRef(); trans_id.scriptId = "custbody_da_transaction_id"; trans_id.value = invoiceobj.Netsuite_Id; FoodicsRef = new StringCustomFieldRef(); FoodicsRef.scriptId = "custbody_da_foodics_reference"; FoodicsRef.value = invoiceobj.BarCode.ToString(); FoodicsNumb = new StringCustomFieldRef(); FoodicsNumb.scriptId = "custbody_da_foodics_number"; FoodicsNumb.value = invoiceobj.Number.ToString(); CustomFieldRef[] customFieldRefArray = new CustomFieldRef[5]; customFieldRefArray[0] = trans_id; customFieldRefArray[1] = payPercent; customFieldRefArray[2] = PayPercentAmount; customFieldRefArray[3] = FoodicsRef; customFieldRefArray[4] = FoodicsNumb; cp.customFieldList = customFieldRefArray; #endregion #region Apply Invoice // Invoice payApply = new CustomerPaymentApply(); payApply.apply = true; payApply.docSpecified = true; payApply.amountSpecified = true; payApply.currency = currency.internalId; payApply.type = "Invoice"; payApply.doc = invoiceobj.Netsuite_Id; payApply.total = payobj.Amount; payApply.amount = payobj.Amount; payApply.applyDate = payobj.Business_Date; payApplylst.Add(payApply); #endregion #region Invoice Custom Attributes #endregion // payment method if (payobj.Payment_Method_Id > 0) { is_valid = true; //payment method RecordRef payment_method = new RecordRef(); payment_method.internalId = payobj.Payment_Method_Id.ToString(); payment_method.type = RecordType.customerPayment; cp.paymentMethod = payment_method; cp.authCode = payobj.Ref.Length > 30 ? payobj.Ref.Substring(0, 30) : payobj.Ref; // amount cp.payment = payobj.Amount; cp.paymentSpecified = true; } AplyList.apply = payApplylst.ToArray(); cp.applyList = AplyList; #endregion if (is_valid) { cps.Add(cp); } #endregion } } catch (Exception ex) { LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } if (cps.Count > 0) { WriteResponseList wr = Service(true).addList(cps.ToArray()); bool result = wr.status.isSuccess; UpdatedLst(invoiceMethodLst, wr); // return result; } } } catch (Exception ex) { LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } } } return(0); }
public bool Update(string PayId, string PayName, bool IsEnable, bool IsVisible, string Link) { bool toReturn = false; using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter()) { PaymentMethodEntity _PaymentMethodEntity = new PaymentMethodEntity(PayId); if (adapter.FetchEntity(_PaymentMethodEntity)) { _PaymentMethodEntity.PayName = PayName; _PaymentMethodEntity.IsEnable = IsEnable; _PaymentMethodEntity.IsVisible = IsVisible; _PaymentMethodEntity.Link = Link; adapter.SaveEntity(_PaymentMethodEntity, true); toReturn = true; } } return toReturn; }
public bool Update(PaymentMethodEntity _PaymentMethodEntity, RelationPredicateBucket filter) { bool toReturn = false; using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter()) { adapter.UpdateEntitiesDirectly(_PaymentMethodEntity, filter); toReturn = true; } return toReturn; }
public bool Update(PaymentMethodEntity _PaymentMethodEntity) { bool toReturn = false; using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter()) { RelationPredicateBucket filter = new RelationPredicateBucket(); IPredicateExpression _PredicateExpression = new PredicateExpression(); _PredicateExpression.Add(PaymentMethodFields.PayId == _PaymentMethodEntity.PayId); filter.PredicateExpression.Add(_PredicateExpression); adapter.UpdateEntitiesDirectly(_PaymentMethodEntity, filter); toReturn = true; } return toReturn; }
public PaymentMethodEntity SelectOne(string PayId) { PaymentMethodEntity toReturn = null; using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter()) { PaymentMethodEntity _PaymentMethodEntity = new PaymentMethodEntity(PayId); if (adapter.FetchEntity(_PaymentMethodEntity)) { toReturn = _PaymentMethodEntity; } } return toReturn; }
public PaymentMethodEntity Insert(string PayName, bool IsEnable, bool IsVisible, string Link) { PaymentMethodEntity _PaymentMethodEntity = new PaymentMethodEntity(); using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter()) { _PaymentMethodEntity.PayName = PayName; _PaymentMethodEntity.IsEnable = IsEnable; _PaymentMethodEntity.IsVisible = IsVisible; _PaymentMethodEntity.Link = Link; adapter.SaveEntity(_PaymentMethodEntity, true); } return _PaymentMethodEntity; }
public PaymentMethodEntity Insert(PaymentMethodEntity _PaymentMethodEntity) { using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter()) { adapter.SaveEntity(_PaymentMethodEntity, true); } return _PaymentMethodEntity; }
public override Int64 Set(string parametersArr) { List <Foodics.NetSuite.Shared.Model.PaymentMethodEntity> lstitemsAll = new CustomDAO().SelectCustomerPayment(5).Take(2000).ToList(); int Exe_length = 200; int lstend = Exe_length; if (lstitemsAll.Count > 0) { for (int Index = 0; Index < lstitemsAll.Count; Index += Exe_length) { if (Index + Exe_length >= lstitemsAll.Count) { lstend = lstitemsAll.Count - Index; } List <Foodics.NetSuite.Shared.Model.PaymentMethodEntity> returnList = lstitemsAll.GetRange(Index, lstend); try { if (returnList.Count > 0) { CustomerRefund[] memoList = new CustomerRefund[returnList.Count]; for (int i = 0; i < returnList.Count; i++) { PaymentMethodEntity invoiceReturn = returnList[i]; CustomerRefund memo = new CustomerRefund(); CustomerRefundApply[] payApply = new CustomerRefundApply[1]; CustomerRefundApplyList AplyList = new CustomerRefundApplyList(); Foodics.NetSuite.Shared.Model.Invoice invoiceobj = new GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice>().GetWhere(" Foodics_Id = '" + invoiceReturn.Foodics_Id + "'").FirstOrDefault(); Setting objSetting = new GenericeDAO <Setting>().GetWhere("Subsidiary_Netsuite_Id=" + invoiceobj.Subsidiary_Id).FirstOrDefault(); //Customer RecordRef entity = new RecordRef(); entity.internalId = invoiceobj.Customer_Netsuite_Id > 0 ? invoiceobj.Customer_Netsuite_Id.ToString() : objSetting.Customer_Netsuite_Id.ToString(); entity.type = RecordType.customer; memo.customer = entity; //currency RecordRef currency = new RecordRef(); currency.internalId = objSetting.Currency_Netsuite_Id.ToString(); currency.type = RecordType.currency; memo.currency = currency; //date memo.tranDateSpecified = true; memo.tranDate = TimeZoneInfo.ConvertTimeToUtc(invoiceobj.Date, TimeZoneInfo.Local); //exchange rate memo.exchangeRate = invoiceobj.Exchange_Rate; //subsidary RecordRef subsid = new RecordRef(); subsid.internalId = invoiceobj.Subsidiary_Id.ToString(); subsid.type = RecordType.subsidiary; memo.subsidiary = subsid; //cp.location RecordRef location = new RecordRef(); location.internalId = invoiceobj.Location_Id.ToString(); location.type = RecordType.location; memo.location = location; #region Apply Invoice // Invoice payApply[0] = new CustomerRefundApply(); payApply[0].apply = true; payApply[0].docSpecified = true; payApply[0].amountSpecified = true; payApply[0].currency = currency.internalId; payApply[0].type = "CreditMemo"; payApply[0].doc = invoiceobj.Netsuite_Id; payApply[0].total = invoiceobj.Paid; payApply[0].amount = invoiceobj.Paid; payApply[0].applyDate = invoiceobj.Date; AplyList.apply = payApply; memo.applyList = AplyList; #endregion #region payment Method RecordRef payment_method = new RecordRef(); payment_method.internalId = invoiceReturn.Payment_Method_Id.ToString(); payment_method.type = RecordType.customerPayment; memo.paymentMethod = payment_method; #endregion memoList[i] = memo; } if (memoList.Length > 0) { WriteResponseList wr = Service(true).addList(memoList.ToArray()); bool result = wr.status.isSuccess; UpdatedLst(returnList, wr); } } } catch (Exception ex) { LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } } } return(0); }