pais_legacy 2.3.0 → 2.3.2

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: 9b355300b6891c6c5ccdfbe802192224ba7171a1314696429bef0ec1b4723e94
4
- data.tar.gz: 35d5798564db5fd79fee8e17ef8e3670a2e20eaf6bbe9cbb516d42f0d680d45e
3
+ metadata.gz: 80d3bf298ea14b2a10e1c6836fe75114ca064483b4cc036d53e865de2ef2f6b7
4
+ data.tar.gz: 6c6e5b411054963d38f348dd3398ce46499dbe66ad3264d0c9404213829c89ea
5
5
  SHA512:
6
- metadata.gz: 1a188ed4744bdfbc2e757fa066bd46fccba0febc74ff673362d248ecd9c5fe0269f58de36af44afde7857a698fb31fb5e07caebfd30088a0ea95f056b8342b32
7
- data.tar.gz: b6b1347dffee8ec977261c52fe19dfbbde73e9c3beed2462950e5951b44b46f8ee3d04d304cf71b7b37fb01b00b6205976deb493e3eb2dfecffab7579d40f7b1
6
+ metadata.gz: 41d422b278734b5659d236993035d608256a7ff10b7a097304c9ce71cdde95cf764feace2755eed1d4cadc8a6c9a87b5ba1bc7343b8afba394380ec83a027146
7
+ data.tar.gz: 3b4a88414f785148322d1fae0436fb5319210c1f388e8b7256e262be96e3db4cc6d25481c174cea9572fa052e556650761b8a5cf204cfd85cf37c33e5966bd57
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaisLegacy
4
- VERSION = "2.3.0"
4
+ VERSION = "2.3.2"
5
5
  end
data/lib/pais_legacy.rb CHANGED
@@ -15,7 +15,8 @@ module PaisLegacy
15
15
  SERVER="192.168.200.4"
16
16
  SUSPENSE_ACCOUNT=1599
17
17
  CLEARING_ACCOUNT=5199
18
-
18
+ TB_DIRECT_ACCOUNT=8999
19
+
19
20
  # --------------------------------------------------------------------------------
20
21
  # Client
21
22
  # --------------------------------------------------------------------------------
@@ -184,20 +185,32 @@ module PaisLegacy
184
185
  # --------------------------------------------------------------------------------
185
186
  # General Journals
186
187
  # --------------------------------------------------------------------------------
187
- def self.save_journals(ledger, data)
188
- File.open(journals_file(ledger), "w") do |f|
188
+ #
189
+ # data should be the whole params, which will include the pais_code, dr & cr amounts
190
+ #
191
+ def self.save_journals(ledger_code, data)
192
+ tranno=Pais.lasttrnno_read(ledger_code).to_i
193
+
194
+ File.open(journals_file(ledger_code), "w") do |f|
189
195
  f.write "AutoPost,LastTrnNo,Date,DR,DR_SUB,CR,CR_SUB,Description,Amount\n"
190
196
 
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]
197
+ data[:dr].each_with_index do |d,i|
198
+ if data[:pais][i]
199
+
200
+ # Determine if it's a credit/debit transaction
201
+ if (amount = data[:dr][i].to_f) > 0
202
+ dr_account,dr_sub,cr_account = accounts(data[:pais][i])
203
+ else
204
+ cr_account,cr_sub,dr_account = accounts(data[:pais][i])
205
+ amount = data[:cr][i]
206
+ end
207
+
208
+ tranno += 1
209
+ date = data[:date_to].nil? ? Time.now : Date.parse(data[:date_to])
210
+ date = date.strftime("%d/%m/%Y")
211
+
212
+ f.write "GJ,#{tranno},#{date},#{dr_account},#{dr_sub},#{cr_account},#{cr_sub},#{description(data,i)},#{amount}\n"
198
213
  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
214
  end
202
215
  end
203
216
  end
@@ -394,7 +407,7 @@ module PaisLegacy
394
407
  private
395
408
  def self.accounts(account)
396
409
  account = account.split("/")
397
- acc = account[0] ? account[0] : SUSPENSE_ACCOUNT
410
+ acc = account[0] ? account[0] : TB_DIRECT_ACCOUNT
398
411
  sub=account[1] if account.count > 1
399
412
  return acc,sub,CLEARING_ACCOUNT
400
413
  end
@@ -404,9 +417,15 @@ module PaisLegacy
404
417
  end
405
418
 
406
419
  def self.description(data,i)
407
- xero_description=data[:xero_name][i].gsub(",","_")
408
420
  pais_account = data[:pais][i]
409
- "Auto post (Xero #{xero_description} -> #{pais_account})"
421
+
422
+ if data[:xero_name]
423
+ desc=data[:xero_name][i].gsub(",","_")
424
+ return "Auto post (Xero #{desc} -> #{pais_account})"
425
+ else
426
+ desc=data[:qb_name][i].gsub(",","_")
427
+ return "Auto post (QB #{desc} -> #{pais_account})"
428
+ end
410
429
  end
411
430
 
412
431
  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.3.0
4
+ version: 2.3.2
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-12-05 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