From 7f4536c715a2165874a3ef3ae70a2d5baeff2a0f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 24 Oct 2022 17:53:46 -0300 Subject: [PATCH] Bug 24381: Update db_rev to new style Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_24381.perl | 322 ----------------- .../data/mysql/atomicupdate/bug_24381.pl | 327 ++++++++++++++++++ 2 files changed, 327 insertions(+), 322 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_24381.perl create mode 100755 installer/data/mysql/atomicupdate/bug_24381.pl diff --git a/installer/data/mysql/atomicupdate/bug_24381.perl b/installer/data/mysql/atomicupdate/bug_24381.perl deleted file mode 100644 index 62b07ed757..0000000000 --- a/installer/data/mysql/atomicupdate/bug_24381.perl +++ /dev/null @@ -1,322 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if ( CheckVersion($DBversion) ) { - - # ACCOUNT_CREDIT - my $account_credit = q{ - [%- USE AuthorisedValues -%] - [%- USE KohaDates -%] - [%- USE Price -%] - [%- PROCESS "accounts.inc" -%] - - [% IF ( LibraryName ) %] - - - - [% END %] - [% IF credit.library %] - - - - [% END %] - - - - - - - - - - - - [% IF credit.payment_type %] - - - - - [% END %] - - - - [% IF ( credit.credit_type_code == 'PAYMENT' ) %] - - - - [% ELSIF ( credit.credit_type_code == 'CREDIT' ) %] - - - - [% ELSIF ( credit.credit_type_code == 'WRITEOFF' ) %] - - - - [% END %] - [% IF credit.amountoutstanding + 0 != 0 %] - - - - - - - - - - - - - [% END %] - [% IF credit.amount != credit.amountoutstanding %] - - - - - [% FOREACH offset IN credit.credit_offsets %] - - - - - [% END %] - [% END %] - - - - - - [% IF change.defined %] - - - - - [% END %] - - - - - - - - -
-

[% LibraryName | html %]

-
-

[% credit.library.branchname | html %]

-
-

[% today | $KohaDates %]

-
Transaction ID: [% credit.accountlines_id %]
Operator ID: [% credit.manager_id %]
Payment type: [% AuthorisedValues.GetByCode('PAYMENT_TYPE', credit.payment_type) %]
-

[%- PROCESS credit_type_description credit_type = credit.credit_type -%] receipt

-
- Received with thanks from [% credit.patron.firstname | html %] [% credit.patron.surname | html %]
- Card number: [% credit.patron.cardnumber | html %]
-
- Credit added to account for [% credit.patron.firstname | html %] [% credit.patron.surname | html %]
- Card number: [% credit.patron.cardnumber | html %]
-
- Writeoff added to account for [% credit.patron.firstname | html %] [% credit.patron.surname | html %]
- Card number: [% credit.patron.cardnumber | html %]
-
Description of creditAmount
[%- PROCESS credit_type_description credit_type = credit.credit_type -%][% credit.amount * -1 | $Price %]
Total available:[% credit.amountoutstanding * -1 | $Price %]
Description of chargesAmount
[% PROCESS account_type_description account=offset.debit %][% IF ( offset.debit.itemnumber ) %] - [% offset.debit.item.biblio.title %][% END %][% offset.amount * -1 | $Price %]
Total:[% credit.amount * -1 | $Price %]
Change given: [% change | $Price %]
Account balance as on date:[% credit.patron.account.balance * -1 | $Price %]
- }; - - my $account_credit_old = q{[%IF(LibraryName)%]

[%LibraryName|html%]

[%END%]

Feereceipt

[%Branches.GetName(patron.branchcode)|html%]

Receivedwiththanksfrom[%patron.firstname|html%][%patron.surname|html%]
Cardnumber:[%patron.cardnumber|html%]
[%FOREACHaccountINaccounts%][%IF(account.amountcredit)%][%ELSE%][%END%][%account.amount|$Price%][%END%]Totaloutstandingduesasondate:[%IF(totalcredit)%][%ELSE%][%END%][%total|$Price%]
DateDescriptionofchargesNoteAmount
[%account.date|$KohaDates%][%PROCESSaccount_type_descriptionaccount=account%][%-IFaccount.description%],[%account.description|html%][%END%][%account.note|html%]
}; - - my $sth = $dbh->prepare( -q{UPDATE letter SET content = ? WHERE code = 'ACCOUNT_CREDIT' AND REPLACE(REPLACE(content, ' ', ''), '\n','') = ?} - ); - $sth->execute( $account_credit, $account_credit_old ); - - # replace patron variable with credit.patron - $dbh->do("UPDATE letter SET content = REPLACE(content, '[% patron', '[% credit.patron') WHERE code = 'ACCOUNT_CREDIT' "); - # replace library variable with credit.library.branchname - $dbh->do("UPDATE letter SET content = REPLACE(content, '[% library', '[% credit.library.branchname') WHERE code = 'ACCOUNT_CREDIT' "); - # replace offsets variable with credit.offsets - $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' credit.offsets %]') WHERE code = 'ACCOUNT_CREDIT' "); - # replace change_given variable with change - $dbh->do("UPDATE letter SET content = REPLACE(content, '[% change_given', '[% change') WHERE code = 'ACCOUNT_CREDIT' "); - - # ACCOUNT_DEBIT - my $account_debit = q{ - [% PROCESS "accounts.inc" %] - [%- USE Price -%] - [%- USE KohaDates -%] - - [% IF ( LibraryName ) %] - - - - [% END %] - [% IF debit.library %] - - - - [% END %] - - - - - [% IF credit.manager_id %] - - - - - [% END %] - - - - - - - [% IF debit.amountoutstanding != 0 %] - - - - - - - - - - - - - - - [% END %] - [% IF debit.amount != debit.amountoutstanding %] - - - - - - [% FOREACH offset IN debit.debit_offsets %] - - - - - - [% END %] - - - - - [% END %] - - - - - - - - - -
-

[% LibraryName | html %]

-
-

[% debit.library.branchname | html %]

-
Fee ID: [% debit.accountlines_id %]
Operator ID: [% credit.manager_id %]
-

Invoice

-
- Bill to: [% debit.patron.firstname | html %] [% debit.patron.surname | html %]
- Card number: [% debit.patron.cardnumber | html %]
-
DateDescription of chargesAmount
[% debit.date | $KohaDates %][% PROCESS account_type_description account=debit %][% debit.amount | $Price %]
Total owed:[% debit.amount | $Price %]
DateDescription of paymentsAmount
[% offset.credit.date | $KohaDates %][% PROCESS account_type_description account=offset.credit %][% offset.amount * -1 | $Price %]
Total paid:[% debit.amount - debit.amountoutstanding | $Price %]
Total outstanding:[% debit.amountoutstanding | $Price %]
- }; - - my $account_debit_old = q{[%IF(LibraryName)%]

[%LibraryName|html%]

[%END%]

INVOICE

[%Branches.GetName(patron.branchcode)|html%]

Billto:[%patron.firstname|html%][%patron.surname|html%]
Cardnumber:[%patron.cardnumber|html%]
AmountAmountoutstanding[%FOREACHaccountINaccounts%][%IF(account.amountcredit)%][%ELSE%][%END%][%account.amount|$Price%][%IF(account.amountoutstandingcredit)%][%ELSE%][%END%][%account.amountoutstanding|$Price%][%END%]Totaloutstandingduesasondate:[%IF(totalcredit)%][%ELSE%][%END%][%total|$Price%]
DateDescriptionofchargesNote
[%account.date|$KohaDates%][%PROCESSaccount_type_descriptionaccount=account%][%-IFaccount.description%],[%account.description|html%][%END%][%account.note|html%]
}; - - $sth = $dbh->prepare( -q{UPDATE letter SET content = ? WHERE code = 'ACCOUNT_DEBIT' AND REPLACE(REPLACE(content, ' ', ''), '\n','') = ?} - ); - $sth->execute($account_debit, $account_debit_old); - - # replace patron variable with debit.patron - $dbh->do("UPDATE letter SET content = REPLACE(content, '[% patron', '[% debit.patron') WHERE code = 'ACCOUNT_DEBIT' "); - # replace library variable with debit.library.branchname - $dbh->do("UPDATE letter SET content = REPLACE(content, '[% library', '[% debit.library.branchname') WHERE code = 'ACCOUNT_DEBIT' "); - # replace offsets variable with debit.offsets - $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' debit.offsets %]') WHERE code = 'ACCOUNT_DEBIT' "); - # replace total variable with debit.patron.account.balance - $dbh->do("UPDATE letter SET content = REPLACE(content, '[% total ', '[% debit.patron.account.balance ') WHERE code = 'ACCOUNT_DEBIT' "); - # replace totalcredit variable with debit.patron.account.balance <= 0 - $dbh->do("UPDATE letter SET content = REPLACE(content, 'totalcredit', 'debit.patron.account.balance <= 0') WHERE code = 'ACCOUNT_DEBIT' "); - - # RECEIPT - my $receipt = q{ - [% PROCESS "accounts.inc" %] - [%- USE KohaDates -%] - [%- USE Price -%] - - [% IF ( LibraryName ) %] - - - - [% END %] - [% IF credit.library %] - - - - [% END %] - - - - - - - - - - - - - - - - - - - - - - - [% FOREACH offset IN payment.credit_offsets %] - - - - - [% END %] - - - - - - - - - - - - - - -
-

[% LibraryName | html %]

-
-

[% payment.library.branchname ) | html %]

-
-

[% payment.date | $KohaDates %]

-
Transaction ID: [% payment.accountlines_id %]
Operator ID: [% payment.manager_id %]
Payment type: [% payment.payment_type %]
-

Payment receipt

-
Description of chargesAmount
[% PROCESS account_type_description account=offset.debit %][% offset.amount * -1 | $Price %]
Total:[% payment.amount * -1 | $Price %]
Tendered: [% tendered | $Price %]
Change given:[% change | $Price %]
- }; - - my $receipt_old = q{[%PROCESS"accounts.inc"%][%IF(LibraryName)%]

[%LibraryName|html%]

[%END%]

[%Branches.GetName(payment.branchcode)|html%]

[%payment.date|$KohaDates%]

Feereceipt

[%FOREACHoffsetINoffsets%][%END%]
TransactionID:[%payment.accountlines_id%]
OperatorID:[%payment.manager_id%]
Paymenttype:[%payment.payment_type%]
DescriptionofchargesAmount
[%PROCESSaccount_type_descriptionaccount=offset.debit%][%offset.amount*-1|$Price%]
Total:[%payment.amount*-1|$Price%]
Tendered:[%collected|$Price%]
Change:[%change|$Price%]
}; - - $sth = $dbh->prepare( -q{UPDATE letter SET content = ? WHERE code = 'RECEIPT' AND REPLACE(REPLACE(content, ' ', ''), '\n','') = ? } - ); - $sth->execute($receipt,$receipt_old); - - # replace offsets variable with debit.offsets - $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' payment.offsets %]') WHERE code = 'RECEIPT' "); - # replace collected variable with tendered - $dbh->do("UPDATE letter SET content = REPLACE(content, '[% collected', '[% tendered') WHERE code = 'RECEIPT' "); - - NewVersion( $DBversion, 24381, "Update accounts notices" ); -} diff --git a/installer/data/mysql/atomicupdate/bug_24381.pl b/installer/data/mysql/atomicupdate/bug_24381.pl new file mode 100755 index 0000000000..19b9c94597 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24381.pl @@ -0,0 +1,327 @@ +use Modern::Perl; + +return { + bug_number => "24381", + description => "Update accounts notices", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + # ACCOUNT_CREDIT + my $account_credit = q{ +[%- USE AuthorisedValues -%] +[%- USE KohaDates -%] +[%- USE Price -%] +[%- PROCESS "accounts.inc" -%] + + [% IF ( LibraryName ) %] + + + + [% END %] + [% IF credit.library %] + + + + [% END %] + + + + + + + + + + + + [% IF credit.payment_type %] + + + + + [% END %] + + + + [% IF ( credit.credit_type_code == 'PAYMENT' ) %] + + + + [% ELSIF ( credit.credit_type_code == 'CREDIT' ) %] + + + + [% ELSIF ( credit.credit_type_code == 'WRITEOFF' ) %] + + + + [% END %] + [% IF credit.amountoutstanding + 0 != 0 %] + + + + + + + + + + + + + [% END %] + [% IF credit.amount != credit.amountoutstanding %] + + + + + [% FOREACH offset IN credit.credit_offsets %] + + + + + [% END %] + [% END %] + + + + + + [% IF change.defined %] + + + + + [% END %] + + + + + + + + +
+

[% LibraryName | html %]

+
+

[% credit.library.branchname | html %]

+
+

[% today | $KohaDates %]

+
Transaction ID: [% credit.accountlines_id %]
Operator ID: [% credit.manager_id %]
Payment type: [% AuthorisedValues.GetByCode('PAYMENT_TYPE', credit.payment_type) %]
+

[%- PROCESS credit_type_description credit_type = credit.credit_type -%] receipt

+
+ Received with thanks from [% credit.patron.firstname | html %] [% credit.patron.surname | html %]
+ Card number: [% credit.patron.cardnumber | html %]
+
+ Credit added to account for [% credit.patron.firstname | html %] [% credit.patron.surname | html %]
+ Card number: [% credit.patron.cardnumber | html %]
+
+ Writeoff added to account for [% credit.patron.firstname | html %] [% credit.patron.surname | html %]
+ Card number: [% credit.patron.cardnumber | html %]
+
Description of creditAmount
[%- PROCESS credit_type_description credit_type = credit.credit_type -%][% credit.amount * -1 | $Price %]
Total available:[% credit.amountoutstanding * -1 | $Price %]
Description of chargesAmount
[% PROCESS account_type_description account=offset.debit %][% IF ( offset.debit.itemnumber ) %] - [% offset.debit.item.biblio.title %][% END %][% offset.amount * -1 | $Price %]
Total:[% credit.amount * -1 | $Price %]
Change given: [% change | $Price %]
Account balance as on date:[% credit.patron.account.balance * -1 | $Price %]
+ }; + + my $account_credit_old = q{[%IF(LibraryName)%]

[%LibraryName|html%]

[%END%]

Feereceipt

[%Branches.GetName(patron.branchcode)|html%]

Receivedwiththanksfrom[%patron.firstname|html%][%patron.surname|html%]
Cardnumber:[%patron.cardnumber|html%]
[%FOREACHaccountINaccounts%][%IF(account.amountcredit)%][%ELSE%][%END%][%account.amount|$Price%][%END%]Totaloutstandingduesasondate:[%IF(totalcredit)%][%ELSE%][%END%][%total|$Price%]
DateDescriptionofchargesNoteAmount
[%account.date|$KohaDates%][%PROCESSaccount_type_descriptionaccount=account%][%-IFaccount.description%],[%account.description|html%][%END%][%account.note|html%]
}; + + my $sth = $dbh->prepare(q{ + UPDATE letter SET content = ? WHERE code = 'ACCOUNT_CREDIT' AND REPLACE(REPLACE(content, ' ', ''), '\n','') = ? + }); + $sth->execute( $account_credit, $account_credit_old ); + + # replace patron variable with credit.patron + $dbh->do("UPDATE letter SET content = REPLACE(content, '[% patron', '[% credit.patron') WHERE code = 'ACCOUNT_CREDIT' "); + # replace library variable with credit.library.branchname + $dbh->do("UPDATE letter SET content = REPLACE(content, '[% library', '[% credit.library.branchname') WHERE code = 'ACCOUNT_CREDIT' "); + # replace offsets variable with credit.offsets + $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' credit.offsets %]') WHERE code = 'ACCOUNT_CREDIT' "); + # replace change_given variable with change + $dbh->do("UPDATE letter SET content = REPLACE(content, '[% change_given', '[% change') WHERE code = 'ACCOUNT_CREDIT' "); + + # ACCOUNT_DEBIT + my $account_debit = q{ +[% PROCESS "accounts.inc" %] +[%- USE Price -%] +[%- USE KohaDates -%] + + [% IF ( LibraryName ) %] + + + + [% END %] + [% IF debit.library %] + + + + [% END %] + + + + + [% IF credit.manager_id %] + + + + + [% END %] + + + + + + + [% IF debit.amountoutstanding != 0 %] + + + + + + + + + + + + + + + [% END %] + [% IF debit.amount != debit.amountoutstanding %] + + + + + + [% FOREACH offset IN debit.debit_offsets %] + + + + + + [% END %] + + + + + [% END %] + + + + + + + + + +
+

[% LibraryName | html %]

+
+

[% debit.library.branchname | html %]

+
Fee ID: [% debit.accountlines_id %]
Operator ID: [% credit.manager_id %]
+

Invoice

+
+ Bill to: [% debit.patron.firstname | html %] [% debit.patron.surname | html %]
+ Card number: [% debit.patron.cardnumber | html %]
+
DateDescription of chargesAmount
[% debit.date | $KohaDates %][% PROCESS account_type_description account=debit %][% debit.amount | $Price %]
Total owed:[% debit.amount | $Price %]
DateDescription of paymentsAmount
[% offset.credit.date | $KohaDates %][% PROCESS account_type_description account=offset.credit %][% offset.amount * -1 | $Price %]
Total paid:[% debit.amount - debit.amountoutstanding | $Price %]
Total outstanding:[% debit.amountoutstanding | $Price %]
+ }; + + my $account_debit_old = q{[%IF(LibraryName)%]

[%LibraryName|html%]

[%END%]

INVOICE

[%Branches.GetName(patron.branchcode)|html%]

Billto:[%patron.firstname|html%][%patron.surname|html%]
Cardnumber:[%patron.cardnumber|html%]
AmountAmountoutstanding[%FOREACHaccountINaccounts%][%IF(account.amountcredit)%][%ELSE%][%END%][%account.amount|$Price%][%IF(account.amountoutstandingcredit)%][%ELSE%][%END%][%account.amountoutstanding|$Price%][%END%]Totaloutstandingduesasondate:[%IF(totalcredit)%][%ELSE%][%END%][%total|$Price%]
DateDescriptionofchargesNote
[%account.date|$KohaDates%][%PROCESSaccount_type_descriptionaccount=account%][%-IFaccount.description%],[%account.description|html%][%END%][%account.note|html%]
}; + + $sth = $dbh->prepare(q{ + UPDATE letter SET content = ? WHERE code = 'ACCOUNT_DEBIT' AND REPLACE(REPLACE(content, ' ', ''), '\n','') = ? + }); + $sth->execute($account_debit, $account_debit_old); + + # replace patron variable with debit.patron + $dbh->do("UPDATE letter SET content = REPLACE(content, '[% patron', '[% debit.patron') WHERE code = 'ACCOUNT_DEBIT' "); + # replace library variable with debit.library.branchname + $dbh->do("UPDATE letter SET content = REPLACE(content, '[% library', '[% debit.library.branchname') WHERE code = 'ACCOUNT_DEBIT' "); + # replace offsets variable with debit.offsets + $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' debit.offsets %]') WHERE code = 'ACCOUNT_DEBIT' "); + # replace total variable with debit.patron.account.balance + $dbh->do("UPDATE letter SET content = REPLACE(content, '[% total ', '[% debit.patron.account.balance ') WHERE code = 'ACCOUNT_DEBIT' "); + # replace totalcredit variable with debit.patron.account.balance <= 0 + $dbh->do("UPDATE letter SET content = REPLACE(content, 'totalcredit', 'debit.patron.account.balance <= 0') WHERE code = 'ACCOUNT_DEBIT' "); + + # RECEIPT + my $receipt = q{ +[% PROCESS "accounts.inc" %] +[%- USE KohaDates -%] +[%- USE Price -%] + + [% IF ( LibraryName ) %] + + + + [% END %] + [% IF credit.library %] + + + + [% END %] + + + + + + + + + + + + + + + + + + + + + + + [% FOREACH offset IN payment.credit_offsets %] + + + + + [% END %] + + + + + + + + + + + + + + +
+

[% LibraryName | html %]

+
+

[% payment.library.branchname ) | html %]

+
+

[% payment.date | $KohaDates %]

+
Transaction ID: [% payment.accountlines_id %]
Operator ID: [% payment.manager_id %]
Payment type: [% payment.payment_type %]
+

Payment receipt

+
Description of chargesAmount
[% PROCESS account_type_description account=offset.debit %][% offset.amount * -1 | $Price %]
Total:[% payment.amount * -1 | $Price %]
Tendered: [% tendered | $Price %]
Change given:[% change | $Price %]
+ }; + + my $receipt_old = q{[%PROCESS"accounts.inc"%][%IF(LibraryName)%]

[%LibraryName|html%]

[%END%]

[%Branches.GetName(payment.branchcode)|html%]

[%payment.date|$KohaDates%]

Feereceipt

[%FOREACHoffsetINoffsets%][%END%]
TransactionID:[%payment.accountlines_id%]
OperatorID:[%payment.manager_id%]
Paymenttype:[%payment.payment_type%]
DescriptionofchargesAmount
[%PROCESSaccount_type_descriptionaccount=offset.debit%][%offset.amount*-1|$Price%]
Total:[%payment.amount*-1|$Price%]
Tendered:[%collected|$Price%]
Change:[%change|$Price%]
}; + + $sth = $dbh->prepare(q{ + UPDATE letter SET content = ? WHERE code = 'RECEIPT' AND REPLACE(REPLACE(content, ' ', ''), '\n','') = ? + }); + $sth->execute($receipt,$receipt_old); + + # replace offsets variable with debit.offsets + $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' payment.offsets %]') WHERE code = 'RECEIPT' "); + # replace collected variable with tendered + $dbh->do("UPDATE letter SET content = REPLACE(content, '[% collected', '[% tendered') WHERE code = 'RECEIPT' "); + }, +}; -- 2.39.5