2
0
mirror of https://github.com/frappe/books.git synced 2025-01-23 15:18:24 +00:00

Merge pull request #809 from frappe/mildred/808-fix-payment-reference-type

fix: #808 Payment referenceType NULL due to bad migration
This commit is contained in:
Mildred Ki'Lya 2024-01-19 23:45:08 +01:00 committed by GitHub
commit dac1b24291
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import createInventoryNumberSeries from './createInventoryNumberSeries';
import fixRoundOffAccount from './fixRoundOffAccount';
import testPatch from './testPatch';
import updateSchemas from './updateSchemas';
import setPaymentReferenceType from './setPaymentReferenceType';
export default [
{ name: 'testPatch', version: '0.5.0-beta.0', patch: testPatch },
@ -28,4 +29,9 @@ export default [
version: '0.6.6-beta.0',
patch: createInventoryNumberSeries,
},
{
name: 'setPaymentReferenceType',
version: '0.21.0',
patch: setPaymentReferenceType,
},
] as Patch[];

View File

@ -0,0 +1,12 @@
import { DatabaseManager } from '../database/manager';
async function execute(dm: DatabaseManager) {
await dm.db!.knex!('Payment')
.where({ referenceType: null, paymentType: 'Pay' })
.update({ referenceType: 'PurchaseInvoice' });
await dm.db!.knex!('Payment')
.where({ referenceType: null, paymentType: 'Receive' })
.update({ referenceType: 'SalesInvoice' });
}
export default { execute, beforeMigrate: true };