tsubaiso-sdk 1.2.9 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40d754a28fdc4ffd21ed85293497cc8ad6065430418020195f7cd6d1971945f5
4
- data.tar.gz: 6c719a60567f7666673f0b5e6ef77b11ccb4c7131606c4b126ddc48ca191e709
3
+ metadata.gz: a0ab0090c36f342bd373de2eae64dcb501dc728cf500b4bfd7ff4c2ef2483cfb
4
+ data.tar.gz: 1ae4c0635a0debc2e331f51f2a9f2369c3efd3845cddec767105d1eecb011ff2
5
5
  SHA512:
6
- metadata.gz: 30891f0818193a78ad1638fc87e760d8f0096a6e498fcc1c3cbd4ad401f49b3c9223c7c432eca1b54e286204df1272634bdb8caeae500d6040788ccef1d6cbd4
7
- data.tar.gz: f185666b820ab87c90472091789a0bb1146ebef0747b26ef40238a2bbbef0c0d23dd6fe10858bd5ed3382e74faba58ce11e82d743e655fbd27f8c3d83e57ab68
6
+ metadata.gz: f0d7ca2a29d15722668a24d183f4e7147be4758f91ce04b09e20a45ca497f690c12f38a5e659b38c75bc4165a16881c65a4157d0fc9dc7c3b639244c139cfd4e
7
+ data.tar.gz: 84be4f0d1ef8cec0f0b0d8b51c162d314965b2235b310ab6b7a2684370b1fac4380d07e5fbdc8da898db55fe64043350b3815d3f46b7a19f3a82e846a0fa0277
data/lib/tsubaiso_sdk.rb CHANGED
@@ -1650,6 +1650,19 @@ class TsubaisoSDK
1650
1650
  api_request(uri, 'GET', params)
1651
1651
  end
1652
1652
 
1653
+ # find_or_create Adjusts
1654
+ def index_adjusts(options)
1655
+ candidate_keys = [
1656
+ :term,
1657
+ :dept_code,
1658
+ :year,
1659
+ :month
1660
+ ]
1661
+ params = create_parameters(candidate_keys, options)
1662
+ uri = URI.parse(@base_url + "/adjusts")
1663
+ api_request(uri, 'GET', params)
1664
+ end
1665
+
1653
1666
  def update_boy_adjusts(options)
1654
1667
  candidate_keys = [
1655
1668
  :term,
@@ -1765,6 +1778,85 @@ class TsubaisoSDK
1765
1778
  api_request(uri, 'POST', params)
1766
1779
  end
1767
1780
 
1781
+ def list_payroll_attendances(year, month)
1782
+ params = { 'format' => 'json' }
1783
+ uri = URI.parse(@base_url + "/payroll_attendances/list/#{year.to_i}/#{month.to_i}")
1784
+ api_request(uri, 'GET', params)
1785
+ end
1786
+
1787
+ def list_timecards(year, month)
1788
+ params = { 'format' => 'json' }
1789
+ uri = URI.parse(@base_url + "/timecards/list/#{year.to_i}/#{month.to_i}")
1790
+ api_request(uri, 'GET', params)
1791
+ end
1792
+
1793
+ def create_timecard(options)
1794
+ candidate_keys = [
1795
+ :staff_id,
1796
+ :target_ymd,
1797
+ :punch_time_0,
1798
+ :punch_time_1,
1799
+ :punch_time_2,
1800
+ :punch_time_3,
1801
+ :additional_memo,
1802
+ ]
1803
+ params = create_parameters(candidate_keys, options)
1804
+ uri = URI.parse(@base_url + "/timecards/create")
1805
+ api_request(uri, 'POST', params)
1806
+ end
1807
+
1808
+ def update_timecard(options)
1809
+ candidate_keys = [
1810
+ :punch_time_0,
1811
+ :punch_time_1,
1812
+ :punch_time_2,
1813
+ :punch_time_3,
1814
+ :additional_memo,
1815
+ ]
1816
+ params = create_parameters(candidate_keys, options)
1817
+ uri = URI.parse(@base_url + "/timecards/update/#{options[:id]}")
1818
+ api_request(uri, 'POST', params)
1819
+ end
1820
+
1821
+ def list_paid_holidays
1822
+ params = { 'format' => 'json' }
1823
+ uri = URI.parse(@base_url + '/paid_holidays/list')
1824
+ api_request(uri, 'GET', params)
1825
+ end
1826
+
1827
+ def list_forms_paid_holidays(staff_id)
1828
+ params = { 'format' => 'json' }
1829
+ uri = URI.parse(@base_url + "/paid_holidays/list_forms/#{staff_id}")
1830
+ api_request(uri, 'GET', params)
1831
+ end
1832
+
1833
+ def create_paid_holiday(options)
1834
+ candidate_keys = [
1835
+ :staff_id,
1836
+ :holiday,
1837
+ :full_or_half
1838
+ ]
1839
+ params = create_parameters(candidate_keys, options)
1840
+ uri = URI.parse(@base_url + "/paid_holidays/create")
1841
+ api_request(uri, 'POST', params)
1842
+ end
1843
+
1844
+ def update_paid_holiday(holiday_id, options)
1845
+ candidate_keys = [
1846
+ :holiday,
1847
+ :full_or_half
1848
+ ]
1849
+ params = create_parameters(candidate_keys, options)
1850
+ uri = URI.parse(@base_url + "/paid_holidays/update/#{holiday_id}")
1851
+ api_request(uri, 'POST', params)
1852
+ end
1853
+
1854
+ def destroy_paid_holiday(holiday_id)
1855
+ params = { 'format' => 'json' }
1856
+ uri = URI.parse(@base_url + "/paid_holidays/destroy/#{holiday_id}")
1857
+ api_request(uri, 'POST', params)
1858
+ end
1859
+
1768
1860
  private
1769
1861
 
1770
1862
 
@@ -164,6 +164,12 @@ class StubRegister
164
164
  stub_requests(:get, url(@root_url, resource, 'list'), {'records': @created_records}, { 'start_date': '2019-12-01', 'finish_date': '2019-12-31'} )
165
165
  stub_requests(:get, url(@root_url, resource, 'list'), {'records': @created_records}, { 'price_min': 10800, 'price_max': 10800} )
166
166
  stub_requests(:get, url(@root_url, resource, 'list'), {'records': @created_records}, { 'dept_code': 'SETSURITSU' } )
167
+ when 'payroll_attendances'
168
+ stub_requests(:get, url(@root_url, resource, 'list', 2020, 1), @created_records)
169
+ when 'timecards'
170
+ stub_requests(:get, url(@root_url, resource, 'list', 2020, 1), @created_records)
171
+ when 'paid_holidays'
172
+ stub_requests(:get, url(@root_url, resource, 'list'), @created_records)
167
173
  else
168
174
  stub_requests(:get, url(@root_url, resource, 'list'), @created_records)
169
175
  end
@@ -0,0 +1,71 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class PaidHolidaysTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ @paid_holiday_1 = {
9
+ staff_id: 2011,
10
+ holiday: {
11
+ start_timestamp: Date.new(2020, 8, 5),
12
+ finish_timestamp: Date.new(2020, 8, 7),
13
+ memo: '夏期休暇',
14
+ },
15
+ full_or_half: 'half'
16
+ }
17
+
18
+ @paid_holiday_2 = {
19
+ staff_id: 2011
20
+ }
21
+
22
+ super("paid_holidays")
23
+ end
24
+
25
+ def test_list_paid_holidays
26
+ res = @api.list_paid_holidays
27
+ assert res
28
+ end
29
+
30
+ def test_list_forms_paid_holidays
31
+ path = "test/stubbings/fixtures/paid_holidays_list_forms_response.json"
32
+ res_body = JSON.load(File.read(path))
33
+
34
+ base_url = @api.instance_variable_get(:@base_url)
35
+ WebMock.stub_request(:get, "#{base_url}/paid_holidays/list_forms/2011").to_return(
36
+ body: res_body.to_json,
37
+ status: 200,
38
+ headers: { 'Content-Type' => 'application/json' }
39
+ )
40
+
41
+ res = @api.list_forms_paid_holidays(2011)
42
+ assert res
43
+ end
44
+
45
+ def test_create_paid_holiday
46
+ res = @api.create_paid_holiday(@paid_holiday_1)
47
+ assert res
48
+
49
+ res = @api.create_paid_holiday(@paid_holiday_2)
50
+ assert res
51
+ end
52
+
53
+ def test_update_paid_holiday
54
+ options = {
55
+ holiday: {
56
+ is_ok: 1,
57
+ start_timestamp: Date.new(2020, 5, 1),
58
+ finish_timestamp: Date.new(2020, 5, 2),
59
+ memo: '申請時のメモ'
60
+ },
61
+ full_or_half: 'half'
62
+ }
63
+ res = @api.update_paid_holiday(0, options)
64
+ assert res
65
+ end
66
+
67
+ def test_destroy_paid_holiday
68
+ res = @api.destroy_paid_holiday(0)
69
+ assert res
70
+ end
71
+ end
@@ -0,0 +1,18 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class PayrollAttendancesTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ super("payroll_attendances")
9
+ end
10
+
11
+ def test_list_payroll_attendances
12
+ listed_timecards = @api.list_payroll_attendances(2020, 1)
13
+ assert_equal 200, listed_timecards[:status].to_i, listed_timecards.inspect
14
+
15
+ # 戻り値が配列でないので、list_responce のスタブを作れません。
16
+ end
17
+
18
+ end
@@ -0,0 +1,69 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class TimecardsTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ @timecards_1 = {
9
+ staff_id: 2010,
10
+ target_ymd: '2020/01/15',
11
+ punch_time_0: '09:00',
12
+ punch_time_1: '12:30',
13
+ punch_time_2: '13:45',
14
+ punch_time_3: '17:20',
15
+ additional_memo: 'タイムカード1',
16
+ }
17
+
18
+ @timecards_2 = {
19
+ staff_id: 2010,
20
+ target_ymd: '2020/01/16',
21
+ punch_time_0: '09:05',
22
+ punch_time_3: '17:25',
23
+ additional_memo: 'タイムカード2',
24
+ }
25
+
26
+ super("timecards")
27
+ end
28
+
29
+ def test_create_timecard
30
+ created_timecard = @api.create_timecard(@timecards_1)
31
+
32
+ assert_equal 200, created_timecard[:status].to_i, created_timecard.inspect
33
+ assert_equal @timecards_1[:staff_id], created_timecard[:json][:staff_id]
34
+ assert_equal @timecards_1[:target_ymd], created_timecard[:json][:target_ymd]
35
+ assert_equal @timecards_1[:punch_time_0], created_timecard[:json][:punch_time_0]
36
+ assert_equal @timecards_1[:punch_time_1], created_timecard[:json][:punch_time_1]
37
+ assert_equal @timecards_1[:punch_time_2], created_timecard[:json][:punch_time_2]
38
+ assert_equal @timecards_1[:punch_time_3], created_timecard[:json][:punch_time_3]
39
+ assert_equal 'タイムカード1[22-01-21 13:30:46 (山川 太郎)', created_timecard[:json][:memo]
40
+ end
41
+
42
+ def test_list_timecards
43
+ tc1 = @api.create_timecard(@timecards_1)
44
+ tc2 = @api.create_timecard(@timecards_2)
45
+
46
+ listed_timecards = @api.list_timecards(2020, 1)
47
+ assert_equal 200, listed_timecards[:status].to_i, listed_timecards.inspect
48
+ target_timecard = listed_timecards[:json].find{ |tc| tc[:id] == tc1[:json][:id]}
49
+ assert_equal @timecards_1[:punch_time_0], target_timecard[:punch_time_0]
50
+ end
51
+
52
+ def test_update_timecard
53
+ created_timecard = @api.create_timecard(@timecards_1)
54
+ assert_equal 200, created_timecard[:status].to_i
55
+ assert_equal "0", created_timecard[:json][:id]
56
+
57
+ updating_options = {
58
+ id: created_timecard[:json][:id],
59
+ punch_time_0: "09:01",
60
+ punch_time_1: "12:31",
61
+ punch_time_2: "13:46",
62
+ punch_time_3: "17:21",
63
+ additional_memo: "修正しました。",
64
+ }
65
+
66
+ updated_timecard = @api.update_timecard(updating_options)
67
+ assert_equal 200, updated_timecard[:status].to_i
68
+ end
69
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tsubaiso-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsubaiso, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -79,6 +79,8 @@ files:
79
79
  - test/tsubaiso_sdk/test_journal.rb
80
80
  - test/tsubaiso_sdk/test_journal_distribution.rb
81
81
  - test/tsubaiso_sdk/test_manual_journal.rb
82
+ - test/tsubaiso_sdk/test_paid_holidays.rb
83
+ - test/tsubaiso_sdk/test_payroll_attendances.rb
82
84
  - test/tsubaiso_sdk/test_payrolles.rb
83
85
  - test/tsubaiso_sdk/test_petty_cash_reason_master.rb
84
86
  - test/tsubaiso_sdk/test_physical_inventory_master.rb
@@ -93,6 +95,7 @@ files:
93
95
  - test/tsubaiso_sdk/test_staff_datum_master.rb
94
96
  - test/tsubaiso_sdk/test_tag.rb
95
97
  - test/tsubaiso_sdk/test_tax_master.rb
98
+ - test/tsubaiso_sdk/test_timecards.rb
96
99
  homepage: https://github.com/tsubaiso/tsubaiso-sdk-ruby
97
100
  licenses:
98
101
  - MIT