pais_legacy 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12e0e5c2ae23c6478f7d42593a75b20897515677436053610143dba974f836b4
4
- data.tar.gz: 6ec00f494ef30e88aa66c0f92e72ffb658d46c0fa3c1719d1847fbc400f405dd
3
+ metadata.gz: 8322506aeab63d91f136772bd74a92d2f61812c5140b8d08d2579047f0752ae4
4
+ data.tar.gz: f946642a14eeaa7391479e27d7e4501bc461a498ad613e8ebadb7b78ceede8c4
5
5
  SHA512:
6
- metadata.gz: cbe84118bf32e6939f3caff7f29296e1679c5a1b6a4eefb5a1328a89e205fb70cec5afe0f9cee10626ba294e8cf21231c28c07c44b641e241acbc18c79570f2d
7
- data.tar.gz: cbc9141589838e1b65d1fc52ae1d53c2f2f57ee1b89af8dea48467609ee94ccd1a8f4b88e1583eb2cb737184ce65a5feb92a49b0ebca4544fd41de6c3d6b9c3b
6
+ metadata.gz: f60cb73e9370a79a644b5db148986fe75e47e2e9b9ab1d72f290981def78a6a89483b3f0343bef2d1264ade107a38f4a21976c03e0e2512c3f91fe3c1b7b3b6d
7
+ data.tar.gz: fb60b1f5decdfb688fc1ea01838c1dab60b2000fb161fd0af3571e79bbee9d6cc17b3f0d991ca23f3eedc30f0610afcb9741876c9b9d1772aca168437b9f1669
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaisLegacy
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.1"
5
5
  end
data/lib/pais_legacy.rb CHANGED
@@ -184,20 +184,32 @@ module PaisLegacy
184
184
  # --------------------------------------------------------------------------------
185
185
  # General Journals
186
186
  # --------------------------------------------------------------------------------
187
- def self.save_journals(ledger, data)
188
- File.open(journals_file(ledger), "w") do |f|
187
+ #
188
+ # data should be the whole params, which will include the pais_code, dr & cr amounts
189
+ #
190
+ def self.save_journals(ledger_code, data)
191
+ tranno=Pais.lasttrnno_read(ledger_code).to_i
192
+
193
+ File.open(journals_file(ledger_code), "w") do |f|
189
194
  f.write "AutoPost,LastTrnNo,Date,DR,DR_SUB,CR,CR_SUB,Description,Amount\n"
190
195
 
191
- data[:xero].each_with_index do |xero,i|
192
- # Determine if it's a credit/debit transaction
193
- if (amount = data[:dr][i].to_f) > 0
194
- dr_account,dr_sub,cr_account = accounts(data[:pais][i])
195
- else
196
- cr_account,cr_sub,dr_account = accounts(data[:pais][i])
197
- amount = data[:cr][i]
196
+ data[:dr].each_with_index do |d,i|
197
+ if data[:pais][i]
198
+
199
+ # Determine if it's a credit/debit transaction
200
+ if (amount = data[:dr][i].to_f) > 0
201
+ dr_account,dr_sub,cr_account = accounts(data[:pais][i])
202
+ else
203
+ cr_account,cr_sub,dr_account = accounts(data[:pais][i])
204
+ amount = data[:cr][i]
205
+ end
206
+
207
+ tranno += 1
208
+ date = data[:date_to].nil? ? Time.now : Date.parse(data[:date_to])
209
+ date = date.strftime("%d/%m/%Y")
210
+
211
+ f.write "GJ,#{tranno},#{date},#{dr_account},#{dr_sub},#{cr_account},#{cr_sub},#{description(data,i)},#{amount}\n"
198
212
  end
199
-
200
- f.write "GJ,#{Pais.lasttrnno_read(ledger).to_i + 1 + i},#{Time.now.strftime("%d/%m/%Y")},#{dr_account},#{dr_sub},#{cr_account},#{cr_sub},#{description(data,i)},#{amount}\n"
201
213
  end
202
214
  end
203
215
  end
@@ -285,15 +297,16 @@ module PaisLegacy
285
297
  out
286
298
  end
287
299
 
288
- def legacy_import_invoice(ledger,date,inv_no)
300
+ def legacy_import_invoice(ledger,date,inv_no,client)
289
301
 
290
302
  date = Date.parse(date).strftime("%d/%m/%Y")
291
303
 
292
- cmd=PaisLegacy::Pais.ssh + ' "bash -c \"' + PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}} {{inv_no}}\""'
304
+ cmd=PaisLegacy::Pais.ssh + ' "bash -c \"' + PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}} {{inv_no}} {{client}}\""'
293
305
  .gsub("{{ccode}}","T1")
294
306
  .gsub("{{ledger}}",ledger.to_s)
295
307
  .gsub("{{date}}",date)
296
308
  .gsub("{{inv_no}}",inv_no)
309
+ .gsub("{{client}}",client)
297
310
 
298
311
  puts cmd
299
312
  out,_,_=Open3.capture2(cmd)
@@ -403,9 +416,15 @@ module PaisLegacy
403
416
  end
404
417
 
405
418
  def self.description(data,i)
406
- xero_description=data[:xero_name][i].gsub(",","_")
407
419
  pais_account = data[:pais][i]
408
- "Auto post (Xero #{xero_description} -> #{pais_account})"
420
+
421
+ if data[:xero_name]
422
+ desc=data[:xero_name][i].gsub(",","_")
423
+ return "Auto post (Xero #{desc} -> #{pais_account})"
424
+ else
425
+ desc=data[:qb_name][i].gsub(",","_")
426
+ return "Auto post (QB #{desc} -> #{pais_account})"
427
+ end
409
428
  end
410
429
 
411
430
  def self.journals_file(ledger)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pais_legacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Pope
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-21 00:00:00.000000000 Z
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.4.10
121
+ rubygems_version: 3.4.22
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: PAIS Legacy API Wrapper