Skip to content

Instantly share code, notes, and snippets.

<%= f.text_field :company_code %>
it will create this:
"customer"=>{"company_code"=>"aaa"}
<%= text_field_tag("customer_code", @customer_code") %>
it will create this:
"customer_code"=>"aaa"
code:
logger.info "XXX:#{@account_category_maincat}:#{@account_category_subcat}"
logger.info "XXX:#{@account_category.data[@account_category_maincat]}"
logger.info "XXX:#{@account_category.data[@account_category_maincat][@account_category_subcat]}"
maincatdata = @account_category.data[@account_category_maincat]
if maincatdata.has_key?(@account_category_subcat)
logger.info "XXX:haskey"
else
logger.info "XXX:hasnokey"
$.ajax({
url : "<%= updatepayment_invoice_path(@invoice) %>",
type: "PATCH",
dataType: 'json',
data : {"utf8":"✓", "authenticity_token":"DdPKAgDvH/x2HaT6JSxZTXrBuumV+glDWR7AT+zwFaU=",
"id":"1",
"company_id":"1",
"payment_invoice":{"code":"test",
"date":"test",
<form accept-charset="UTF-8" action="/invoices/1" class="edit_invoice" id="edit_invoice_1" method="post"><div style="display:none"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="patch" /><input name="authenticity_token" type="hidden" value="TpR56rhvriaX4eIucvybH6moEdLvtm290RQ4mRQuRZo=" /></div>
this doesnt work: (only takes in payment_total but not the rest)
retval = @invoice.update(:payment_total => 20, :due_amount => 10, :data => clonedata)
this works:
retval = Invoice.where(:id => @invoice.id).update_all(:payment_total => 20,
:due_amount => 10,
:data => clonedata.to_json)
issue this:
retval = @invoice.update(:payment_total => clonedata["payment_total"],
:due_amount => clonedata["due_amount"] ,
:data => clonedata.to_json)
will output nothing. not UPDATE sql issued. i wonder why
issue this:
[["Code", "Name", "Description", "Quantity", "Price", "Discount", "["ABD", "XYZ"]", "Amount"]]
@invoice["data"]["items"].map do |key, value|
[value["product_code"],
value["product_name"],
value["product_description"],
value["product_quantity"],
value["product_price"],
jsondata ='{"1":
{"name": "Tax Exempt", "abbreviation": "Tax Exempt", "description": "",
"tax_percentage": "0.0", "tax_num": "", "recoverable": false, "compound_tax": false},
"2":
{"name": "Tax on Purchases", "abbreviation": "GST Purchase", "description": "",
"tax_percentage": "6.0", "tax_num": "", "recoverable": false, "compound_tax": false},
"3":
{"name": "Tax on Sales", "abbreviation": "GST Sales","description": "",
@general_ledgers = GeneralLedger.where(:company_id => current_user.companies.first.id,
:gl_date >= params["general_ledger"]["from_date"],
:gl_date <= params["general_ledger"]["to_date"]).order(:gl_date)
def update
from_account_category = JSON.parse(params["bank_cash_journal"]["from_account"])
@bank_cash_journal.from_account_maincat = from_account_category["maincat"]
@bank_cash_journal.from_account_subcat = from_account_category["subcat"]
@bank_cash_journal.from_account_code = from_account_category["code"]
@bank_cash_journal.from_account_name = from_account_category["name"]
retval = @bank_cash_journal.update ??? usually its @bank_cash_journal.update(bank_cash_journal_params)