Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

better pre-payment support for banks

  • Loading branch information...
commit 2a839677bba650c605efa04b1dab4ad156b1853f 1 parent c3eafbe
Dimitri Kurashvili authored
View
2  app/controllers/application_controller.rb
@@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery
# რა რაოდენობის მონაცემის გამოტანაა შესძლებელი 1 გვერდზე
- MAX_PER_PAGE = 1000
+ MAX_PER_PAGE = 100
# ერთ გვერდზე გამოტანის საწყისი მნიშვნელობა
DEFAULT_PER_PAGE = 10
View
4 app/controllers/banks_controller.rb
@@ -31,7 +31,7 @@ def index
#
# GET /bank-:bank_id/cust
def cust_index
- @customers = BankCustomer.where(:bank_id => @bank.id).paginate(:page => params[:page], :per_page => per_page)
+ @customers = BankCustomer.where(:bank_id => @bank.id).paginate(page: params[:page], per_page: per_page)
respond_to do |format|
format.html { @title = "აბონენტების მართვა" }
format.xml { }
@@ -43,8 +43,6 @@ def cust_index
# GET /bank-:bank_id/:id
def cust_show
@customer = find_bank_customer
- @pre_payments = Payment.where(:custkey => @customer.customer.custkey, :status => [0, 1])
- @pre_trash_payments = TrashPayment.where(:custkey => @customer.customer.custkey, :status => [0, 1])
@title = 'აბონენტის თვისებები'
end
View
2  app/models/customer.rb
@@ -5,4 +5,6 @@ class Customer < ActiveRecord::Base
set_primary_key :custkey
ka_accessor :custname, :accnumb
has_one :address, foreign_key: :premisekey
+ has_many :pre_payments, class_name: 'Payment', foreign_key: :custkey, conditions: {status: [0,1]}
+ has_many :pre_trash_payments, class_name: 'TrashPayment', foreign_key: :custkey, conditions: {status: [0,1]}
end
View
8 app/views/banks/_customer.xml.haml
@@ -3,16 +3,16 @@
%number= cust.customer.accnumb_ka
%balance= cust.customer.balance
%balance_trash= cust.trash_customer ? cust.trash_customer.curr_balance : 0
- - if defined?(pre_payments) and pre_payments and pre_payments.any?
+ - if cust.customer.pre_payments.any?
%pre-payments
- - pre_payments.each do |pay|
+ - cust.customer.pre_payments.each do |pay|
%payment
%paydate= pay.paydate.strftime('%Y-%m-%d')
%amount= number_format pay.amount
%docnumber= pay.billnumber_ka
- - if defined?(pre_trash_payments) and pre_trash_payments and pre_trash_payments.any?
+ - if cust.customer.pre_trash_payments.any?
%pre-trash-payments
- - pre_trash_payments.each do |pay|
+ - cust.customer.pre_trash_payments.each do |pay|
%payment
%paydate= pay.paydate.strftime('%Y-%m-%d')
%amount= number_format pay.amount
View
2  app/views/banks/cust_show.xml.haml
@@ -1 +1 @@
-= render :partial => 'banks/customer', :locals => {:cust => @customer, :pre_payments => @pre_payments, :pre_trash_payments => @pre_trash_payments}
+= render :partial => 'banks/customer', :locals => {:cust => @customer }
Please sign in to comment.
Something went wrong with that request. Please try again.