diff --git a/Koha/Plugin/Acquire/Controllers/FundManagement/FundAllocations.pm b/Koha/Plugin/Acquire/Controllers/FundManagement/FundAllocations.pm index 781d4cd..9bccf9c 100644 --- a/Koha/Plugin/Acquire/Controllers/FundManagement/FundAllocations.pm +++ b/Koha/Plugin/Acquire/Controllers/FundManagement/FundAllocations.pm @@ -234,14 +234,27 @@ sub transfer { my $fund_transferring_from = Koha::Acquire::Funds::Funds->find( { fund_id => $body->{fund_id_from} } ); my $fund_transferring_to = Koha::Acquire::Funds::Funds->find( { fund_id => $body->{fund_id_to} } ); - my $note_from = "Transfer to " . $fund_transferring_to->name; + my $sub_fund_transferring_from = + Koha::Acquire::Funds::SubFunds->find( { sub_fund_id => $body->{sub_fund_id_from} } ); + my $sub_fund_transferring_to = + Koha::Acquire::Funds::SubFunds->find( { sub_fund_id => $body->{sub_fund_id_to} } ); + + my $note_from = "Transfer to " + . ( $sub_fund_transferring_to ? $sub_fund_transferring_to->name : $fund_transferring_to->name ); $note_from = $note_from . ": " . $body->{note} if $body->{note}; - my $note_to = "Transfer from " . $fund_transferring_from->name; + my $note_to = + "Transfer from " + . ( + $sub_fund_transferring_from ? $sub_fund_transferring_from->name : $fund_transferring_from->name ); $note_to = $note_to . ": " . $body->{note} if $body->{note}; + my $fund_id_from = $body->{sub_fund_id_from} ? undef : $body->{fund_id_from}; + my $fund_id_to = $body->{sub_fund_id_to} ? undef : $body->{fund_id_to}; + my $allocation_from = Koha::Acquire::Funds::FundAllocation->new( { - fund_id => $body->{fund_id_from}, + fund_id => $fund_id_from, + sub_fund_id => $body->{sub_fund_id_from}, ledger_id => $fund_transferring_from->ledger_id, fiscal_yr_id => $fund_transferring_from->fiscal_yr_id, allocation_amount => -$body->{transfer_amount}, @@ -255,7 +268,8 @@ sub transfer { )->store(); my $allocation_to = Koha::Acquire::Funds::FundAllocation->new( { - fund_id => $body->{fund_id_to}, + fund_id => $fund_id_to, + sub_fund_id => $body->{sub_fund_id_to}, ledger_id => $fund_transferring_to->ledger_id, fiscal_yr_id => $fund_transferring_to->fiscal_yr_id, allocation_amount => $body->{transfer_amount}, diff --git a/src/components/FundManagement/FundAllocationFormAdd.vue b/src/components/FundManagement/FundAllocationFormAdd.vue index 110b021..1857075 100644 --- a/src/components/FundManagement/FundAllocationFormAdd.vue +++ b/src/components/FundManagement/FundAllocationFormAdd.vue @@ -7,24 +7,25 @@

New fund allocation

+

Allocate to fund: {{ selectedFund.name }}

    -
  1. +
  2. { - this.selectedFund = fund - this.fund_allocation.fund_id = fund.fund_id - this.fund_allocation.ledger_id = fund.ledger_id - this.fund_allocation.fiscal_yr_id = fund.fiscal_yr_id - this.fund_allocation.currency = fund.currency - this.fund_allocation.owner = fund.owner - this.fund_allocation.visible_to = fund.visible_to + await client[whichClient].get(params[whichParam]).then( + result => { + this.selectedFund = result + this.fund_allocation[whichParam] = result[whichParam] + this.fund_allocation.ledger_id = result.ledger_id + this.fund_allocation.fiscal_yr_id = result.fiscal_yr_id + this.fund_allocation.currency = result.currency + this.fund_allocation.owner = result.owner + this.fund_allocation.visible_to = result.visible_to }, error => {} ) diff --git a/src/components/FundManagement/TransferFunds.vue b/src/components/FundManagement/TransferFunds.vue index 890f012..c14c3cf 100644 --- a/src/components/FundManagement/TransferFunds.vue +++ b/src/components/FundManagement/TransferFunds.vue @@ -1,39 +1,57 @@