unipump 0.2.0 → 0.3.0

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: 47b3ded4adb8542b7c97b5163ad60d83b2415ded901121e205451977d2269fcf
4
- data.tar.gz: 62853432f82b5cd7a64ec0ad16fb24efe8e71a2ab59e7aab7e0971dff6f09065
3
+ metadata.gz: 70ddfc228cd9746dacb4d8d00a4f7cc66a3e2c6880e62a5dc2a4ed9b8aef4b26
4
+ data.tar.gz: 52e3a1838db7e54a52fb62b27439ef210943fce3d7a18b3615e48a405fb5a9fb
5
5
  SHA512:
6
- metadata.gz: 00c5a85ec55dfb5e29fd2a01d7255a2fd08b421686bb2d23f5aa1f8c7ca3a455061f23e7940d9b0efc170ca337fcd02a3048f7cea526e98e2a6e690d39e8095a
7
- data.tar.gz: 3d2350a002c0e4f4b569ee7fb39868d036cd896e04954143b9a774d766af48c36b398deb69c738efd4136745931a9865b107a97bd23648045a0d0d6c16706b0a
6
+ metadata.gz: 35a18fdafddafdeb0ca76c5dedd89162c7934a9df88e62dfc0d0e655179184291bce1d326e9d79267d7f249c279dc117811bb11d436b7c2b0f1686f0ace1064d
7
+ data.tar.gz: '0907dbe7141953a1f694f035965d76d4a7509f40cccb6204ca4fa18aea5438b85b5f1a6b7014b07ff301caacd37931494a3e15dfc76d54010b6dd46b34d0e0a3'
data/exe/unipump CHANGED
@@ -16,7 +16,7 @@ SPEC = %(
16
16
  absent
17
17
 
18
18
  -e,environment=ENV
19
- Set the run-time environment to 'production' or 'test'. In the test
19
+ Set the run-time environment to 'prod' or 'test'. In the test
20
20
  environment, data will be uploaded to the Uniconta test system and
21
21
  TIMEREG_TEST is updated in the database instead of the TIMEREG table. The
22
22
  default is 'test'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UniPump
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/unipump.rb CHANGED
@@ -37,7 +37,7 @@ class Pump
37
37
 
38
38
  # Environment-dependent constants
39
39
  TEST_SYSTEM = "81470" # Uniconta test system ID
40
- PROD_SYSTEM = nil
40
+ PROD_SYSTEM = "86837"
41
41
  TEST_TIMEREG_TABLE = "tidsreg_test"
42
42
  PROD_TIMEREG_TABLE = "tidsreg"
43
43
  TEST_FAKTURALINIE_VIEW = "v_fakturalinie_test"
@@ -66,9 +66,9 @@ class Pump
66
66
  def tidsreg_table = (environment == "prod" ? PROD_TIMEREG_TABLE : TEST_TIMEREG_TABLE)
67
67
  def fakturalinie_view = (environment == "prod" ? PROD_FAKTURALINIE_VIEW : TEST_FAKTURALINIE_VIEW)
68
68
  def root_url = "https://odata.uniconta.com/api/Entities/#{system}"
69
- def order_list_url = "#{root_url}/DebtorOrderClient"
70
- def insert_order_list_url = "#{root_url}/InsertList/DebtorOrderClient"
71
- def insert_order_line_list_url = "#{root_url}/InsertList/DebtorOrderLineClient"
69
+ def order_list_url = "#{root_url}/DebtorOrderClientUser"
70
+ def insert_order_list_url = "#{root_url}/InsertList/DebtorOrderClientUser"
71
+ def insert_order_line_list_url = "#{root_url}/InsertList/DebtorOrderLineClientUser"
72
72
 
73
73
  def initialize(
74
74
  username, password, environment,
@@ -177,14 +177,13 @@ class Pump
177
177
  # that we may recover from a database failure after the order lines
178
178
  # have been uploaded
179
179
  tidsreg_keys = conn.records %(
180
- select
180
+ select distinct
181
181
  meid,
182
182
  said,
183
183
  acid,
184
184
  dato
185
185
  from #{fakturalinie_view}
186
186
  where #{line_constraint}
187
- order by sagsnummer
188
187
  )
189
188
 
190
189
  # Save tidsreg keys to disk
@@ -213,7 +212,7 @@ class Pump
213
212
  emit " #{order.ordrenummer} (#{order.sagsnummer}) #{order_lines.size} items"
214
213
 
215
214
  # Create json object for HTTP
216
- json = format_order_line(order, order_lines)
215
+ json = format_order_line(order, order_lines, end_date)
217
216
 
218
217
  # Transfer JSON document. Note that HTTP redirects are not supported
219
218
  # (yet)
@@ -264,7 +263,6 @@ private
264
263
  end
265
264
 
266
265
  def upload_json(url, json) # ChatGPT
267
- return
268
266
  # Write to json log
269
267
  File.open(jlog, "a") { |f| f.puts json } if jlog
270
268
 
@@ -374,10 +372,11 @@ private
374
372
  " }" + curr_comma
375
373
  end
376
374
 
377
- def format_blank_line(out, ordrenummer)
375
+ def format_blank_line(out, ordrenummer, end_date)
378
376
  format_fields(
379
377
  out,
380
378
  "OrderNumber" => ordrenummer,
379
+ "PumpDate" => "#{end_date}T12:00:00",
381
380
  "Text" => ""
382
381
  )
383
382
  end
@@ -397,7 +396,7 @@ private
397
396
  out.string
398
397
  end
399
398
 
400
- def format_order_line(order, order_lines)
399
+ def format_order_line(order, order_lines, end_date)
401
400
  @curr_comma = ","
402
401
  out = StringIO.new
403
402
  out.puts "["
@@ -405,31 +404,30 @@ private
405
404
  prev_rolle = nil
406
405
  prev_maaned = nil
407
406
  for order_line in order_lines
407
+ # header
408
408
  if prev_rolle != order_line.rolle || prev_maaned != order_line.maaned
409
- format_blank_line(out, order_line.ordrenummer.to_i) if !prev_rolle.nil? && !prev_maaned.nil?
409
+ format_blank_line(out, order_line.ordrenummer.to_i, end_date) if !prev_rolle.nil? && !prev_maaned.nil?
410
410
  format_fields(out,
411
411
  "OrderNumber" => order_line.ordrenummer.to_i,
412
+ "PumpDate" => "#{end_date}T12:00:00",
412
413
  "Text" => order_line.rolle)
413
414
  prev_rolle = order_line.rolle
414
415
  prev_maaned = order_line.maaned
415
416
  end
417
+ # body
416
418
  format_fields(out,
417
419
  "OrderNumber" => order_line.ordrenummer.to_i,
420
+ "PumpDate" => "#{end_date}T12:00:00",
418
421
  "Text" => " #{order_line.tekst}",
419
422
  "Item" => order_line.ydelse,
420
423
  "Qty" => order_line.antal,
421
424
  "Price" => order_line.pris)
422
425
  end
423
426
  @curr_comma = ""
424
- format_blank_line(out, order_line.ordrenummer.to_i)
427
+ format_blank_line(out, order_line.ordrenummer.to_i, end_date)
425
428
  }
426
429
  out.puts "]"
427
430
  out.string
428
431
  end
429
432
  end
430
433
 
431
-
432
-
433
-
434
-
435
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unipump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-21 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tiny_tds