sales listing under transacitons
This commit is contained in:
3
app/assets/javascripts/transactions/sales.coffee
Normal file
3
app/assets/javascripts/transactions/sales.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/transactions/sales.scss
Normal file
3
app/assets/stylesheets/transactions/sales.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the transactions/Sales controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
74
app/controllers/transactions/sales_controller.rb
Normal file
74
app/controllers/transactions/sales_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Transactions::SalesController < ApplicationController
|
||||
before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /transactions/sales
|
||||
# GET /transactions/sales.json
|
||||
def index
|
||||
@transactions_sales = Sale.all
|
||||
end
|
||||
|
||||
# GET /transactions/sales/1
|
||||
# GET /transactions/sales/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /transactions/sales/new
|
||||
def new
|
||||
@transactions_sale = Sale.new
|
||||
end
|
||||
|
||||
# GET /transactions/sales/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /transactions/sales
|
||||
# POST /transactions/sales.json
|
||||
def create
|
||||
@transactions_sale = Sale.new(transactions_sale_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @transactions_sale.save
|
||||
format.html { redirect_to @transactions_sale, notice: 'Sale was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @transactions_sale }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @transactions_sale.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /transactions/sales/1
|
||||
# PATCH/PUT /transactions/sales/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @transactions_sale.update(transactions_sale_params)
|
||||
format.html { redirect_to @transactions_sale, notice: 'Sale was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @transactions_sale }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @transactions_sale.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /transactions/sales/1
|
||||
# DELETE /transactions/sales/1.json
|
||||
def destroy
|
||||
@transactions_sale.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_transactions_sale
|
||||
@transactions_sale = Sale.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def transactions_sale_params
|
||||
params.require(:transactions_sale).permit(:cashier_id, :cashier_name, :requested_by, :requested_at, :receipt_no, :receipt_date, :customer_id, :payment_status, :sale_status, :total_amount, :total_discount, :total_tax, :tax_type, :grand_total, :rounding_adjustment, :amount_received, :amount_changed)
|
||||
end
|
||||
end
|
||||
2
app/helpers/transactions/sales_helper.rb
Normal file
2
app/helpers/transactions/sales_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Transactions::SalesHelper
|
||||
end
|
||||
5
app/models/transactions.rb
Normal file
5
app/models/transactions.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Transactions
|
||||
def self.table_name_prefix
|
||||
'transactions_'
|
||||
end
|
||||
end
|
||||
27
app/views/transactions/sales/_form.html.erb
Normal file
27
app/views/transactions/sales/_form.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<%= simple_form_for(@transactions_sale) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.association :cashier %>
|
||||
<%= f.input :cashier_name %>
|
||||
<%= f.input :requested_by %>
|
||||
<%= f.input :requested_at %>
|
||||
<%= f.input :receipt_no %>
|
||||
<%= f.input :receipt_date %>
|
||||
<%= f.association :customer %>
|
||||
<%= f.input :payment_status %>
|
||||
<%= f.input :sale_status %>
|
||||
<%= f.input :total_amount %>
|
||||
<%= f.input :total_discount %>
|
||||
<%= f.input :total_tax %>
|
||||
<%= f.input :tax_type %>
|
||||
<%= f.input :grand_total %>
|
||||
<%= f.input :rounding_adjustment %>
|
||||
<%= f.input :amount_received %>
|
||||
<%= f.input :amount_changed %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,2 @@
|
||||
json.extract! transactions_sale, :id, :cashier_id, :cashier_name, :requested_by, :requested_at, :receipt_no, :receipt_date, :customer_id, :payment_status, :sale_status, :total_amount, :total_discount, :total_tax, :tax_type, :grand_total, :rounding_adjustment, :amount_received, :amount_changed, :created_at, :updated_at
|
||||
json.url transactions_sale_url(transactions_sale, format: :json)
|
||||
6
app/views/transactions/sales/edit.html.erb
Normal file
6
app/views/transactions/sales/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing Transactions Sale</h1>
|
||||
|
||||
<%= render 'form', transactions_sale: @transactions_sale %>
|
||||
|
||||
<%= link_to 'Show', @transactions_sale %> |
|
||||
<%= link_to 'Back', transactions_sales_path %>
|
||||
59
app/views/transactions/sales/index.html.erb
Normal file
59
app/views/transactions/sales/index.html.erb
Normal file
@@ -0,0 +1,59 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<h1>Transactions Sales</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Cashier</th>
|
||||
<th>Cashier name</th>
|
||||
<th>Requested by</th>
|
||||
<th>Requested at</th>
|
||||
<th>Receipt no</th>
|
||||
<th>Receipt date</th>
|
||||
<th>Customer</th>
|
||||
<th>Payment status</th>
|
||||
<th>Sale status</th>
|
||||
<th>Total amount</th>
|
||||
<th>Total discount</th>
|
||||
<th>Total tax</th>
|
||||
<th>Tax type</th>
|
||||
<th>Grand total</th>
|
||||
<th>Rounding adjustment</th>
|
||||
<th>Amount received</th>
|
||||
<th>Amount changed</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @transactions_sales.each do |transactions_sale| %>
|
||||
<tr>
|
||||
<td><%= transactions_sale.cashier %></td>
|
||||
<td><%= transactions_sale.cashier_name %></td>
|
||||
<td><%= transactions_sale.requested_by %></td>
|
||||
<td><%= transactions_sale.requested_at %></td>
|
||||
<td><%= transactions_sale.receipt_no %></td>
|
||||
<td><%= transactions_sale.receipt_date %></td>
|
||||
<td><%= transactions_sale.customer %></td>
|
||||
<td><%= transactions_sale.payment_status %></td>
|
||||
<td><%= transactions_sale.sale_status %></td>
|
||||
<td><%= transactions_sale.total_amount %></td>
|
||||
<td><%= transactions_sale.total_discount %></td>
|
||||
<td><%= transactions_sale.total_tax %></td>
|
||||
<td><%= transactions_sale.tax_type %></td>
|
||||
<td><%= transactions_sale.grand_total %></td>
|
||||
<td><%= transactions_sale.rounding_adjustment %></td>
|
||||
<td><%= transactions_sale.amount_received %></td>
|
||||
<td><%= transactions_sale.amount_changed %></td>
|
||||
<td><%= link_to 'Show', transactions_sale %></td>
|
||||
<td><%= link_to 'Edit', edit_transactions_sale_path(transactions_sale) %></td>
|
||||
<td><%= link_to 'Destroy', transactions_sale, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Transactions Sale', new_transactions_sale_path %>
|
||||
1
app/views/transactions/sales/index.json.jbuilder
Normal file
1
app/views/transactions/sales/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @transactions_sales, partial: 'transactions_sales/transactions_sale', as: :transactions_sale
|
||||
5
app/views/transactions/sales/new.html.erb
Normal file
5
app/views/transactions/sales/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New Transactions Sale</h1>
|
||||
|
||||
<%= render 'form', transactions_sale: @transactions_sale %>
|
||||
|
||||
<%= link_to 'Back', transactions_sales_path %>
|
||||
89
app/views/transactions/sales/show.html.erb
Normal file
89
app/views/transactions/sales/show.html.erb
Normal file
@@ -0,0 +1,89 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Cashier:</strong>
|
||||
<%= @transactions_sale.cashier %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Cashier name:</strong>
|
||||
<%= @transactions_sale.cashier_name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Requested by:</strong>
|
||||
<%= @transactions_sale.requested_by %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Requested at:</strong>
|
||||
<%= @transactions_sale.requested_at %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Receipt no:</strong>
|
||||
<%= @transactions_sale.receipt_no %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Receipt date:</strong>
|
||||
<%= @transactions_sale.receipt_date %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Customer:</strong>
|
||||
<%= @transactions_sale.customer %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Payment status:</strong>
|
||||
<%= @transactions_sale.payment_status %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Sale status:</strong>
|
||||
<%= @transactions_sale.sale_status %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Total amount:</strong>
|
||||
<%= @transactions_sale.total_amount %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Total discount:</strong>
|
||||
<%= @transactions_sale.total_discount %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Total tax:</strong>
|
||||
<%= @transactions_sale.total_tax %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Tax type:</strong>
|
||||
<%= @transactions_sale.tax_type %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Grand total:</strong>
|
||||
<%= @transactions_sale.grand_total %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Rounding adjustment:</strong>
|
||||
<%= @transactions_sale.rounding_adjustment %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Amount received:</strong>
|
||||
<%= @transactions_sale.amount_received %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Amount changed:</strong>
|
||||
<%= @transactions_sale.amount_changed %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_transactions_sale_path(@transactions_sale) %> |
|
||||
<%= link_to 'Back', transactions_sales_path %>
|
||||
1
app/views/transactions/sales/show.json.jbuilder
Normal file
1
app/views/transactions/sales/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "transactions_sales/transactions_sale", transactions_sale: @transactions_sale
|
||||
@@ -142,7 +142,12 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
end
|
||||
#--------- Transactions Sections ------------#
|
||||
namespace :transactions do
|
||||
resources :sales
|
||||
end
|
||||
|
||||
#--------- Reports Controller Sections ------------#
|
||||
namespace :reports do
|
||||
resources :sales, :only => [:index, :show]
|
||||
resources :orders, :only => [:index, :show]
|
||||
|
||||
@@ -20,3 +20,5 @@ rails generate scaffold Setup/TaxProfile name:string rate:decimal inclusive:bool
|
||||
rails generate scaffold_controller Setup/CashierTerminal name:string is_active:boolean is_currently_login:boolean auto_print_receipt:string printer_name:string header:json footer:json font:string font_size:string show_tax:boolean show_cashier:boolean show_guest_info:boolean --no-migration
|
||||
|
||||
rails generate scaffold_controller Settings/OrderQueueStation station_name:string is_active:boolean processing_items:json print_copy:boolean printer_name:string font_size:integer cut_per_item:boolean use_alternate_name:boolean created_by:string --no-migration
|
||||
|
||||
rails generate scaffold_controller transactions/Sale cashier:references cashier_name:string requested_by:string requested_at:datetime receipt_no:string receipt_date:datetime customer:references payment_status:string sale_status:string total_amount:decimal total_discount:decimal total_tax:decimal tax_type:string grand_total:decimal rounding_adjustment:decimal amount_received:decimal amount_changed:decimal --no-migration
|
||||
|
||||
141
spec/controllers/transactions/sales_controller_spec.rb
Normal file
141
spec/controllers/transactions/sales_controller_spec.rb
Normal file
@@ -0,0 +1,141 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
#
|
||||
# Also compared to earlier versions of this generator, there are no longer any
|
||||
# expectations of assigns and templates rendered. These features have been
|
||||
# removed from Rails core in Rails 5, but can be added back in via the
|
||||
# `rails-controller-testing` gem.
|
||||
|
||||
RSpec.describe Transactions::SalesController, type: :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Transactions::Sale. As you add validations to Transactions::Sale, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# Transactions::SalesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "returns a success response" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "returns a success response" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
get :show, params: {id: sale.to_param}, session: valid_session
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "returns a success response" do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "returns a success response" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
get :edit, params: {id: sale.to_param}, session: valid_session
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Transactions::Sale" do
|
||||
expect {
|
||||
post :create, params: {transactions_sale: valid_attributes}, session: valid_session
|
||||
}.to change(Transactions::Sale, :count).by(1)
|
||||
end
|
||||
|
||||
it "redirects to the created transactions_sale" do
|
||||
post :create, params: {transactions_sale: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(Transactions::Sale.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "returns a success response (i.e. to display the 'new' template)" do
|
||||
post :create, params: {transactions_sale: invalid_attributes}, session: valid_session
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested transactions_sale" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
put :update, params: {id: sale.to_param, transactions_sale: new_attributes}, session: valid_session
|
||||
sale.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "redirects to the transactions_sale" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
put :update, params: {id: sale.to_param, transactions_sale: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(sale)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "returns a success response (i.e. to display the 'edit' template)" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
put :update, params: {id: sale.to_param, transactions_sale: invalid_attributes}, session: valid_session
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested transactions_sale" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, params: {id: sale.to_param}, session: valid_session
|
||||
}.to change(Transactions::Sale, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the transactions_sales list" do
|
||||
sale = Transactions::Sale.create! valid_attributes
|
||||
delete :destroy, params: {id: sale.to_param}, session: valid_session
|
||||
expect(response).to redirect_to(transactions_sales_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/transactions/sales_helper_spec.rb
Normal file
15
spec/helpers/transactions/sales_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Transactions::SalesHelper. For example:
|
||||
#
|
||||
# describe Transactions::SalesHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Transactions::SalesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/transactions/sale_spec.rb
Normal file
5
spec/models/transactions/sale_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Transactions::Sale, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
10
spec/requests/transactions/transactions_sales_spec.rb
Normal file
10
spec/requests/transactions/transactions_sales_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Transactions::Sales", type: :request do
|
||||
describe "GET /transactions_sales" do
|
||||
it "works! (now write some real specs)" do
|
||||
get transactions_sales_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
39
spec/routing/transactions/sales_routing_spec.rb
Normal file
39
spec/routing/transactions/sales_routing_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Transactions::SalesController, type: :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/transactions/sales").to route_to("transactions/sales#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/transactions/sales/new").to route_to("transactions/sales#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/transactions/sales/1").to route_to("transactions/sales#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/transactions/sales/1/edit").to route_to("transactions/sales#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/transactions/sales").to route_to("transactions/sales#create")
|
||||
end
|
||||
|
||||
it "routes to #update via PUT" do
|
||||
expect(:put => "/transactions/sales/1").to route_to("transactions/sales#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #update via PATCH" do
|
||||
expect(:patch => "/transactions/sales/1").to route_to("transactions/sales#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/transactions/sales/1").to route_to("transactions/sales#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
60
spec/views/transactions/sales/edit.html.erb_spec.rb
Normal file
60
spec/views/transactions/sales/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "transactions/sales/edit", type: :view do
|
||||
before(:each) do
|
||||
@transactions_sale = assign(:transactions_sale, Transactions::Sale.create!(
|
||||
:cashier => nil,
|
||||
:cashier_name => "MyString",
|
||||
:requested_by => "MyString",
|
||||
:receipt_no => "MyString",
|
||||
:customer => nil,
|
||||
:payment_status => "MyString",
|
||||
:sale_status => "MyString",
|
||||
:total_amount => "9.99",
|
||||
:total_discount => "9.99",
|
||||
:total_tax => "9.99",
|
||||
:tax_type => "MyString",
|
||||
:grand_total => "9.99",
|
||||
:rounding_adjustment => "9.99",
|
||||
:amount_received => "9.99",
|
||||
:amount_changed => "9.99"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit transactions_sale form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", transactions_sale_path(@transactions_sale), "post" do
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[cashier_id]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[cashier_name]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[requested_by]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[receipt_no]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[customer_id]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[payment_status]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[sale_status]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[total_amount]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[total_discount]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[total_tax]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[tax_type]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[grand_total]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[rounding_adjustment]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[amount_received]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[amount_changed]"
|
||||
end
|
||||
end
|
||||
end
|
||||
61
spec/views/transactions/sales/index.html.erb_spec.rb
Normal file
61
spec/views/transactions/sales/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,61 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "transactions/sales/index", type: :view do
|
||||
before(:each) do
|
||||
assign(:transactions_sales, [
|
||||
Transactions::Sale.create!(
|
||||
:cashier => nil,
|
||||
:cashier_name => "Cashier Name",
|
||||
:requested_by => "Requested By",
|
||||
:receipt_no => "Receipt No",
|
||||
:customer => nil,
|
||||
:payment_status => "Payment Status",
|
||||
:sale_status => "Sale Status",
|
||||
:total_amount => "9.99",
|
||||
:total_discount => "9.99",
|
||||
:total_tax => "9.99",
|
||||
:tax_type => "Tax Type",
|
||||
:grand_total => "9.99",
|
||||
:rounding_adjustment => "9.99",
|
||||
:amount_received => "9.99",
|
||||
:amount_changed => "9.99"
|
||||
),
|
||||
Transactions::Sale.create!(
|
||||
:cashier => nil,
|
||||
:cashier_name => "Cashier Name",
|
||||
:requested_by => "Requested By",
|
||||
:receipt_no => "Receipt No",
|
||||
:customer => nil,
|
||||
:payment_status => "Payment Status",
|
||||
:sale_status => "Sale Status",
|
||||
:total_amount => "9.99",
|
||||
:total_discount => "9.99",
|
||||
:total_tax => "9.99",
|
||||
:tax_type => "Tax Type",
|
||||
:grand_total => "9.99",
|
||||
:rounding_adjustment => "9.99",
|
||||
:amount_received => "9.99",
|
||||
:amount_changed => "9.99"
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of transactions/sales" do
|
||||
render
|
||||
assert_select "tr>td", :text => nil.to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Cashier Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Requested By".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Receipt No".to_s, :count => 2
|
||||
assert_select "tr>td", :text => nil.to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Payment Status".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Sale Status".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Tax Type".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
||||
end
|
||||
end
|
||||
60
spec/views/transactions/sales/new.html.erb_spec.rb
Normal file
60
spec/views/transactions/sales/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "transactions/sales/new", type: :view do
|
||||
before(:each) do
|
||||
assign(:transactions_sale, Transactions::Sale.new(
|
||||
:cashier => nil,
|
||||
:cashier_name => "MyString",
|
||||
:requested_by => "MyString",
|
||||
:receipt_no => "MyString",
|
||||
:customer => nil,
|
||||
:payment_status => "MyString",
|
||||
:sale_status => "MyString",
|
||||
:total_amount => "9.99",
|
||||
:total_discount => "9.99",
|
||||
:total_tax => "9.99",
|
||||
:tax_type => "MyString",
|
||||
:grand_total => "9.99",
|
||||
:rounding_adjustment => "9.99",
|
||||
:amount_received => "9.99",
|
||||
:amount_changed => "9.99"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new transactions_sale form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", transactions_sales_path, "post" do
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[cashier_id]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[cashier_name]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[requested_by]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[receipt_no]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[customer_id]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[payment_status]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[sale_status]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[total_amount]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[total_discount]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[total_tax]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[tax_type]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[grand_total]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[rounding_adjustment]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[amount_received]"
|
||||
|
||||
assert_select "input[name=?]", "transactions_sale[amount_changed]"
|
||||
end
|
||||
end
|
||||
end
|
||||
42
spec/views/transactions/sales/show.html.erb_spec.rb
Normal file
42
spec/views/transactions/sales/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "transactions/sales/show", type: :view do
|
||||
before(:each) do
|
||||
@transactions_sale = assign(:transactions_sale, Transactions::Sale.create!(
|
||||
:cashier => nil,
|
||||
:cashier_name => "Cashier Name",
|
||||
:requested_by => "Requested By",
|
||||
:receipt_no => "Receipt No",
|
||||
:customer => nil,
|
||||
:payment_status => "Payment Status",
|
||||
:sale_status => "Sale Status",
|
||||
:total_amount => "9.99",
|
||||
:total_discount => "9.99",
|
||||
:total_tax => "9.99",
|
||||
:tax_type => "Tax Type",
|
||||
:grand_total => "9.99",
|
||||
:rounding_adjustment => "9.99",
|
||||
:amount_received => "9.99",
|
||||
:amount_changed => "9.99"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(//)
|
||||
expect(rendered).to match(/Cashier Name/)
|
||||
expect(rendered).to match(/Requested By/)
|
||||
expect(rendered).to match(/Receipt No/)
|
||||
expect(rendered).to match(//)
|
||||
expect(rendered).to match(/Payment Status/)
|
||||
expect(rendered).to match(/Sale Status/)
|
||||
expect(rendered).to match(/9.99/)
|
||||
expect(rendered).to match(/9.99/)
|
||||
expect(rendered).to match(/9.99/)
|
||||
expect(rendered).to match(/Tax Type/)
|
||||
expect(rendered).to match(/9.99/)
|
||||
expect(rendered).to match(/9.99/)
|
||||
expect(rendered).to match(/9.99/)
|
||||
expect(rendered).to match(/9.99/)
|
||||
end
|
||||
end
|
||||
5
test/application_system_test_case.rb
Normal file
5
test/application_system_test_case.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require "test_helper"
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
||||
end
|
||||
9
test/system/sales_test.rb
Normal file
9
test/system/sales_test.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class Transactions::SalesTest < ApplicationSystemTestCase
|
||||
# test "visiting the index" do
|
||||
# visit transactions_sales_url
|
||||
#
|
||||
# assert_selector "h1", text: "Transactions::Sale"
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user