There should be a high-level method for creating new debits, similar to Koha::Account::add_credit. It will handle creating the line, and the offset.
Created attachment 81614 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account
Uploaded a 'Work In Progress' patch.. my intention is to start building the dependent bugs and iterate on this patch as I find new requirements when building the dependant bugs.
Created attachment 81620 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account
Comment on attachment 81620 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account Review of attachment 81620 [details] [review]: ----------------------------------------------------------------- ::: Koha/Account.pm @@ +435,5 @@ > + - 'lost' > + - 'processing' > + - 'management' > + - 'sundry' > + - 'card' You are missing some types from $account_types_debit here @@ +454,5 @@ > + } > + > + my $description = $params->{description} // q{}; > + my $note = $params->{note} // q{}; > + my $user_id = $params->{user_id}; Should not user_id be taken from C4::Context->userenv when not available in params? @@ +488,5 @@ > + amount => $amount, > + description => $description, > + accounttype => $account_type, > + amountoutstanding => $amount, > + invoice_type => $invoice_type, There is no invoice_type column in accountlines @@ +498,5 @@ > + > + # Record the account offset > + my $account_offset = Koha::Account::Offset->new( > + { debit_id => $line->id, > + type => $Koha::Account::offset_type->{$type}, This will not work, values from $type are not defined in offset_type
(In reply to Josef Moravec from comment #4) > > + my $user_id = $params->{user_id}; > > Should not user_id be taken from C4::Context->userenv when not available in > params? No, that's the caller's responability.
Created attachment 81880 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account
+$debit_type can be any of: => I would not repeat that. Move the global vars at the top of the file instead, maybe should be defined with constant (see C4::Serials for an existing case).
Going to rebase this little tree against 19066 as it's close to going in.
Created attachment 82772 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit
Created attachment 82773 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account
Created attachment 82785 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit
Created attachment 82786 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account
Created attachment 83009 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit
Created attachment 83010 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account
Created attachment 83086 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit Sponsored-by: PTFS Europe
Created attachment 83087 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account Sponsored-by: PTFS Europe
Added sponsorship lines.
Created attachment 83099 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 83100 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
At first glance the logs will be different, how bad could be?
Created attachment 83228 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 83229 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 83273 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 83274 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
(In reply to Jonathan Druart from comment #20) > At first glance the logs will be different, how bad could be? You are completely right.. I've noted the differences in each of the dependant bugs.. as it happens I was going to try and catch you to discuss at some point today as my own opinion is now varying.
Created attachment 83706 [details] [review] Bug 21002: Add tests for Koha::Account::add_debit Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 83707 [details] [review] Bug 21002: Add ->add_debit method to Koha::Account Sponsored-by: PTFS Europe Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Awesome work all! Pushed to master for 19.05
Enhancement, will not be backported to 18.11.x series at this time.