Merge branch 'registry-772' into registry-623

# Conflicts:
#	app/models/invoice.rb
#	db/structure.sql
This commit is contained in:
Artur Beljajev 2018-03-10 16:48:47 +02:00
commit 7acd41595c
10 changed files with 29 additions and 12 deletions

View file

@ -3,7 +3,7 @@ class Directo < ActiveRecord::Base
belongs_to :item, polymorphic: true belongs_to :item, polymorphic: true
def self.send_receipts def self.send_receipts
new_trans = Invoice.where(invoice_type: "DEB", in_directo: false).where(cancelled_at: nil) new_trans = Invoice.where(in_directo: false).where(cancelled_at: nil)
total = new_trans.count total = new_trans.count
counter = 0 counter = 0
Rails.logger.info("[DIRECTO] Will try to send #{total} invoices") Rails.logger.info("[DIRECTO] Will try to send #{total} invoices")

View file

@ -27,7 +27,7 @@ class Invoice < ActiveRecord::Base
attr_accessor :billing_email attr_accessor :billing_email
validates :billing_email, email_format: { message: :invalid }, allow_blank: true validates :billing_email, email_format: { message: :invalid }, allow_blank: true
validates :invoice_type, :due_date, :currency, :seller_name, validates :due_date, :currency, :seller_name,
:seller_iban, :buyer_name, :invoice_items, :vat_rate, presence: true :seller_iban, :buyer_name, :invoice_items, :vat_rate, presence: true
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 99 }, allow_nil: true validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 99 }, allow_nil: true

View file

@ -67,7 +67,6 @@ class Registrar < ActiveRecord::Base
end end
invoices.create( invoices.create(
invoice_type: 'DEB',
due_date: (Time.zone.now.to_date + Setting.days_to_keep_invoices_active.days).end_of_day, due_date: (Time.zone.now.to_date + Setting.days_to_keep_invoices_active.days).end_of_day,
payment_term: 'prepayment', payment_term: 'prepayment',
description: description, description: description,

View file

@ -0,0 +1,5 @@
class RemoveInvoicesInvoiceType < ActiveRecord::Migration
def change
remove_column :invoices, :invoice_type, :string
end
end

View file

@ -998,7 +998,6 @@ CREATE TABLE invoices (
id integer NOT NULL, id integer NOT NULL,
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL,
invoice_type character varying NOT NULL,
due_date timestamp without time zone NOT NULL, due_date timestamp without time zone NOT NULL,
payment_term character varying, payment_term character varying,
currency character varying NOT NULL, currency character varying NOT NULL,
@ -3244,7 +3243,7 @@ ALTER TABLE ONLY settings
-- --
-- Name: unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
ALTER TABLE ONLY registrars ALTER TABLE ONLY registrars
@ -3260,7 +3259,7 @@ ALTER TABLE ONLY contacts
-- --
-- Name: unique_name; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: unique_name; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
ALTER TABLE ONLY registrars ALTER TABLE ONLY registrars
@ -3268,7 +3267,7 @@ ALTER TABLE ONLY registrars
-- --
-- Name: unique_reference_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: unique_reference_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
ALTER TABLE ONLY registrars ALTER TABLE ONLY registrars
@ -3276,7 +3275,7 @@ ALTER TABLE ONLY registrars
-- --
-- Name: unique_reg_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: unique_reg_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
ALTER TABLE ONLY registrars ALTER TABLE ONLY registrars
@ -4713,3 +4712,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180309053921');
INSERT INTO schema_migrations (version) VALUES ('20180309054510'); INSERT INTO schema_migrations (version) VALUES ('20180309054510');
INSERT INTO schema_migrations (version) VALUES ('20180310142630');

View file

@ -1613,7 +1613,6 @@
<text text-anchor="start" x="121.5" y="-1571.3" font-family="Times,serif" font-size="14.00">id :integer</text> <text text-anchor="start" x="121.5" y="-1571.3" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="121.5" y="-1556.3" font-family="Times,serif" font-size="14.00">created_at :datetime</text> <text text-anchor="start" x="121.5" y="-1556.3" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="121.5" y="-1541.3" font-family="Times,serif" font-size="14.00">updated_at :datetime</text> <text text-anchor="start" x="121.5" y="-1541.3" font-family="Times,serif" font-size="14.00">updated_at :datetime</text>
<text text-anchor="start" x="121.5" y="-1526.3" font-family="Times,serif" font-size="14.00">invoice_type :string</text>
<text text-anchor="start" x="121.5" y="-1511.3" font-family="Times,serif" font-size="14.00">due_date :datetime</text> <text text-anchor="start" x="121.5" y="-1511.3" font-family="Times,serif" font-size="14.00">due_date :datetime</text>
<text text-anchor="start" x="121.5" y="-1496.3" font-family="Times,serif" font-size="14.00">payment_term :string</text> <text text-anchor="start" x="121.5" y="-1496.3" font-family="Times,serif" font-size="14.00">payment_term :string</text>
<text text-anchor="start" x="121.5" y="-1481.3" font-family="Times,serif" font-size="14.00">currency :string</text> <text text-anchor="start" x="121.5" y="-1481.3" font-family="Times,serif" font-size="14.00">currency :string</text>

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

Before After
Before After

View file

@ -3,7 +3,6 @@ FactoryBot.define do
buyer_name 'Registrar 1' buyer_name 'Registrar 1'
currency { 'EUR' } currency { 'EUR' }
due_date { Time.zone.now.to_date + 1.day } due_date { Time.zone.now.to_date + 1.day }
invoice_type 'DEB'
seller_iban { '123' } seller_iban { '123' }
seller_name { 'EIS' } seller_name { 'EIS' }
seller_city { 'Tallinn' } seller_city { 'Tallinn' }

View file

@ -13,7 +13,6 @@ describe Invoice do
"Currency is missing", "Currency is missing",
"Due date is missing", "Due date is missing",
"Invoice items is missing", "Invoice items is missing",
"Invoice type is missing",
"Seller iban is missing", "Seller iban is missing",
"Seller name is missing", "Seller name is missing",
"Vat prc is missing" "Vat prc is missing"

View file

@ -1,7 +1,6 @@
DEFAULTS: &DEFAULTS DEFAULTS: &DEFAULTS
created_at: <%= Date.parse '2010-07-05' %> created_at: <%= Date.parse '2010-07-05' %>
due_date: <%= Date.parse '2010-07-06' %> due_date: <%= Date.parse '2010-07-06' %>
invoice_type: DEB
currency: EUR currency: EUR
seller_name: John Doe seller_name: John Doe
seller_iban: 1234 seller_iban: 1234

View file

@ -0,0 +1,16 @@
require 'test_helper'
class BalanceTopUpTest < ActionDispatch::IntegrationTest
def setup
login_as users(:api_bestnames)
end
def test_registrar_balance_top_up
visit registrar_invoices_url
click_link_or_button 'Add deposit'
fill_in 'Amount', with: 100
click_link_or_button 'Add'
assert_text 'Please pay the following invoice'
end
end