Skip to content

Commit

Permalink
Merge pull request #809 from frappe/mildred/808-fix-payment-reference…
Browse files Browse the repository at this point in the history
…-type

fix: #808 Payment referenceType NULL due to bad migration
  • Loading branch information
mildred committed Jan 19, 2024
2 parents c7c7aae + dcbfa9f commit dac1b24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/patches/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -28,4 +29,9 @@ export default [
version: '0.6.6-beta.0',
patch: createInventoryNumberSeries,
},
{
name: 'setPaymentReferenceType',
version: '0.21.0',
patch: setPaymentReferenceType,
},
] as Patch[];
12 changes: 12 additions & 0 deletions backend/patches/setPaymentReferenceType.ts
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit dac1b24

Please sign in to comment.