text
stringlengths
0
15.7k
source
stringlengths
6
112
set _colFirst to first column index of first column of theRange
addColumnsByColor.applescript
set _colLast to first column index of last column of theRange
addColumnsByColor.applescript
return range ¬
addColumnsByColor.applescript
((get address of row rowNumber of column _colFirst) & ":" & ¬
addColumnsByColor.applescript
(get address of row rowNumber of column _colLast))
addColumnsByColor.applescript
end getRowRange
addColumnsByColor.applescript
on getCellColorIndex(theRange)
addColumnsByColor.applescript
if class of selection is range then
addColumnsByColor.applescript
set _range to theRange
addColumnsByColor.applescript
set _range to theRange as range
addColumnsByColor.applescript
set _cellCount to count of cells of _range
addColumnsByColor.applescript
repeat with i from 1 to _cellCount
addColumnsByColor.applescript
set _colorIndex to color index of interior object of cell i of _range
addColumnsByColor.applescript
set end of _result to _colorIndex
addColumnsByColor.applescript
end getCellColorIndex
addColumnsByColor.applescript
on getListPosition(theList, theItem)
addColumnsByColor.applescript
if item i of theList is theItem then return i
addColumnsByColor.applescript
end getListPosition
addColumnsByColor.applescript
on getMaxColumnIndex(recordList)
addColumnsByColor.applescript
set _indexMax to 0
addColumnsByColor.applescript
repeat with i from 1 to length of recordList
addColumnsByColor.applescript
set _indexCur to columnIndex of item i of recordList
addColumnsByColor.applescript
if (_indexCur as integer) is greater than (_indexMax as integer) then
addColumnsByColor.applescript
set _indexMax to _indexCur as integer
addColumnsByColor.applescript
return _indexMax
addColumnsByColor.applescript
end getMaxColumnIndex
addColumnsByColor.applescript
global exportFileName, startRowIndex, startColumnIndex, isSortDescending, isCloseExcel, cellThresholdValue, cellThresholdColor
moneymoney-sum-by-bank.scpt
set exportFileName to missing value
moneymoney-sum-by-bank.scpt
set startRowIndex to 1
moneymoney-sum-by-bank.scpt
set startColumnIndex to 1
moneymoney-sum-by-bank.scpt
set isSortDescending to true
moneymoney-sum-by-bank.scpt
set isCloseExcel to false
moneymoney-sum-by-bank.scpt
set cellThresholdValue to 100000
moneymoney-sum-by-bank.scpt
set cellThresholdColor to {255, 244, 233}
moneymoney-sum-by-bank.scpt
global tmpDir
moneymoney-sum-by-bank.scpt
set tmpDir to (path to library folder from user domain as text) & "Caches:"
moneymoney-sum-by-bank.scpt
on ExportAccounts()
moneymoney-sum-by-bank.scpt
tell application "MoneyMoney"
moneymoney-sum-by-bank.scpt
set accounts to export accounts
moneymoney-sum-by-bank.scpt
set UUID to do shell script "uuidgen"
moneymoney-sum-by-bank.scpt
set accountsPropertyListFile to (tmpDir & UUID & ".plist")
moneymoney-sum-by-bank.scpt
set accountsPropertyListFilePosix to POSIX path of accountsPropertyListFile
moneymoney-sum-by-bank.scpt
open for access file the accountsPropertyListFile with write permission
moneymoney-sum-by-bank.scpt
write (accounts) to file the accountsPropertyListFile as «class utf8»
moneymoney-sum-by-bank.scpt
close access file the accountsPropertyListFile
moneymoney-sum-by-bank.scpt
log "Accounts file has been generated to " & accountsPropertyListFilePosix
moneymoney-sum-by-bank.scpt
return accountsPropertyListFilePosix
moneymoney-sum-by-bank.scpt
end ExportAccounts
moneymoney-sum-by-bank.scpt
on DeleteFile(fileName)
moneymoney-sum-by-bank.scpt
log "INFO: removing temporary file " & fileName
moneymoney-sum-by-bank.scpt
do shell script "test -f " & fileName as POSIX file
moneymoney-sum-by-bank.scpt
tell application "System Events" to delete alias fileName
moneymoney-sum-by-bank.scpt
on IncreaseBankBalance(bankIdentifier, balance, balancePerBankList)
moneymoney-sum-by-bank.scpt
log "INFO: Increase bank balance of " & bankIdentifier & " by " & balance
moneymoney-sum-by-bank.scpt
repeat with a from 1 to the count of balancePerBankList
moneymoney-sum-by-bank.scpt
if bankIdentifier of item a of balancePerBankList is bankIdentifier then
moneymoney-sum-by-bank.scpt
set newBalance to (balance of item a of balancePerBankList) + balance
moneymoney-sum-by-bank.scpt
log "DEBUG: Found existing balance. Set new balance to " & newBalance
moneymoney-sum-by-bank.scpt
set item a of balancePerBankList to {bankIdentifier:bankIdentifier, balance:newBalance}
moneymoney-sum-by-bank.scpt
return balancePerBankList
moneymoney-sum-by-bank.scpt
set the end of balancePerBankList to {bankIdentifier:bankIdentifier, balance:balance}
moneymoney-sum-by-bank.scpt
end IncreaseBankBalance
moneymoney-sum-by-bank.scpt
on SumBankBalancesFromPlist(accountsPropertyListFile)
moneymoney-sum-by-bank.scpt
set balancePerBankList to {}
moneymoney-sum-by-bank.scpt
tell property list file accountsPropertyListFile
moneymoney-sum-by-bank.scpt
repeat with i from 1 to number of property list items
moneymoney-sum-by-bank.scpt
set accountName to value of property list item "name" of property list item i
moneymoney-sum-by-bank.scpt
set isGroup to value of property list item "group" of property list item i
moneymoney-sum-by-bank.scpt
if isGroup is false then
moneymoney-sum-by-bank.scpt
set bankIdentifier to value of property list item "bankIdentifier" of property list item "attributes" of property list item i
moneymoney-sum-by-bank.scpt
log "WARNING: " & errStr & ". MoneyMoney Attribute 'bankIdentifier' not set for account " & accountName
moneymoney-sum-by-bank.scpt
set bankIdentifier to "Sonstige"
moneymoney-sum-by-bank.scpt
set balances to value of property list item "balance" of property list item i
moneymoney-sum-by-bank.scpt
repeat with balance in balances
moneymoney-sum-by-bank.scpt
my IncreaseBankBalance(bankIdentifier, get first item of balance, balancePerBankList)
moneymoney-sum-by-bank.scpt
if balancePerBankList is {} then
moneymoney-sum-by-bank.scpt
error "Temporary property list file " & accountsPropertyListFile & " could not be read or no MoneyMoney accounts with attribute 'bankIdentifier' exists."
moneymoney-sum-by-bank.scpt
end SumBankBalancesFromPlist
moneymoney-sum-by-bank.scpt
on OpenExcelWithData(bankBalances)
moneymoney-sum-by-bank.scpt
if (exportFileName is missing value) then
moneymoney-sum-by-bank.scpt
open exportFileName
moneymoney-sum-by-bank.scpt
set x to startRowIndex
moneymoney-sum-by-bank.scpt
repeat with balanceData in bankBalances
moneymoney-sum-by-bank.scpt
set balance to balance of balanceData
moneymoney-sum-by-bank.scpt
set bank to bankIdentifier of balanceData
moneymoney-sum-by-bank.scpt
set value of cell x of column startColumnIndex to balance
moneymoney-sum-by-bank.scpt
set value of cell x of column (startColumnIndex + 1) to bank
moneymoney-sum-by-bank.scpt
if (balance > cellThresholdValue) then
moneymoney-sum-by-bank.scpt
set color of interior object of cell x of column startColumnIndex to cellThresholdColor
moneymoney-sum-by-bank.scpt
set number format of column startColumnIndex to "#,##0.00 €"
moneymoney-sum-by-bank.scpt
if (isSortDescending is true) then
moneymoney-sum-by-bank.scpt
set sortingRange to "" & startRowIndex & ":" & x
moneymoney-sum-by-bank.scpt
sort range sortingRange key1 cell 1 of column startColumnIndex order1 sort descending
moneymoney-sum-by-bank.scpt
if (exportFileName is not missing value) then
moneymoney-sum-by-bank.scpt
save yes
moneymoney-sum-by-bank.scpt
if (isCloseExcel is true) then
moneymoney-sum-by-bank.scpt
close active workbook
moneymoney-sum-by-bank.scpt
end OpenExcelWithData
moneymoney-sum-by-bank.scpt
set accountsPropertyListFile to ExportAccounts()
moneymoney-sum-by-bank.scpt
set bankBalances to SumBankBalancesFromPlist(accountsPropertyListFile)
moneymoney-sum-by-bank.scpt