Compare commits

..

2 Commits

Author SHA1 Message Date
71153490eb container: hledger-flow: coinbase: refactor native/network calc columns 2026-04-01 12:59:04 -07:00
59ec5a9010 container: hledger-flow: coinbase: add on-chain native tx amount column
for calculating native (fiat) amount without fee. Can be used with
custom tax rules to calculate native amount of any on-chain spends.
2026-04-01 12:57:33 -07:00
2 changed files with 29 additions and 6 deletions

View File

@@ -176,15 +176,37 @@ function __parse()
# managed within the rules file.
#
if ($7 > 0 && $5 > 0) {printf("%.8f", $7 / $5)}; printf OFS # native_amount_price
if ($7 > 0 && $5 > 0) {printf("%.8f", ($7 / $5) * $16)}; printf OFS # native_network_transaction_fee_amount
if ($7 > 0 && $5 > 0)
{
native_amount_price = $7 / $5
printf("%.8f", native_amount_price); printf OFS
native_network_transaction_fee_amount = native_amount_price * $16
printf("%.8f", native_network_transaction_fee_amount); printf OFS
}
else
{
printf OFS # native_amount_price
printf OFS # native_network_transaction_fee_amount
}
#
# Add new column to calculate the difference between amount and network fee,
# i.e., amount_amount - network_transaction_fee_amount
# Add new columns to calculate the difference between amount and network fee
#
if ($16 > 0) {printf("%.8f", $5 - $16)}; printf OFS # network_transaction_amount_amount
if ($16 > 0)
{
network_transaction_amount_amount = $5 - $16
printf("%.8f", network_transaction_amount_amount); printf OFS
native_network_transaction_amount = network_transaction_amount_amount * native_amount_price
printf("%.8f", native_network_transaction_amount); printf OFS
}
else
{
printf OFS # network_transaction_amount_amount
printf OFS # native_network_transaction_amount
}
#
# Advanced Trade: add new column for calculating real value amount

View File

@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
fields account_id,coinbase_id,type,status_,amount_amount,amount_currency,native_amount_amount,native_amount_currency,created_at,resource,resource_path,description,network_status,network_network_name,network_hash,network_transaction_fee_amount,network_transaction_fee_currency,to_resource,to_address,to_email,from_resource,from_resource_path,from_id,from_name,cancelable,idem,buy_total_amount,buy_total_currency,buy_subtotal_amount,buy_subtotal_currency,buy_fee_amount,buy_fee_currency,buy_id,buy_payment_method_name,sell_total_amount,sell_total_currency,sell_subtotal_amount,sell_subtotal_currency,sell_fee_amount,sell_fee_currency,sell_id,sell_payment_method_name,trade_fee_amount,trade_fee_currency,trade_id,trade_payment_method_name,advanced_trade_fill_fill_price,advanced_trade_fill_product_id,advanced_trade_fill_order_id,advanced_trade_fill_commission,advanced_trade_fill_order_side,native_amount_price,native_network_transaction_fee_amount,network_transaction_amount_amount,advanced_trade_fill_real_value_amount,advanced_trade_fill_pair_lhs,advanced_trade_fill_pair_rhs,advanced_trade_fill_cost_basis_amount,taxed_at,direction,subaccount
fields account_id,coinbase_id,type,status_,amount_amount,amount_currency,native_amount_amount,native_amount_currency,created_at,resource,resource_path,description,network_status,network_network_name,network_hash,network_transaction_fee_amount,network_transaction_fee_currency,to_resource,to_address,to_email,from_resource,from_resource_path,from_id,from_name,cancelable,idem,buy_total_amount,buy_total_currency,buy_subtotal_amount,buy_subtotal_currency,buy_fee_amount,buy_fee_currency,buy_id,buy_payment_method_name,sell_total_amount,sell_total_currency,sell_subtotal_amount,sell_subtotal_currency,sell_fee_amount,sell_fee_currency,sell_id,sell_payment_method_name,trade_fee_amount,trade_fee_currency,trade_id,trade_payment_method_name,advanced_trade_fill_fill_price,advanced_trade_fill_product_id,advanced_trade_fill_order_id,advanced_trade_fill_commission,advanced_trade_fill_order_side,native_amount_price,native_network_transaction_fee_amount,network_transaction_amount_amount,native_network_transaction_amount,advanced_trade_fill_real_value_amount,advanced_trade_fill_pair_lhs,advanced_trade_fill_pair_rhs,advanced_trade_fill_cost_basis_amount,taxed_at,direction,subaccount
# The above fields; in order and in human-readable form:
#
@@ -73,6 +73,7 @@ fields account_id,coinbase_id,type,status_,amount_amount,amount_currency,native_
# native_amount_price
# native_network_transaction_fee_amount
# network_transaction_amount_amount
# native_network_transaction_amount
# advanced_trade_fill_real_value_amount
# advanced_trade_fill_pair_lhs
# advanced_trade_fill_pair_rhs