update rake shift_sales:audit

This commit is contained in:
Thein Lin Kyaw
2020-05-22 17:28:23 +06:30
parent e5a27aaac9
commit 8bae89eeac

View File

@@ -1,6 +1,6 @@
namespace :shift_sales do
desc "TODO"
task :audit, [:shift_sale_ids, :repayment] => [:environment] do |tasks, args|
task :audit, [:shift_sale_ids, :shop_code, :repayment] => [:environment] do |tasks, args|
Rails.logger = Logger.new(STDOUT)
if args[:shift_sale_ids].empty?
@@ -38,13 +38,10 @@ namespace :shift_sales do
sale.grand_total = sale.total_amount - sale.total_discount + sale.total_tax
sale.old_grand_total = grand_total
license = License.new(ENV["SX_PROVISION_URL"])
shop_name = license.read_license_no_decrypt("shop_name")
shop = if Rails.env.production? || shop_name.present?
Shop.find_by(name: shop_name)
if args[:shop_code]
shop = Shop.find_by!(shop_code: args[:shop_code])
else
Shop.first
shop = Shop.first
end
if shop.is_rounding_adj