How to delete Quickbook Invoice payment using SDK(Quickbook 14) - quickbooks

We are using Interop.QBFC14 SDK to delete invoice.
IMsgSetRequest requestMsgSet = sessionHelper.GetMsgSetRequest();
ITxnDel txnDelRq = requestMsgSet.AppendTxnDelRq();
txnDelRq.TxnDelType.SetValue(ENTxnDelType.tdtReceivepayment);
txnDelRq.TxnID.SetValue("<>");

Related

How to Many2Many field relationship and map that in Invoice in odoo

how we suppose to do that, is it possible to use Many2many fields or we can create another model with vehicle_id and partner_id.
how create and edit vehicle_number fetch automatically cutomer_id many2many field when vehicle already existing vehicle number with different partner_id
class VehicleMaster(models.Model):
_name = "vehicle.master.model"
_description = "Vehicle Master"
_rec_name = 'x_vehicle_number_id'
x_brand_id = fields.Many2one('vehicle.brand.model', string="Brand Name",ondelete='restrict')
x_model_id = fields.Many2one('vehicle.model.model', string="Model Name",domain=" [('brand_id','=',x_brand_id)]",ondelete='restrict')
x_vehicle_number_id = fields.Char(string="Vehicle Number", required=True, tracking=True,ondelete='restrict')
x_customer_id = fields.Many2many('res.partner',string="Customers",required=True,tracking=True)
class CustomInvoice(models.Model):
_inherit = "account.move"
vehicle_number = fields.Many2one('vehicle.master.model',string='Vehicle number',domain="[('x_customer_id','=',partner_id)]")
I try to used vehicle.master.model in field many2many vehicle_number and relation with invoice module when create vehicle_number in invoice to not fetch automatically when vehicle_number is already created with different partner_id.

restforce gem save only changed attriubtes?

I'm using restforce to interat with salesforce in Ruby on Rails.
I have this snippet of code:
client = Restforce.new
acc = client.find("Account", account_ID)
acc.firstName = "test"
acc.save
# if I use update I get the same error
acc.update
But I get the following error
[
{
"message":"Unable to create/update fields: jigsaw_clean__Sync_Status_Indicator__c, LastModifiedDate, PhotoUrl, IsDeleted, jigsaw_clean__Jigsaw_Managed_Backend__c, jigsaw_clean__Sync_Status_Summary__c, AccPwr1__c, BillingAddress, jigsaw_clean__Duplicate__c, LastActivityDate, jigsaw_clean__Automatic_Updates__c, JigsawCompanyId, CreatedById, MasterRecordId, LastViewedDate, CreatedDate, LastReferencedDate, jigsaw_clean__Additional_Information__c, jigsaw_clean__Jigsaw_Last_Sync_Locked__c, Cross_Sell_Score__c, jigsaw_clean__Jigsaw_Managed__c, ShippingAddress, LastModifiedById, IANA_Number_field__c. Please check the security settings of this field and verify that it is read/write for your profile or permission set.",
"errorCode":"INVALID_FIELD_FOR_INSERT_UPDATE",
"fields":[
"jigsaw_clean__Sync_Status_Indicator__c",
"jigsaw_clean__Jigsaw_Managed_Backend__c",
"jigsaw_clean__Sync_Status_Summary__c",
"AccPwr1__c",
"BillingAddress",
"jigsaw_clean__Duplicate__c",
"LastActivityDate",
"jigsaw_clean__Automatic_Updates__c",
"CreatedById",
"MasterRecordId",
"jigsaw_clean__Additional_Information__c",
"jigsaw_clean__Jigsaw_Last_Sync_Locked__c",
"Cross_Sell_Score__c",
"jigsaw_clean__Jigsaw_Managed__c",
]
}
]
and other fields.
I know, I can do something like:
client = Restforce.new
acc = client.find("Account", account_ID)
acc1 = {Id: acc.Id}
acc1["firstName"] = "test"
client.update("Account", acc1)
How do I do this in a more efficient way?
Please check the security settings of this field and verify that it is read/write for your profile or permission set.
Are you sure that you have permission to make updates?
The only way I can find is the instead of using find we use query with fields that we want to update.
client = Restforce.new
acc1 = client.query("SELECT ID, firstName, LastName FROM Account where ID = '#{account_ID}'").first
acc1["firstName"] = "test"
acc1.save

Shopify how to create Price Rule through API

I am new to shopify. Now I want to use shopify API to create a price rule, this is my source code here
I use rails 5.1.4, shopify_app 8.1.0
shop_url = "https://api_key:secret#domain/admin"
ShopifyAPI::Base.site = shop_url
prerequisite_saved_search_ids = [53677883419]
price_rule = ShopifyAPI::PriceRule.new
price_rule.title = "demodemo"
price_rule.target_name = "line_item"
price_rule.target_selection = "all"
price_rule.allocation_method = "across"
price_rule.value_type = "fixed_amount"
price_rule.value = "-10.0"
price_rule.customer_selection = "prerequisite"
price_rule.prerequisite_saved_search_ids = prerequisite_saved_search_ids
price_rule.start_at = Time.now.iso8601
res = price_rule.save
puts res
However it always return me false. If anyone has the idea? Thanks a million!
Please check this Api to create price rule(Shopify Api). I have used this Api in php and its working fine for me.
I have created App and then use Api key and secret key to generate price rule.
Thanks
For the ones coming to this question, one could fetch Price rules as per shopify_app gem for Rails applications as:
First allow your app to access read/write permissions in initializers/shopify.rb file as:
config.scope = "read_products, write_products, read_price_rules, write_price_rules"
After that you can fetch price rules as:
#price_rules = ShopifyAPI::PriceRule.find(:all, params:{id: '4171201931'})
And can also create a price rule as:
#create_price_rule = ShopifyAPI::PriceRule.new(
price_rule: {
title: "FREESHIPPING2",
target_type: "shipping_line",
target_selection: "all",
allocation_method: "each",
value_type: "percentage",
value: "-100.0",
usage_limit: 20,
customer_selection: "all",
prerequisite_subtotal_range: {
greater_than_or_equal_to: "50.0"
},
starts_at: "2017-11-19T17:59:10Z"
}
)
#create_price_rule.save
There are validations involved. Incase you want to check the response, one may inspect it like #create_price_rule.inspect
Or even you can delete a PriceRule as:
#price_rules = ShopifyAPI::PriceRule.find(:all).first
#price_rules.destroy
#last_price_rule = ShopifyAPI::PriceRule.find(4171860875)

Cross-database join in Flask-SQLAlchemy

I'm trying to do a cross-database join in Flask-SQLAlchemy:
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = '...Master...'
app.config['SQLALCHEMY_BINDS'] = { 'Billing': '...Billing...' }
db = SQLAlchemy(app)
class Account(db.Model):
__tablename__ = 'Accounts'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(255))
class Setting(db.Model):
__tablename__ = 'Settings'
AccountId = db.Column(db.Integer, db.ForeignKey(Account.id), primary_key=True)
Enabled = db.Column(db.Boolean)
class BillingAccount(db.Model):
__tablename__ = 'Account'
__bind_key__ = 'Billing'
id = db.Column(db.Integer, primary_key=True)
AccountId = db.Column(db.Integer, db.ForeignKey(Account.id))
currency = db.Column(db.Integer)
class AccountSetting(db.Model):
__table__ = db.join(Account, AccountSetting)
id = db.column_property(Account.id, AccountSetting.AccountId)
username = Account.username
enabled = Setting.Enabled
class AccountSettingBilling(db.Model):
__table__ = db.join(Account, AccountSetting).join(BillingAccount)
id = db.column_property(Account.id, AccountSetting.AccountId, BillingAccount.AccountId)
username = Account.username
enabled = Setting.Enabled
currency = BillingAccount.currency
With this I can successfully query AccountSetting.query.all() but not AccountSettingBilling.query.all(), which fails with error 208 (MSSQL for 'object does not exist').
If I examine the generated SQL I can clearly see that it is doing a JOIN on Account.AccountId=Accounts.id when I'd expect to see some reference to Billing, e.g. Billing.Account.AccountId=Accounts.id.
Having followed Cross database join in sqlalchemy and http://pythonhosted.org/Flask-SQLAlchemy/binds.html it looks to me as though I've done things correctly. What gives?
You define an object db = SQLAlchemy(app) - it is Database1. You refer to it everywhere, but there is no reference to Database2. Also note code refers to columns for the join using 2 part identifiers:
Account . AccountId and Accounts . id
whereas you wish to have 3 part identifiers:
Billing . Account . AccountId and [Accounts] . Accounts . id
You are missing this property for db name from definition of each Class:
__table_args__ = {'schema': 'Accounts'}
__table_args__ = {'schema': 'Billing'}

Friends checkins with facebook graph api and rails - APIError

I am trying to get a users friends checkins, I am using omniauth and koala gem.
When a user gets saved this method hits:
def add_friends
friends_data = facebook.get_connections("me", "friends", :fields => "id, name, link, picture, gender, checkins")
friends_data.map do |h|
friend = Friend.new
friend.uid = h["id"]
friend.name = h["name"]
friend.image = h["picture"]
friend.gender = h["gender"]
friend.urls = h["link"]
friend.user_id = self.id
friend.save!
if (!h["checkins"].blank?)
checkin = Checkin.new
checkin.checkin_id = h["id"]
checkin.user_id = h["checkins"]["data"]["from"]["id"]
checkin.user_name = h["checkins"]["data"]["from"]["name"]
checkin.tags = h["checkins"]["tags"]["data"]["name"]
checkin.place_id = h["checkins"]["place"]["id"]
checkin.place_name = h["checkins"]["place"]["name"]
checkin.message = h["checkins"]["message"]
checkin.created_time = h["checkins"]["created_time"]
checkin.friend_id = friend.id
checkin.save!
end
end
end
But I get this error:
Koala::Facebook::APIError: HTTP 500: Response body: {"error_code":1,"error_msg":"An unknown error occurred"}
I dont really know what that means, any ideas? And does anybody know how to define a limit on checkins with the koala gem?
I tried something like this:
u.facebook.get_connections("me","friends", :fields => "checkins.limit(2)")
But I got the same error!
In fields, you're requesting information about a friend, but 'checkins' isn't a profile field, it's an entirely different connection altogether.
What you must do is loop through all the friend IDs and get the checkins for each:
friend_checkins = []
friend_ids = u.facebook.get_connections("me","friends", :fields => "id")
friend_ids.each do |friend_id|
friend_checkins << u.facebook.get_connections(friend_id,"checkins")
end
Also, when doing this, it would be a great time to look into batch requests with Koala, as you could potentially be making a lot of calls to the API here..

Resources