dhananjay1405 / tally-database-loader

Tally to Database Server (SQL Server / MySQL / PostgreSQL / BigQuery) data transfer utility powered by Node.JS Javascript compiler. Supports CSV, JSON & Azure Data Lake export too.
MIT License
61 stars 37 forks source link

post-import-scripts/opening-transaction.sql --- Is not relevant anymore #34

Open pharmankur opened 3 weeks ago

pharmankur commented 3 weeks ago

With database field changes applied in V 1.0.31 ; the following query has become redundant. https://github.com/dhananjay1405/tally-database-loader/blob/main/post-import-scripts/opening-transaction.sql

/ Post Import Script : Opening Transactions SQL for treating opening balance as a transaction to speed-up calculation / insert into trn_voucher(guid,date,voucher_type,is_invoice,is_accounting_voucher,is_order_voucher) values('00000000-0000-0000-0000-000000000000-00000001','1999-12-31','opening balance',0,1,0); insert into trn_accounting(guid,ledger,amount) select '00000000-0000-0000-0000-000000000000-00000001' 'guid', l.name, l.opening_balance from mst_ledger l where l.opening_balance <> 0 ;

Present fields in trn_voucher are ---> [ Fields in BOLD are missing fields from query ] guid,date,voucher_type,_vouchernumber,_referencenumber,_referencedate,narration,_partyname,_place_ofsupply,is_invoice,is_accounting_voucher,_is_inventoryvoucher,is_order_voucher

Present fields in trn_accounting are ---> [ Fields in BOLD are missing fields from query ] guid,ledger,amount,_amountforex,currency

Please update the script if to be used further and add some documentation about use of the query Also suggest, if this is really useful , make it as a standard while importing data. If the thing is not relevant anymore , discard it from code.

dhananjay1405 commented 3 weeks ago

@pharmankur good observation. Let me share the purpose behind this SQL script. To calculate Closing Balance of Ledger, one need to SUM trn_accounting[amount] column and add mst_ledger[opening_balance] to it. To simplify, I created this script which I had planned to run post import on automated basis. But later I realized this is unprofessional approach, since it increases burden of filtering rows excluding such rows for many other analytical requirements. So, I dropped this idea before even implementing it.

I have added SQL query (which can be created as View in the database), to solve this requirement. https://github.com/dhananjay1405/tally-database-loader/blob/main/reports/mssql/accounting-voucher-view.sql

So, this script and folder no longer needs to stay. Thanks for reminding me of clean-up activity which is overdue. You should see this entire folder along with script vanish away in the next code check-in.