From a82f581ff83d7ce05c24d88aa336d3bdfa016712 Mon Sep 17 00:00:00 2001 From: Karthick Date: Tue, 1 Nov 2016 00:29:30 +0530 Subject: [PATCH 01/17] Avoid generation of zero invoice --- app/helpers/wkinvoice_helper.rb | 42 ++++++++++++++++++++++++++------- init.rb | 7 +++++- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/app/helpers/wkinvoice_helper.rb b/app/helpers/wkinvoice_helper.rb index d82a6b2b1..cbdb720bf 100644 --- a/app/helpers/wkinvoice_helper.rb +++ b/app/helpers/wkinvoice_helper.rb @@ -25,16 +25,21 @@ def addInvoice(accountId, projectId, invoiceDate,invoicePeriod) @invoice.modifier_id = User.current.id @invoice.account_id = accountId @invoice.invoice_number = getPluginSetting('wktime_invoice_no_prefix') - if !@invoice.save + errorMsg = generateInvoiceItems(projectId) + errorMsg + end + + def saveInvoice + errorMsg = nil + unless @invoice.save errorMsg = @invoice.errors.full_messages.join("
") else @invoice.invoice_number = @invoice.invoice_number + @invoice.id.to_s @invoice.save - errorMsg = generateInvoiceItems(projectId) end errorMsg end - + def generateInvoices(accountId, projectId, invoiceDate,invoicePeriod) errorMsg = nil account = WkAccount.find(accountId) @@ -51,27 +56,33 @@ def generateInvoices(accountId, projectId, invoiceDate,invoicePeriod) def generateInvoiceItems(projectId) if projectId.blank? || projectId.to_i == 0 WkAccountProject.where(account_id: @invoice.account_id).find_each do |accProj| - addInvoiceItem(accProj) + errorMsg = addInvoiceItem(accProj) end else accountProject = WkAccountProject.where("account_id = ? and project_id = ?", @invoice.account_id, projectId) - addInvoiceItem(accountProject[0]) + errorMsg = addInvoiceItem(accountProject[0]) end - errorMsg = nil errorMsg end def addInvoiceItem(accountProject) if accountProject.billing_type == 'TM' # Add invoice items for Time and Materiel cost - saveTAMInvoiceItem(accountProject) + errorMsg = saveTAMInvoiceItem(accountProject) else # Add invoice item for fixed cost from the scheduled entries + errorMsg = nil genInvFrom = Setting.plugin_redmine_wktime['wktime_generate_invoice_from'] genInvFrom = genInvFrom.blank? ? @invoice.start_date : genInvFrom.to_date scheduledEntries = accountProject.wk_billing_schedules.where(:account_project_id => accountProject.id, :bill_date => genInvFrom .. @invoice.end_date, :invoice_id => nil) totalAmount = 0 scheduledEntries.each do |entry| + if @invoice.id.blank? + errorMsg = saveInvoice + unless errorMsg.blank? + break + end + end invItem = saveFCInvoiceItem(entry) totalAmount = totalAmount + invItem.amount entry.invoice_id = @invoice.id @@ -83,6 +94,7 @@ def addInvoiceItem(accountProject) addTaxes(accountProject, scheduledEntries[0].currency, totalAmount) end end + errorMsg end # Add the invoice items for the scheduled entries @@ -107,6 +119,7 @@ def saveTAMInvoiceItem(accountProject) genInvFrom = genInvFrom.blank? ? @invoice.start_date : genInvFrom.to_date timeEntries = TimeEntry.joins("left outer join custom_values on time_entries.id = custom_values.customized_id and custom_values.customized_type = 'TimeEntry' and custom_values.custom_field_id = #{getSettingCfId('wktime_billing_id_cf')}").where(project_id: accountProject.project_id, spent_on: genInvFrom .. @invoice.end_date).where("custom_values.value is null OR #{getSqlLengthQry("custom_values.value")} = 0 ") + errorMsg = nil totalAmount = 0 lastUserId = 0 lastIssueId = 0 @@ -126,6 +139,12 @@ def saveTAMInvoiceItem(accountProject) updateBilledHours(entry, lasInvItmId) next end + if @invoice.id.blank? + errorMsg = saveInvoice + unless errorMsg.blank? + break + end + end invItem = @invoice.invoice_items.new() lastUserId = entry.user_id lastIssueId = entry.issue_id @@ -149,6 +168,12 @@ def saveTAMInvoiceItem(accountProject) next end lastIssueId = entry.issue_id + if @invoice.id.blank? + errorMsg = saveInvoice + unless errorMsg.blank? + break + end + end invItem = @invoice.invoice_items.new() if accountProject.itemized_bill description = entry.issue.blank? ? entry.project.name : (accountProject.account.account_billing ? entry.project.name + ' - ' + entry.issue.subject : entry.issue.subject) @@ -165,7 +190,8 @@ def saveTAMInvoiceItem(accountProject) end if accountProject.apply_tax && totalAmount>0 addTaxes(accountProject, rateHash['currency'], totalAmount) - end + end + errorMsg end # Update invoice item by the given invoice item Object diff --git a/init.rb b/init.rb index cd3e86ae8..2bc7cc4fa 100644 --- a/init.rb +++ b/init.rb @@ -473,10 +473,15 @@ def plugin Rails.logger.info "==========Invoice job - Started==========" invoiceHelper = Object.new.extend(WkinvoiceHelper) allAccounts = WkAccount.all + errorMsg = nil allAccounts.each do |account| errorMsg = invoiceHelper.generateInvoices(account.id, nil, currentMonthStart, invoicePeriod) end - Rails.logger.info "===== Invoice generated Successfully =====" + if errorMsg.blank? + Rails.logger.info "===== Invoice generated Successfully =====" + else + Rails.logger.info "===== Job failed: #{errorMsg} =====" + end end rescue Exception => e Rails.logger.info "Job failed: #{e.message}" From 6611862bfa55f68ff29b3473c19f3e3e0278a033 Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Tue, 15 Nov 2016 18:47:22 +0530 Subject: [PATCH 02/17] Bug Fixing: Remove email,home phone, mobile fields and validation --- app/controllers/wkaccount_controller.rb | 44 ++++++++++++---------- app/models/wk_account.rb | 1 + app/views/wkaccount/_account_list.html.erb | 4 +- app/views/wkaccount/edit.html.erb | 30 +++++++-------- 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/app/controllers/wkaccount_controller.rb b/app/controllers/wkaccount_controller.rb index 073f7113a..61ffce659 100644 --- a/app/controllers/wkaccount_controller.rb +++ b/app/controllers/wkaccount_controller.rb @@ -38,46 +38,50 @@ def edit @accountEntry = nil unless params[:account_id].blank? @accountEntry = WkAccount.find(params[:account_id]) - else - @accountEntry = @accountEntry end end def update + errorMsg = nil + wkaddress = nil if params[:address_id].blank? || params[:address_id].to_i == 0 wkaddress = WkAddress.new else wkaddress = WkAddress.find(params[:address_id].to_i) end - wkaddress.address1 = params[:address1] - wkaddress.address2 = params[:address2] - wkaddress.work_phone = params[:work_phone] - wkaddress.home_phone = params[:home_phone] - wkaddress.city = params[:city] - wkaddress.state = params[:state] - wkaddress.pin = params[:pin] - wkaddress.mobile = params[:mobile] - wkaddress.email = params[:email] - wkaddress.country = params[:country] - wkaddress.fax = params[:fax] - wkaddress.save() - address_id = wkaddress.id + wkaddress.address1 = params[:address1] unless params[:address1].blank? + wkaddress.address2 = params[:address2] unless params[:address2].blank? + wkaddress.work_phone = params[:work_phone] unless params[:work_phone].blank? + wkaddress.city = params[:city] unless params[:city].blank? + wkaddress.state = params[:state] unless params[:state].blank? + wkaddress.pin = params[:pin] unless params[:pin].blank? + wkaddress.country = params[:country] unless params[:country].blank? + wkaddress.fax = params[:fax] unless params[:fax].blank? + if params[:account_id].blank? || params[:account_id].to_i == 0 wkaccount = WkAccount.new else wkaccount = WkAccount.find(params[:account_id].to_i) end - wkaccount.address_id = address_id + wkaccount.name = params[:name] wkaccount.account_type = 'A' wkaccount.account_billing = params[:account_billing].blank? ? 0 : params[:account_billing] - wkaccount.save() - if wkaccount.save() + unless wkaccount.save() + errorMsg = wkaccount.errors.full_messages.join("
") + else + if wkaddress.changed? + wkaddress.save() + wkaccount.address_id = wkaddress.id + wkaccount.save() + end + end + if errorMsg.nil? redirect_to :controller => 'wkaccount',:action => 'index' , :tab => 'wkaccount' flash[:notice] = l(:notice_successful_update) else - redirect_to :controller => 'wkaccount',:action => 'edit' , :tab => 'wkaccount' - flash[:error] = wkaccount.errors.full_messages.join("
") + flash[:error] = errorMsg #wkaccount.errors.full_messages.join("
") + redirect_to :controller => 'wkaccount',:action => 'edit', :account_id => wkaccount.id end end diff --git a/app/models/wk_account.rb b/app/models/wk_account.rb index 290e04d57..ecd7a8e39 100644 --- a/app/models/wk_account.rb +++ b/app/models/wk_account.rb @@ -6,6 +6,7 @@ class WkAccount < ActiveRecord::Base has_many :invoice_items, through: :invoices has_many :projects, through: :wk_account_projects has_many :contracts, foreign_key: "account_id", class_name: "WkContract", :dependent => :destroy + validates_presence_of :name # Returns account's contracts for the given project # or nil if the account do not have contract diff --git a/app/views/wkaccount/_account_list.html.erb b/app/views/wkaccount/_account_list.html.erb index f2b282355..6ec04535f 100644 --- a/app/views/wkaccount/_account_list.html.erb +++ b/app/views/wkaccount/_account_list.html.erb @@ -6,7 +6,7 @@ <%= l(:label_account_name) %> <%= l(:label_account_address) %> <%= l(:label_work_phone) %> - <%= l(:label_email) %> + <%= l(:label_country) %> <%= l(:label_city) %> @@ -18,7 +18,7 @@ <%=h entry.name %> <%=h entry.address.blank? ? "" : entry.address.address1 %> <%=h entry.address.blank? ? "" : entry.address.work_phone %> - <%=h entry.address.blank? ? "" : entry.address.email %> + <%=h entry.address.blank? ? "" : entry.address.country %> <%=h entry.address.blank? ? "" : entry.address.city %> diff --git a/app/views/wkaccount/edit.html.erb b/app/views/wkaccount/edit.html.erb index be81e539a..9c98886bf 100644 --- a/app/views/wkaccount/edit.html.erb +++ b/app/views/wkaccount/edit.html.erb @@ -2,14 +2,14 @@

<%=@accountEntry.blank? ? l(:label_new_account) : l(:label_edit_account) %>

-
+
<%=l(:label_account_information)%> <%=h hidden_field_tag('account_id', @accountEntry.blank? ? "" :@accountEntry.id) %> <%=h hidden_field_tag('address_id', @accountEntry.blank? ? "" :@accountEntry.address_id) %> - + @@ -17,23 +17,23 @@ - + - + - +
<%= l(:label_account_name) %><%=h text_field_tag("name",@accountEntry.blank? ? "" : @accountEntry.name,:size => 20, :required => true) %> <%=h text_field_tag("name",@accountEntry.blank? ? "" : @accountEntry.name,:size => 20) %>
<%= l(:label_account_billing) %>
<%= l(:label_work_phone) %><%=h text_field_tag("work_phone",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.work_phone,:size => 20, :required => true) %> <%=h text_field_tag("work_phone",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.work_phone,:size => 20) %>
<%= l(:label_fax) %><%=h text_field_tag("fax",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.fax,:size => 20, :required => true) %> <%=h text_field_tag("fax",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.fax,:size => 20) %>
@@ -44,27 +44,27 @@ - + - + - + - + - + - +
<%= l(:label_account_address1) %><%=h text_field_tag("address1",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.address1,:size =>40,:required => true) %> <%=h text_field_tag("address1",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.address1,:size =>40) %>
<%= l(:label_account_address2) %><%=h text_field_tag("address2",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.address2,:size =>40,:required => true) %> <%=h text_field_tag("address2",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.address2,:size =>40) %>
<%= l(:label_city) %><%=h text_field_tag("city",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.city,:size =>30,:required => true) %> <%=h text_field_tag("city",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.city,:size =>30) %>
<%= l(:label_state) %><%=h text_field_tag("state",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.state,:size =>30,:required => true) %> <%=h text_field_tag("state",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.state,:size =>30) %>
<%= l(:label_country) %><%=h text_field_tag("country",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.country,:size =>30,:required => true) %> <%=h text_field_tag("country",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.country,:size =>30) %>
<%= l(:label_pin) %><%=h text_field_tag("pin",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.pin,:size =>30,:required => true) %> <%=h text_field_tag("pin",@accountEntry.blank? || @accountEntry.address.blank? ? "" : @accountEntry.address.pin,:size =>30) %>
From 96c63839433f445948187d07dc7af7dc50dceee3 Mon Sep 17 00:00:00 2001 From: Karthick Date: Wed, 16 Nov 2016 16:36:29 +0530 Subject: [PATCH 03/17] Delete associated billed id custom field values when delete ivoice item --- app/controllers/wkinvoice_controller.rb | 31 +++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/app/controllers/wkinvoice_controller.rb b/app/controllers/wkinvoice_controller.rb index 56fb2d0ab..597ca97c2 100644 --- a/app/controllers/wkinvoice_controller.rb +++ b/app/controllers/wkinvoice_controller.rb @@ -77,9 +77,10 @@ def invreport def update errorMsg = nil invoiceItem = nil - invItemId = WkInvoiceItem.select(:id).where(:invoice_id => params["invoice_id"].to_i) - arrId = invItemId.map {|i| i.id } + #invItemId = WkInvoiceItem.select(:id).where(:invoice_id => params["invoice_id"].to_i) + #arrId = invItemId.map {|i| i.id } @invoice = WkInvoice.find(params["invoice_id"].to_i) + arrId = @invoice.invoice_items.pluck(:id) @invoice.status = params[:field_status] if @invoice.status_changed? @invoice.closed_on = Time.now @@ -87,19 +88,30 @@ def update end totalAmount = 0 tothash = Hash.new - for i in 1..(params[:totalrow].to_i) - if !params["item_id#{i}"].blank? + totalRow = params[:totalrow].to_i + savedRows = 0 + deletedRows = 0 + #for i in 1..totalRow + while savedRows < totalRow + i = savedRows + deletedRows + 1 + if params["item_id#{i}"].blank? && params["project_id#{i}"].blank? + deletedRows = deletedRows + 1 + next + end + unless params["item_id#{i}"].blank? arrId.delete(params["item_id#{i}"].to_i) invoiceItem = WkInvoiceItem.find(params["item_id#{i}"].to_i) updatedItem = updateInvoiceItem(invoiceItem, params["project_id#{i}"], params["name#{i}"], params["rate#{i}"].to_f, params["quantity#{i}"].to_f, invoiceItem.currency) - else + else invoiceItem = @invoice.invoice_items.new updatedItem = updateInvoiceItem(invoiceItem, params["project_id#{i}"], params["name#{i}"], params["rate#{i}"].to_f, params["quantity#{i}"].to_f, params["currency#{i}"]) end + savedRows = savedRows + 1 tothash[updatedItem.project_id] = [(tothash[updatedItem.project_id].blank? ? 0 : tothash[updatedItem.project_id][0]) + updatedItem.amount, updatedItem.currency] end if !arrId.blank? + deleteBilledEntries(arrId) WkInvoiceItem.delete_all(:id => arrId) end @@ -119,11 +131,16 @@ def update end def destroy - WkInvoice.find(params[:invoice_id].to_i).destroy - + invoice = WkInvoice.find(params[:invoice_id].to_i)#.destroy + deleteBilledEntries(invoice.invoice_items.pluck(:id)) + invoice.destroy flash[:notice] = l(:notice_successful_delete) redirect_back_or_default :action => 'index', :tab => params[:tab] end + + def deleteBilledEntries(invItemIdsArr) + CustomField.find(getSettingCfId('wktime_billing_id_cf')).custom_values.where(:value => invItemIdsArr).delete_all unless getSettingCfId('wktime_billing_id_cf').blank? || getSettingCfId('wktime_billing_id_cf') == 0 + end def getAccountProjIds accArr = "" From 496fbec338f044edb7294e99f649ceef94f66eca Mon Sep 17 00:00:00 2001 From: Karthick Date: Wed, 16 Nov 2016 19:13:52 +0530 Subject: [PATCH 04/17] Add round off ivoice item --- app/controllers/wkinvoice_controller.rb | 7 ++++++ app/helpers/wkinvoice_helper.rb | 20 +++++++++++++++++ app/views/wkinvoice/_edit_invoice.html.erb | 26 +++++++++++++++++----- config/locales/de.yml | 1 + config/locales/en.yml | 3 ++- config/locales/fr.yml | 3 ++- config/locales/it.yml | 3 ++- 7 files changed, 54 insertions(+), 9 deletions(-) diff --git a/app/controllers/wkinvoice_controller.rb b/app/controllers/wkinvoice_controller.rb index 597ca97c2..ef6f91fe4 100644 --- a/app/controllers/wkinvoice_controller.rb +++ b/app/controllers/wkinvoice_controller.rb @@ -121,6 +121,13 @@ def update addTaxes(accountProject[0], val[1], val[0]) end + unless @invoice.id.blank? + totalAmount = @invoice.invoice_items.sum(:amount) + if (totalAmount.round - totalAmount) != 0 + addRoundInvItem(totalAmount) + end + end + if errorMsg.nil? redirect_to :action => 'index' , :tab => 'wkinvoice' flash[:notice] = l(:notice_successful_update) diff --git a/app/helpers/wkinvoice_helper.rb b/app/helpers/wkinvoice_helper.rb index cbdb720bf..f623218d0 100644 --- a/app/helpers/wkinvoice_helper.rb +++ b/app/helpers/wkinvoice_helper.rb @@ -26,6 +26,12 @@ def addInvoice(accountId, projectId, invoiceDate,invoicePeriod) @invoice.account_id = accountId @invoice.invoice_number = getPluginSetting('wktime_invoice_no_prefix') errorMsg = generateInvoiceItems(projectId) + unless @invoice.id.blank? + totalAmount = @invoice.invoice_items.sum(:amount) + if (totalAmount.round - totalAmount) != 0 + addRoundInvItem(totalAmount) + end + end errorMsg end @@ -260,6 +266,20 @@ def addTaxes(accountProject, currency, totalAmount) end end + # Add an invoice item for the round off value + def addRoundInvItem(totalAmount) + invItem = @invoice.invoice_items.new() + invItem.name = l(:label_round_off) + invItem.rate = totalAmount.round - totalAmount + invItem.project_id = @invoice.invoice_items[0].project_id + invItem.currency = @invoice.invoice_items[0].currency + invItem.quantity = 1 + invItem.amount = totalAmount.round - totalAmount + invItem.item_type = 'r' + invItem.modifier_id = User.current.id + invItem.save() + end + # Return the Query string with SQL length function for the given column def getSqlLengthQry(column) if ActiveRecord::Base.connection.adapter_name == 'SQLServer' diff --git a/app/views/wkinvoice/_edit_invoice.html.erb b/app/views/wkinvoice/_edit_invoice.html.erb index 7cc7ef62e..c79319bdf 100644 --- a/app/views/wkinvoice/_edit_invoice.html.erb +++ b/app/views/wkinvoice/_edit_invoice.html.erb @@ -37,8 +37,7 @@ - <% @invoiceItem.each do |entry| %> - <% if entry.item_type == 'i' %> + <% @invoiceItem.where(:item_type => 'i').each do |entry| %> <%=h hidden_field_tag("item_id#{row_index}", entry.id ) %> @@ -55,15 +54,13 @@ :title => l(:button_delete) %> <% row_index = row_index + 1 %> - <% end %> <% end %> <% tax_index = 1 %> - <% @invoiceItem.each do |entry| %> - <% if entry.item_type == 't' %> + <% @invoiceItem.where(:item_type => 't').each do |entry| %> @@ -75,7 +72,24 @@ <% total = total + entry.amount %> <% tax_index = tax_index + 1 %> - <% end %> + <% end %> + +
<%=h hidden_field_tag("tax_id#{tax_index}", entry.id ) %> <%=h hidden_field_tag("pjt_id#{tax_index}", entry.project_id ) %>
+ +<% round_index = 1 %> + + <% @invoiceItem.where(:item_type => 'r').each do |entry| %> + + + + + + + + + <% total = total + entry.amount %> + + <% round_index = round_index + 1 %> <% end %>
<%=h hidden_field_tag("round_id#{round_index}", entry.id ) %><%=h hidden_field_tag("pjt_id#{round_index}", entry.project_id ) %><%= entry.name %><%= entry.currency %>
diff --git a/config/locales/de.yml b/config/locales/de.yml index afae7fc27..978988eb9 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -394,5 +394,6 @@ de: label_bill_date: Bill Date label_account_billing: Account Billing label_sub_total: Sub total + label_round_off: Round Off \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 60b6c24f0..df46ccecd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -394,4 +394,5 @@ en: label_one: one label_bill_date: Bill Date label_account_billing: Account Billing - label_sub_total: Sub total \ No newline at end of file + label_sub_total: Sub total + label_round_off: Round Off \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a901f2b69..5748919e9 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -395,4 +395,5 @@ fr: label_one: one label_bill_date: Bill Date label_account_billing: Account Billing - label_sub_total: Sub total \ No newline at end of file + label_sub_total: Sub total + label_round_off: Round Off \ No newline at end of file diff --git a/config/locales/it.yml b/config/locales/it.yml index 17288154d..83618e5ab 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -392,4 +392,5 @@ it: label_one: one label_bill_date: Bill Date label_account_billing: Account Billing - label_sub_total: Sub total \ No newline at end of file + label_sub_total: Sub total + label_round_off: Round Off \ No newline at end of file From 19696c7755b289e8cecc7deafec9e915b2fef333 Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Thu, 17 Nov 2016 10:34:53 +0530 Subject: [PATCH 05/17] Bug Fixing: Remove validation for value field in invoice component --- assets/javascripts/settings.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/settings.js b/assets/javascripts/settings.js index 4eb4c1984..1392ab328 100644 --- a/assets/javascripts/settings.js +++ b/assets/javascripts/settings.js @@ -173,7 +173,7 @@ function dialogAction() var listBox = document.getElementById("settings_wktime_invoice_components"); var invCompName = document.getElementById("inv_copm_name"); var invCompVal = document.getElementById("inv_copm_value"); - if(invCompName.value != "" && invCompVal.value != ""){ + if(invCompName.value != ""){ //invCompName.value != "" && invCompVal.value != "" if('Add'== leaveAction){ opt = document.createElement("option"); listBox.options.add(opt); @@ -192,9 +192,9 @@ function dialogAction() } else{ var alertMsg = ""; - if(invCompVal.value == ""){ + /*if(invCompVal.value == ""){ alertMsg = lblInvCompVal + " "+ lblInvalid + "\n"; - } + }*/ if(invCompName.value == ""){ alertMsg = lblInvCompName + " "+ lblInvalid + "\n"; } From 489356edebb5c2636d0530085ca242958182d40e Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Thu, 17 Nov 2016 10:36:50 +0530 Subject: [PATCH 06/17] Bug Fixing: Add/edit Account validation --- app/controllers/wkaccount_controller.rb | 17 +++++++---------- app/models/wk_address.rb | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/controllers/wkaccount_controller.rb b/app/controllers/wkaccount_controller.rb index 61ffce659..f26d0bad0 100644 --- a/app/controllers/wkaccount_controller.rb +++ b/app/controllers/wkaccount_controller.rb @@ -57,24 +57,21 @@ def update wkaddress.pin = params[:pin] unless params[:pin].blank? wkaddress.country = params[:country] unless params[:country].blank? wkaddress.fax = params[:fax] unless params[:fax].blank? - + unless wkaddress.save() + errorMsg = wkaddress.errors.full_messages.join("
") + end if params[:account_id].blank? || params[:account_id].to_i == 0 wkaccount = WkAccount.new else wkaccount = WkAccount.find(params[:account_id].to_i) end - + wkaccount.address_id = wkaddress.id wkaccount.name = params[:name] wkaccount.account_type = 'A' wkaccount.account_billing = params[:account_billing].blank? ? 0 : params[:account_billing] - unless wkaccount.save() - errorMsg = wkaccount.errors.full_messages.join("
") - else - if wkaddress.changed? - wkaddress.save() - wkaccount.address_id = wkaddress.id - wkaccount.save() - end + + unless wkaccount.save() + errorMsg = errorMsg.blank? ? wkaccount.errors.full_messages.join("
") : wkaccount.errors.full_messages.join("
") + "
" + errorMsg end if errorMsg.nil? redirect_to :controller => 'wkaccount',:action => 'index' , :tab => 'wkaccount' diff --git a/app/models/wk_address.rb b/app/models/wk_address.rb index f3323514f..4eb6fdd55 100644 --- a/app/models/wk_address.rb +++ b/app/models/wk_address.rb @@ -1,4 +1,5 @@ class WkAddress < ActiveRecord::Base unloadable has_many :wk_accounts, foreign_key: "address_id", class_name: "WkAccount" + validates_presence_of :address1, :work_phone, :fax, :city, :state, :country, :pin end From e0ce4738db3a2b0fde40cad16bdcc004916f7a90 Mon Sep 17 00:00:00 2001 From: Karthick Date: Thu, 17 Nov 2016 12:51:39 +0530 Subject: [PATCH 07/17] Avoid saving address when account not valid --- app/controllers/wkaccount_controller.rb | 26 +++++++++++++------------ app/models/wk_address.rb | 3 ++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/controllers/wkaccount_controller.rb b/app/controllers/wkaccount_controller.rb index f26d0bad0..86df37ac9 100644 --- a/app/controllers/wkaccount_controller.rb +++ b/app/controllers/wkaccount_controller.rb @@ -49,15 +49,15 @@ def update else wkaddress = WkAddress.find(params[:address_id].to_i) end - wkaddress.address1 = params[:address1] unless params[:address1].blank? - wkaddress.address2 = params[:address2] unless params[:address2].blank? - wkaddress.work_phone = params[:work_phone] unless params[:work_phone].blank? - wkaddress.city = params[:city] unless params[:city].blank? - wkaddress.state = params[:state] unless params[:state].blank? - wkaddress.pin = params[:pin] unless params[:pin].blank? - wkaddress.country = params[:country] unless params[:country].blank? - wkaddress.fax = params[:fax] unless params[:fax].blank? - unless wkaddress.save() + wkaddress.address1 = params[:address1] + wkaddress.address2 = params[:address2] + wkaddress.work_phone = params[:work_phone] + wkaddress.city = params[:city] + wkaddress.state = params[:state] + wkaddress.pin = params[:pin] + wkaddress.country = params[:country] + wkaddress.fax = params[:fax] + unless wkaddress.valid? errorMsg = wkaddress.errors.full_messages.join("
") end if params[:account_id].blank? || params[:account_id].to_i == 0 @@ -65,15 +65,17 @@ def update else wkaccount = WkAccount.find(params[:account_id].to_i) end - wkaccount.address_id = wkaddress.id + #wkaccount.address_id = wkaddress.id wkaccount.name = params[:name] wkaccount.account_type = 'A' wkaccount.account_billing = params[:account_billing].blank? ? 0 : params[:account_billing] - - unless wkaccount.save() + unless wkaccount.valid? errorMsg = errorMsg.blank? ? wkaccount.errors.full_messages.join("
") : wkaccount.errors.full_messages.join("
") + "
" + errorMsg end if errorMsg.nil? + wkaddress.save + wkaccount.address_id = wkaddress.id + wkaccount.save redirect_to :controller => 'wkaccount',:action => 'index' , :tab => 'wkaccount' flash[:notice] = l(:notice_successful_update) else diff --git a/app/models/wk_address.rb b/app/models/wk_address.rb index 4eb6fdd55..29958e84d 100644 --- a/app/models/wk_address.rb +++ b/app/models/wk_address.rb @@ -1,5 +1,6 @@ class WkAddress < ActiveRecord::Base unloadable has_many :wk_accounts, foreign_key: "address_id", class_name: "WkAccount" - validates_presence_of :address1, :work_phone, :fax, :city, :state, :country, :pin + validates_presence_of :address1, :work_phone, :fax, :city, :state, :country + validates_numericality_of :pin, :only_integer => true, :greater_than_or_equal_to => 0, :message => :invalid end From fb26275dc64e1d5a7d3830c21452810d7fd0eea2 Mon Sep 17 00:00:00 2001 From: Karthick Date: Thu, 17 Nov 2016 15:00:58 +0530 Subject: [PATCH 08/17] Save rate and quantity as blank for round item Remove project name tax item description --- app/helpers/wkinvoice_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/wkinvoice_helper.rb b/app/helpers/wkinvoice_helper.rb index f623218d0..486e40bbb 100644 --- a/app/helpers/wkinvoice_helper.rb +++ b/app/helpers/wkinvoice_helper.rb @@ -254,7 +254,7 @@ def addTaxes(accountProject, currency, totalAmount) projectTaxes = accountProject.wk_acc_project_taxes projectTaxes.each do |projtax| invItem = @invoice.invoice_items.new() - invItem.name = accountProject.project.name + ' - ' + projtax.tax.name + invItem.name = projtax.tax.name invItem.rate = projtax.tax.rate_pct.blank? ? 0 : projtax.tax.rate_pct invItem.project_id = accountProject.project_id invItem.currency = currency @@ -270,10 +270,10 @@ def addTaxes(accountProject, currency, totalAmount) def addRoundInvItem(totalAmount) invItem = @invoice.invoice_items.new() invItem.name = l(:label_round_off) - invItem.rate = totalAmount.round - totalAmount + invItem.rate = nil invItem.project_id = @invoice.invoice_items[0].project_id invItem.currency = @invoice.invoice_items[0].currency - invItem.quantity = 1 + invItem.quantity = nil invItem.amount = totalAmount.round - totalAmount invItem.item_type = 'r' invItem.modifier_id = User.current.id From 05040c49b4c19165d479ab80df6667305a83bfcf Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Thu, 17 Nov 2016 15:30:38 +0530 Subject: [PATCH 09/17] bug Fixing: report changes --- app/controllers/wkinvoice_controller.rb | 1 + app/views/wkinvoice/invreport.html.erb | 135 +++++++++++++++--------- config/locales/de.yml | 4 +- config/locales/en.yml | 5 +- config/locales/fr.yml | 5 +- config/locales/it.yml | 5 +- 6 files changed, 100 insertions(+), 55 deletions(-) diff --git a/app/controllers/wkinvoice_controller.rb b/app/controllers/wkinvoice_controller.rb index ef6f91fe4..c5ca56c09 100644 --- a/app/controllers/wkinvoice_controller.rb +++ b/app/controllers/wkinvoice_controller.rb @@ -63,6 +63,7 @@ def edit @invoice = WkInvoice.find(params[:invoice_id].to_i) @invoiceItem = @invoice.invoice_items unless params[:is_report].blank? || !to_boolean(params[:is_report]) + @invoiceItem = @invoiceItem.order(:project_id, :item_type) render :action => 'invreport', :layout => false end diff --git a/app/views/wkinvoice/invreport.html.erb b/app/views/wkinvoice/invreport.html.erb index 3d1fb989c..b4fac54d6 100644 --- a/app/views/wkinvoice/invreport.html.erb +++ b/app/views/wkinvoice/invreport.html.erb @@ -1,7 +1,7 @@ <% if !@invoiceItem.blank? %>
-
<%= l(:label_export_invoice) %>
+
<%= l(:label_invoice) %>
@@ -23,8 +23,10 @@ - - + + @@ -37,56 +39,95 @@ + - - - - - - + - <% @invoiceItem.where(:item_type => 'i').each do | entry | %> - - - - - - - - - <% end %> - <% if @invoiceItem.where(:item_type => 't').count > 0 %> - - - - - - - - - <% end %> - - <% @invoiceItem.where(:item_type => 't').each do | entry | %> - - - - - - - - - <% end %> - - - - - - + - + <% unless Setting.plugin_redmine_wktime['wktime_invoice_components'].blank? Setting.plugin_redmine_wktime['wktime_invoice_components'].each do |element| diff --git a/config/locales/de.yml b/config/locales/de.yml index 978988eb9..b9bcfc8cd 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -356,7 +356,7 @@ de: label_bank: Bank label_customer: Customer label_supplier: Supplier - label_export_invoice: EXPORT INVOICE + label_export_invoice: Print Invoice label_authorized_signatory: Authorized Signatory label_place: Place label_trillion: trillion @@ -395,5 +395,5 @@ de: label_account_billing: Account Billing label_sub_total: Sub total label_round_off: Round Off - + label_grand_total: Grand Total \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index df46ccecd..364c6711c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -356,7 +356,7 @@ en: label_bank: Bank label_customer: Customer label_supplier: Supplier - label_export_invoice: EXPORT INVOICE + label_export_invoice: Print Invoice label_authorized_signatory: Authorized Signatory label_place: Place label_erpmine: ERPmine @@ -395,4 +395,5 @@ en: label_bill_date: Bill Date label_account_billing: Account Billing label_sub_total: Sub total - label_round_off: Round Off \ No newline at end of file + label_round_off: Round Off + label_grand_total: Grand Total \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 5748919e9..b3f9da5ac 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -357,7 +357,7 @@ fr: label_bank: Bank label_customer: Customer label_supplier: Supplier - label_export_invoice: EXPORT INVOICE + label_export_invoice: Print Invoice label_authorized_signatory: Authorized Signatory label_place: Place label_erpmine: ERPmine @@ -396,4 +396,5 @@ fr: label_bill_date: Bill Date label_account_billing: Account Billing label_sub_total: Sub total - label_round_off: Round Off \ No newline at end of file + label_round_off: Round Off + label_grand_total: Grand Total \ No newline at end of file diff --git a/config/locales/it.yml b/config/locales/it.yml index 83618e5ab..4ab19abc9 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -354,7 +354,7 @@ it: label_bank: Bank label_customer: Customer label_supplier: Supplier - label_export_invoice: EXPORT INVOICE + label_export_invoice: Print Invoice label_authorized_signatory: Authorized Signatory label_place: Place label_erpmine: ERPmine @@ -393,4 +393,5 @@ it: label_bill_date: Bill Date label_account_billing: Account Billing label_sub_total: Sub total - label_round_off: Round Off \ No newline at end of file + label_round_off: Round Off + label_grand_total: Grand Total \ No newline at end of file From 4c0ead91e08905fd1a96e4c15b15230db7acbeb9 Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Thu, 17 Nov 2016 16:59:54 +0530 Subject: [PATCH 10/17] Bug Fixing: report align --- app/views/wkinvoice/invreport.html.erb | 88 +++++++++++++------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/app/views/wkinvoice/invreport.html.erb b/app/views/wkinvoice/invreport.html.erb index b4fac54d6..3bcb64135 100644 --- a/app/views/wkinvoice/invreport.html.erb +++ b/app/views/wkinvoice/invreport.html.erb @@ -15,20 +15,18 @@
<%= l(:label_invoice_date) %>
<%=h Setting.plugin_redmine_wktime['wktime_company_name'] + " " + Setting.plugin_redmine_wktime['wktime_company_address'] %><%=h @invoice.account.name + " " + @invoice.account.address.address1 + " " + @invoice.account.address.city + " " + @invoice.account.address.state + " " + @invoice.account.address.country + " " + @invoice.account.address.pin.to_s %><%=h Setting.plugin_redmine_wktime['wktime_company_name'] + "\n" + Setting.plugin_redmine_wktime['wktime_company_address'] %> + + <%=h @invoice.account.name + "\n" + @invoice.account.address.address1 + "\n" + (@invoice.account.address.address2.blank? ? "" : @invoice.account.address.address2) + "\n" + @invoice.account.address.city + " " + @invoice.account.address.state + "\n" + @invoice.account.address.pin.to_s + "\n" + @invoice.account.address.country %> <%=h @invoice.invoice_number %> <%=h @invoice.invoice_date.to_formatted_s(:long) %>
<%=h accContract.contract_number + " - " + accContract.start_date.to_formatted_s(:long) unless accContract.blank? %> <%=h @invoice.start_date.to_formatted_s(:long) + ' to ' + @invoice.end_date.to_formatted_s(:long) %>
<%= l(:label_invoice_name) %><%= l(:label_billing_type) %><%= l(:label_rate) %><%= l(:label_quantity) %><%= l(:label_wk_currency) %><%= l(:field_amount) %> + + + + + + + + + + <% lastItemType = nil %> + <% lastProjectId = nil %> + <% @invoiceItem.each do | entry | %> + <% if entry.item_type != 'r' %> + <% if !lastItemType.blank? && entry.item_type != lastItemType && lastProjectId == entry.project_id %> + + + + + + + + + <% end %> + + <% if !lastProjectId.blank? && lastProjectId != entry.project_id %> + + + + + + + + + <% end %> + + + + + + + + + + <% end %> + + <% lastItemType = entry.item_type%> + <% lastProjectId = entry.project_id %> + <% end %> + + + + + + + + + <% @invoiceItem.where(:item_type => 'r').each do | entry | %> + + + + + + + + + <% end %> +
<%= l(:label_invoice_name) %><%= l(:label_billing_type) %><%= l(:label_rate) %><%= l(:label_quantity) %><%= l(:label_wk_currency) %><%= l(:field_amount) %>
<%=h l(:label_sub_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId, :item_type => 'i').sum(:quantity) %><%=h entry.currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId, :item_type => 'i').sum(:amount) %>
<%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:quantity) %><%=h entry.currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %>
<%=h entry.name %><%=h entry.item_type == 'i' ? l(:field_hours) : '' %><%=h "%.2f" % entry.rate unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%>
<%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %>
<%=h entry.name %><%=h entry.item_type == 'i' ? l(:field_hours) : '' %><%=h "%.2f" % entry.rate unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%>
+
<%=h entry.name %><%=h l(:field_hours) %><%=h "%.2f" % entry.rate unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%>
<%=h l(:label_sub_total) %><%=h "%.2f" % @invoiceItem.where(:item_type => 'i').sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.where(:item_type => 'i').sum(:amount) %>
<%=h entry.name %><%=h l(:label_tax) %><%=h "%.2f" % entry.rate.to_s + "%" unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%>
<%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.sum(:amount) %> + + + + + + + + + +
<%=h l(:label_grand_total) %><%=h "%.2f" % @invoiceItem.sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.sum(:amount) %>
+
<%= l(:label_amount_in_words) %><%=h numberInWords(@invoiceItem.sum(:amount)) + " only" %><%=h numberInWords(@invoiceItem.sum(:amount)) + " only." %>
- - +
+ - - - + + + - - - - + + + + @@ -42,47 +40,47 @@ From 07cf03790df042559cd8ee2c6b1bb09d8e90da2f Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Thu, 17 Nov 2016 18:59:50 +0530 Subject: [PATCH 11/17] Bug Fixing: report and fix invoice round off --- app/views/wkinvoice/_edit_invoice.html.erb | 12 ++++++------ app/views/wkinvoice/invreport.html.erb | 14 +++++++------- assets/javascripts/invoice.js | 7 +++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/views/wkinvoice/_edit_invoice.html.erb b/app/views/wkinvoice/_edit_invoice.html.erb index c79319bdf..e66e32be5 100644 --- a/app/views/wkinvoice/_edit_invoice.html.erb +++ b/app/views/wkinvoice/_edit_invoice.html.erb @@ -64,11 +64,11 @@ - - - + + + - + <% total = total + entry.amount %> <% tax_index = tax_index + 1 %> @@ -86,12 +86,12 @@ - + <% total = total + entry.amount %> <% round_index = round_index + 1 %> <% end %> - +
<%= l(:label_name_address_of,l(:label_supplier)) %><%= l(:label_name_address_of,l(:label_customer)) %><%= l(:label_invoice_number) %><%= l(:label_invoice_date) %><%= l(:label_name_address_of,l(:label_customer)) %><%= l(:label_invoice_number) %><%= l(:label_invoice_date) %>
<%=h Setting.plugin_redmine_wktime['wktime_company_name'] + "\n" + Setting.plugin_redmine_wktime['wktime_company_address'] %> - - <%=h @invoice.account.name + "\n" + @invoice.account.address.address1 + "\n" + (@invoice.account.address.address2.blank? ? "" : @invoice.account.address.address2) + "\n" + @invoice.account.address.city + " " + @invoice.account.address.state + "\n" + @invoice.account.address.pin.to_s + "\n" + @invoice.account.address.country %> <%=h @invoice.invoice_number %><%=h @invoice.invoice_date.to_formatted_s(:long) %><%=h Setting.plugin_redmine_wktime['wktime_company_name'] + "\n" + Setting.plugin_redmine_wktime['wktime_company_address'] %><%=h @invoice.account.name + "\n" + @invoice.account.address.address1 + "\n" + (@invoice.account.address.address2.blank? ? "" : (@invoice.account.address.address2) + "\n") + @invoice.account.address.city + " " + @invoice.account.address.state + "\n" + @invoice.account.address.pin.to_s + "\n" + @invoice.account.address.country %> <%=h @invoice.invoice_number %><%=h @invoice.invoice_date.to_formatted_s(:long) %>
<%= l(:label_cntrt_purchase_work_order) %>
- - +
+ - - - - + + + + <% lastItemType = nil %> <% lastProjectId = nil %> <% @invoiceItem.each do | entry | %> <% if entry.item_type != 'r' %> <% if !lastItemType.blank? && entry.item_type != lastItemType && lastProjectId == entry.project_id %> - + - - - - + + + + <% end %> <% if !lastProjectId.blank? && lastProjectId != entry.project_id %> - + - - - - + + + + <% end %> - - - - + + + + <% end %> @@ -90,22 +88,22 @@ <% lastItemType = entry.item_type%> <% lastProjectId = entry.project_id %> <% end %> - + - - - - + + + + <% @invoiceItem.where(:item_type => 'r').each do | entry | %> - - - - + + + + <% end %>
<%= l(:label_invoice_name) %> <%= l(:label_billing_type) %><%= l(:label_rate) %><%= l(:label_quantity) %><%= l(:label_wk_currency) %><%= l(:field_amount) %><%= l(:label_rate) %><%= l(:label_quantity) %><%= l(:label_wk_currency) %><%= l(:field_amount) %>
<%=h l(:label_sub_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId, :item_type => 'i').sum(:quantity) %><%=h entry.currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId, :item_type => 'i').sum(:amount) %><%=h l(:label_sub_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId, :item_type => 'i').sum(:quantity) %><%=h entry.currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId, :item_type => 'i').sum(:amount) %>
<%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:quantity) %><%=h entry.currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %><%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:quantity) %><%=h entry.currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %>
<%=h entry.name %> <%=h entry.item_type == 'i' ? l(:field_hours) : '' %><%=h "%.2f" % entry.rate unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%><%=h ("%.2f" % entry.rate).to_s + (entry.item_type == 'i' ? '' : "%") unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%>
<%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %><%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %>
<%=h entry.name %> <%=h entry.item_type == 'i' ? l(:field_hours) : '' %><%=h "%.2f" % entry.rate unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%><%=h "%.2f" % entry.rate unless entry.rate.blank? %><%=h "%.2f" % entry.quantity unless entry.quantity.blank? %><%=h entry.currency %><%=h "%.2f" % entry.amount unless entry.amount.blank?%>
@@ -115,12 +113,12 @@
- + - - - - + + + +
<%=h l(:label_grand_total) %><%=h "%.2f" % @invoiceItem.sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.sum(:amount) %><%=h l(:label_grand_total) %><%=h "%.2f" % @invoiceItem.sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.sum(:amount) %>
<%=h hidden_field_tag("tax_id#{tax_index}", entry.id ) %> <%=h hidden_field_tag("pjt_id#{tax_index}", entry.project_id ) %><%= entry.name %> <%= entry.name %> <%= entry.quantity %><%= entry.currency %><%= entry.currency %>
<%= entry.currency %><%= entry.currency %>
<%=h hidden_field_tag("totalrow", row_index-1 ) %> diff --git a/app/views/wkinvoice/invreport.html.erb b/app/views/wkinvoice/invreport.html.erb index 3bcb64135..f968aacbf 100644 --- a/app/views/wkinvoice/invreport.html.erb +++ b/app/views/wkinvoice/invreport.html.erb @@ -94,7 +94,7 @@ <%=h l(:label_total) %> <%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:quantity) %> <%=h @invoiceItem[0].currency %> - <%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %> + <%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %> <% @invoiceItem.where(:item_type => 'r').each do | entry | %> @@ -113,12 +113,12 @@ - - - - - - + + + + + +
<%=h l(:label_grand_total) %><%=h "%.2f" % @invoiceItem.sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.sum(:amount) %><%=h l(:label_grand_total) %><%=h "%.2f" % @invoiceItem.sum(:quantity) %><%=h @invoiceItem[0].currency %><%=h "%.2f" % @invoiceItem.sum(:amount) %>
diff --git a/assets/javascripts/invoice.js b/assets/javascripts/invoice.js index a13069945..80f5aabd3 100644 --- a/assets/javascripts/invoice.js +++ b/assets/javascripts/invoice.js @@ -114,6 +114,13 @@ function addAmount(fldId) } document.getElementById('invsubtotal').innerHTML = "SubTotal : " + total.toFixed(2); document.getElementById('invtotalamount').innerHTML = "Total : " + (taxtotal + total).toFixed(2); + var roundtotal = Math.round(taxtotal + total); + var roundlen = document.getElementById('taxTable').rows.length; + if(roundlen > 1) + { + document.getElementById('roundamount').innerHTML = (roundtotal - (taxtotal + total)).toFixed(2); + } + document.getElementById('roundtotalamount').innerHTML = roundtotal.toFixed(2); } function deleteRow(tableId, totalrow) From fb96af46224be22d49514159cc4977afd40811c0 Mon Sep 17 00:00:00 2001 From: Karthick Date: Fri, 18 Nov 2016 14:54:40 +0530 Subject: [PATCH 12/17] Label And alignment changes --- app/views/wkattendance/clockedit.html.erb | 2 +- app/views/wkinvoice/_edit_invoice.html.erb | 8 +++++--- app/views/wkinvoice/invreport.html.erb | 6 +++--- app/views/wktime/_attendance.html.erb | 2 +- app/views/wktime/_attendance_widget.html.erb | 2 +- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- config/locales/it.yml | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/views/wkattendance/clockedit.html.erb b/app/views/wkattendance/clockedit.html.erb index 32fc86ad6..5f7097b7a 100644 --- a/app/views/wkattendance/clockedit.html.erb +++ b/app/views/wkattendance/clockedit.html.erb @@ -69,7 +69,7 @@ <% end %> " > - + <%=h text_field_tag("tothours", totalhours.round(2),:size => 10, :disabled => isAccountUser ? false : true, :required => true) %> diff --git a/app/views/wkinvoice/_edit_invoice.html.erb b/app/views/wkinvoice/_edit_invoice.html.erb index e66e32be5..adc1f671d 100644 --- a/app/views/wkinvoice/_edit_invoice.html.erb +++ b/app/views/wkinvoice/_edit_invoice.html.erb @@ -57,7 +57,9 @@ <% end %> +<% if @invoiceItem.where(:item_type => 't').count > 0 %> +<% end %> <% tax_index = 1 %> <% @invoiceItem.where(:item_type => 't').each do |entry| %> @@ -88,10 +90,10 @@ <% total = total + entry.amount %> - + + <% round_index = round_index + 1 %> - <% end %> - + <% end %>
<%= entry.currency %>
<%=h hidden_field_tag("totalrow", row_index-1 ) %> diff --git a/app/views/wkinvoice/invreport.html.erb b/app/views/wkinvoice/invreport.html.erb index f968aacbf..e2f69308a 100644 --- a/app/views/wkinvoice/invreport.html.erb +++ b/app/views/wkinvoice/invreport.html.erb @@ -1,7 +1,7 @@ <% if !@invoiceItem.blank? %>
-
<%= l(:label_invoice) %>
+
<%= (l(:label_invoice)).upcase %>
@@ -88,7 +88,7 @@ <% lastItemType = entry.item_type%> <% lastProjectId = entry.project_id %> <% end %> - + @@ -97,7 +97,7 @@ <% @invoiceItem.where(:item_type => 'r').each do | entry | %> - + diff --git a/app/views/wktime/_attendance.html.erb b/app/views/wktime/_attendance.html.erb index ca106821e..dbcb96c55 100644 --- a/app/views/wktime/_attendance.html.erb +++ b/app/views/wktime/_attendance.html.erb @@ -72,7 +72,7 @@ <% end %> <%=h hidden_field_tag("attnDayEntriesCnt_#{i}", j) %>

- <%= l(:label_grand_total) %> + <%= l(:label_total_hours) %> <%= text_field_tag "grandTotal_#{i}" , "" , :size => 4, :disabled => disable %>

<% if isAccountUser %> diff --git a/app/views/wktime/_attendance_widget.html.erb b/app/views/wktime/_attendance_widget.html.erb index e079fc33f..bd9b151bc 100644 --- a/app/views/wktime/_attendance_widget.html.erb +++ b/app/views/wktime/_attendance_widget.html.erb @@ -28,7 +28,7 @@ <% totalhours = (hideStart ? ( !remaininghr.blank? ? remaininghr.round(0)+totalhours : totalhours) : totalhours ) %> <% totalhours1 = Time.at(totalhours).utc.strftime("%H:%M:%S") %> <% if User.current.logged? && wktime_helper.checkViewPermission %> - - + - + <% total = total + entry.amount %> From 3544470e98743ed6590ed617c8e442f03197e930 Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Fri, 18 Nov 2016 15:15:36 +0530 Subject: [PATCH 15/17] Bug Fixing: Alignment changes in invoice edit --- app/views/wkinvoice/_edit_invoice.html.erb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/wkinvoice/_edit_invoice.html.erb b/app/views/wkinvoice/_edit_invoice.html.erb index fbd9d4b1d..cbb9454cb 100644 --- a/app/views/wkinvoice/_edit_invoice.html.erb +++ b/app/views/wkinvoice/_edit_invoice.html.erb @@ -64,18 +64,18 @@
<%=h l(:label_total) %><%=h "%.2f" % @invoiceItem.where(:project_id => lastProjectId).where.not(:item_type => 'r').sum(:amount) %>
<%=h entry.name %> <%=h entry.item_type == 'i' ? l(:field_hours) : '' %> <%=h "%.2f" % entry.rate unless entry.rate.blank? %>
<%=h hidden_field_tag("tax_id#{tax_index}", entry.id ) %><%=h hidden_field_tag("pjt_id#{tax_index}", entry.project_id ) %><%=h entry.project.name%> <%= entry.name %> <%= entry.quantity %><%=h hidden_field_tag("pjt_id#{tax_index}", entry.project_id ) %> <%= entry.currency %>
<% @invoiceItem.where(:item_type => 't').each do |entry| %> - - - - - - - + + + + + + + <% total = total + entry.amount %> <% tax_index = tax_index + 1 %> <% end %> - +
<%=h hidden_field_tag("tax_id#{tax_index}", entry.id ) %><%=h entry.project.name%><%= entry.name %> <%=h hidden_field_tag("pjt_id#{tax_index}", entry.project_id ) %><%= entry.currency %><%=h hidden_field_tag("tax_id#{tax_index}", entry.id ) %><%=h entry.project.name%><%= entry.name %> <%=h hidden_field_tag("pjt_id#{tax_index}", entry.project_id ) %><%= entry.currency %>
<% round_index = 1 %> @@ -88,10 +88,10 @@ - <%= entry.currency %> + <%= entry.currency %> <% total = total + entry.amount %> - + <% round_index = round_index + 1 %> <% end %> From 90cf19a796bb17eace7ecbaa52f84cf10cd6ba35 Mon Sep 17 00:00:00 2001 From: dhineshrajasekar Date: Fri, 18 Nov 2016 15:20:19 +0530 Subject: [PATCH 16/17] update readme doc --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 20ae22eed..2a589ecd1 100644 --- a/README.rdoc +++ b/README.rdoc @@ -52,7 +52,7 @@ Release Notes for 2.5.2 Features: - Billing module is introduced. BugFixing: - - Fixed: Account working on mac safari. + - Fixed: Account validation not working on mac safari. Customization: For any Customization/Support, please contact us, our consulting team will be happy to help you From 1c30860daa92f501fe4ef1388ffda17dcb13084b Mon Sep 17 00:00:00 2001 From: Karthick Date: Fri, 18 Nov 2016 15:27:34 +0530 Subject: [PATCH 17/17] Give space for signature --- app/views/wkinvoice/invreport.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/wkinvoice/invreport.html.erb b/app/views/wkinvoice/invreport.html.erb index e2f69308a..1108072f8 100644 --- a/app/views/wkinvoice/invreport.html.erb +++ b/app/views/wkinvoice/invreport.html.erb @@ -138,7 +138,9 @@ <% end %>
-
+
+
+
<%= l(:label_place) %> :