mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-27 18:19:48 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a383c71424 | ||
|
|
2065afe108 | ||
|
|
7051256e60 | ||
|
|
5dd7179cca | ||
|
|
3575d54efa |
@@ -15,6 +15,8 @@ import { AttachmentsOnPaymentsReceived } from "./events/AttachmentsOnPaymentsRec
|
|||||||
import { AttachmentsOnManualJournals } from "./events/AttachmentsOnManualJournals";
|
import { AttachmentsOnManualJournals } from "./events/AttachmentsOnManualJournals";
|
||||||
import { AttachmentsOnVendorCredits } from "./events/AttachmentsOnVendorCredits";
|
import { AttachmentsOnVendorCredits } from "./events/AttachmentsOnVendorCredits";
|
||||||
import { AttachmentsOnSaleInvoiceCreated } from "./events/AttachmentsOnSaleInvoice";
|
import { AttachmentsOnSaleInvoiceCreated } from "./events/AttachmentsOnSaleInvoice";
|
||||||
|
import { AttachmentsOnSaleReceipt } from "./events/AttachmentsOnSaleReceipts";
|
||||||
|
import { AttachmentsOnSaleEstimates } from "./events/AttachmentsOnSaleEstimates";
|
||||||
import { AttachmentsController } from "./Attachments.controller";
|
import { AttachmentsController } from "./Attachments.controller";
|
||||||
import { RegisterTenancyModel } from "../Tenancy/TenancyModels/Tenancy.module";
|
import { RegisterTenancyModel } from "../Tenancy/TenancyModels/Tenancy.module";
|
||||||
import { DocumentModel } from "./models/Document.model";
|
import { DocumentModel } from "./models/Document.model";
|
||||||
@@ -50,6 +52,8 @@ const models = [
|
|||||||
AttachmentsOnManualJournals,
|
AttachmentsOnManualJournals,
|
||||||
AttachmentsOnVendorCredits,
|
AttachmentsOnVendorCredits,
|
||||||
AttachmentsOnSaleInvoiceCreated,
|
AttachmentsOnSaleInvoiceCreated,
|
||||||
|
AttachmentsOnSaleReceipt,
|
||||||
|
AttachmentsOnSaleEstimates,
|
||||||
AttachmentsApplication,
|
AttachmentsApplication,
|
||||||
UploadDocument,
|
UploadDocument,
|
||||||
AttachmentUploadPipeline,
|
AttachmentUploadPipeline,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export class AttachmentsOnPaymentsReceived {
|
|||||||
);
|
);
|
||||||
await this.linkAttachmentService.bulkLink(
|
await this.linkAttachmentService.bulkLink(
|
||||||
keys,
|
keys,
|
||||||
'PaymentReceive',
|
'PaymentReceived',
|
||||||
paymentReceive.id,
|
paymentReceive.id,
|
||||||
trx,
|
trx,
|
||||||
);
|
);
|
||||||
@@ -76,7 +76,7 @@ export class AttachmentsOnPaymentsReceived {
|
|||||||
);
|
);
|
||||||
await this.unlinkAttachmentService.unlinkUnpresentedKeys(
|
await this.unlinkAttachmentService.unlinkUnpresentedKeys(
|
||||||
keys,
|
keys,
|
||||||
'PaymentReceive',
|
'PaymentReceived',
|
||||||
oldPaymentReceive.id,
|
oldPaymentReceive.id,
|
||||||
trx,
|
trx,
|
||||||
);
|
);
|
||||||
@@ -100,7 +100,7 @@ export class AttachmentsOnPaymentsReceived {
|
|||||||
);
|
);
|
||||||
await this.linkAttachmentService.bulkLink(
|
await this.linkAttachmentService.bulkLink(
|
||||||
keys,
|
keys,
|
||||||
'PaymentReceive',
|
'PaymentReceived',
|
||||||
oldPaymentReceive.id,
|
oldPaymentReceive.id,
|
||||||
trx,
|
trx,
|
||||||
);
|
);
|
||||||
@@ -117,7 +117,7 @@ export class AttachmentsOnPaymentsReceived {
|
|||||||
trx,
|
trx,
|
||||||
}: IPaymentReceivedDeletingPayload) {
|
}: IPaymentReceivedDeletingPayload) {
|
||||||
await this.unlinkAttachmentService.unlinkAllModelKeys(
|
await this.unlinkAttachmentService.unlinkAllModelKeys(
|
||||||
'PaymentReceive',
|
'PaymentReceived',
|
||||||
oldPaymentReceive.id,
|
oldPaymentReceive.id,
|
||||||
trx,
|
trx,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import { BillPaymentMeta } from './BillPayment.meta';
|
|||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { BillPaymentDefaultViews } from '../constants';
|
import { BillPaymentDefaultViews } from '../constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@InjectModelMeta(BillPaymentMeta)
|
@InjectModelMeta(BillPaymentMeta)
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/Inje
|
|||||||
import { BillMeta } from './Bill.meta';
|
import { BillMeta } from './Bill.meta';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { BillDefaultViews } from '../Bills.constants';
|
import { BillDefaultViews } from '../Bills.constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@InjectModelMeta(BillMeta)
|
@InjectModelMeta(BillMeta)
|
||||||
@InjectModelDefaultViews(BillDefaultViews)
|
@InjectModelDefaultViews(BillDefaultViews)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export class DocumentLink extends BaseModel{
|
|||||||
* Relationship mapping.
|
* Relationship mapping.
|
||||||
*/
|
*/
|
||||||
static get relationMappings() {
|
static get relationMappings() {
|
||||||
const Document = require('./Document');
|
const { Document } = require('./Document');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +36,7 @@ export class DocumentLink extends BaseModel{
|
|||||||
*/
|
*/
|
||||||
document: {
|
document: {
|
||||||
relation: Model.HasOneRelation,
|
relation: Model.HasOneRelation,
|
||||||
modelClass: Document.default,
|
modelClass: Document,
|
||||||
join: {
|
join: {
|
||||||
from: 'document_links.documentId',
|
from: 'document_links.documentId',
|
||||||
to: 'documents.id',
|
to: 'documents.id',
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
|||||||
import { CreditNoteMeta } from './CreditNote.meta';
|
import { CreditNoteMeta } from './CreditNote.meta';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { CreditNoteDefaultViews } from '../constants';
|
import { CreditNoteDefaultViews } from '../constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@InjectModelMeta(CreditNoteMeta)
|
@InjectModelMeta(CreditNoteMeta)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/Inje
|
|||||||
import { ExpenseMeta } from './Expense.meta';
|
import { ExpenseMeta } from './Expense.meta';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { ExpenseDefaultViews } from '../constants';
|
import { ExpenseDefaultViews } from '../constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@InjectModelMeta(ExpenseMeta)
|
@InjectModelMeta(ExpenseMeta)
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import { ManualJournalMeta } from './ManualJournal.meta';
|
|||||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { ManualJournalDefaultViews } from '../constants';
|
import { ManualJournalDefaultViews } from '../constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@InjectModelMeta(ManualJournalMeta)
|
@InjectModelMeta(ManualJournalMeta)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Model } from 'objection';
|
import { Model } from 'objection';
|
||||||
import { PaymentReceivedEntry } from './PaymentReceivedEntry';
|
import { PaymentReceivedEntry } from './PaymentReceivedEntry';
|
||||||
|
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||||
@@ -7,7 +8,9 @@ import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/Inje
|
|||||||
import { PaymentReceivedMeta } from './PaymentReceived.meta';
|
import { PaymentReceivedMeta } from './PaymentReceived.meta';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { PaymentReceivedDefaultViews } from '../constants';
|
import { PaymentReceivedDefaultViews } from '../constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@InjectModelMeta(PaymentReceivedMeta)
|
@InjectModelMeta(PaymentReceivedMeta)
|
||||||
@@ -31,6 +34,7 @@ export class PaymentReceived extends TenantBaseModel {
|
|||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|
||||||
entries?: PaymentReceivedEntry[];
|
entries?: PaymentReceivedEntry[];
|
||||||
|
public attachments!: Document[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table name.
|
* Table name.
|
||||||
@@ -159,7 +163,7 @@ export class PaymentReceived extends TenantBaseModel {
|
|||||||
to: 'documents.id',
|
to: 'documents.id',
|
||||||
},
|
},
|
||||||
filter(query) {
|
filter(query) {
|
||||||
query.where('model_ref', 'PaymentReceive');
|
query.where('model_ref', 'PaymentReceived');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export class GetPaymentReceivedService {
|
|||||||
.withGraphFetched('entries.invoice')
|
.withGraphFetched('entries.invoice')
|
||||||
.withGraphFetched('transactions')
|
.withGraphFetched('transactions')
|
||||||
.withGraphFetched('branch')
|
.withGraphFetched('branch')
|
||||||
|
.withGraphFetched('attachments')
|
||||||
.findById(paymentReceiveId);
|
.findById(paymentReceiveId);
|
||||||
|
|
||||||
if (!paymentReceive) {
|
if (!paymentReceive) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Transformer } from '../../Transformer/Transformer';
|
|||||||
import { PaymentReceived } from '../models/PaymentReceived';
|
import { PaymentReceived } from '../models/PaymentReceived';
|
||||||
import { PaymentReceivedEntry } from '../models/PaymentReceivedEntry';
|
import { PaymentReceivedEntry } from '../models/PaymentReceivedEntry';
|
||||||
import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer';
|
import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer';
|
||||||
|
import { AttachmentTransformer } from '@/modules/Attachments/Attachment.transformer';
|
||||||
|
|
||||||
export class PaymentReceiveTransfromer extends Transformer {
|
export class PaymentReceiveTransfromer extends Transformer {
|
||||||
/**
|
/**
|
||||||
@@ -17,6 +18,7 @@ export class PaymentReceiveTransfromer extends Transformer {
|
|||||||
'formattedAmount',
|
'formattedAmount',
|
||||||
'formattedExchangeRate',
|
'formattedExchangeRate',
|
||||||
'entries',
|
'entries',
|
||||||
|
'attachments',
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -89,4 +91,13 @@ export class PaymentReceiveTransfromer extends Transformer {
|
|||||||
protected entries = (payment: PaymentReceived): PaymentReceivedEntry[] => {
|
protected entries = (payment: PaymentReceived): PaymentReceivedEntry[] => {
|
||||||
return this.item(payment.entries, new PaymentReceivedEntryTransfromer());
|
return this.item(payment.entries, new PaymentReceivedEntryTransfromer());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the payment received attachments.
|
||||||
|
* @param {PaymentReceived} payment
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
protected attachments = (payment: PaymentReceived) => {
|
||||||
|
return this.item(payment.attachments, new AttachmentTransformer());
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import { Customer } from '@/modules/Customers/models/Customer';
|
|||||||
import { DiscountType } from '@/common/types/Discount';
|
import { DiscountType } from '@/common/types/Discount';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { SaleEstimateDefaultViews } from '../constants';
|
import { SaleEstimateDefaultViews } from '../constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@InjectModelMeta(SaleEstimateMeta)
|
@InjectModelMeta(SaleEstimateMeta)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { BaseModel } from '@/models/Model';
|
|||||||
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||||
import { Customer } from '@/modules/Customers/models/Customer';
|
import { Customer } from '@/modules/Customers/models/Customer';
|
||||||
import { AccountTransaction } from '@/modules/Accounts/models/AccountTransaction.model';
|
import { AccountTransaction } from '@/modules/Accounts/models/AccountTransaction.model';
|
||||||
|
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
||||||
import { Branch } from '@/modules/Branches/models/Branch.model';
|
import { Branch } from '@/modules/Branches/models/Branch.model';
|
||||||
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
||||||
import { DiscountType } from '@/common/types/Discount';
|
import { DiscountType } from '@/common/types/Discount';
|
||||||
@@ -15,6 +16,7 @@ import { SearchableBaseModelMixin } from '@/modules/DynamicListing/models/Search
|
|||||||
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
import { SaleReceiptMeta } from './SaleReceipt.meta';
|
import { SaleReceiptMeta } from './SaleReceipt.meta';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { SaleReceiptDefaultViews } from '../constants';
|
import { SaleReceiptDefaultViews } from '../constants';
|
||||||
@@ -26,6 +28,7 @@ const ExtendedModel = R.pipe(
|
|||||||
MetadataModelMixin,
|
MetadataModelMixin,
|
||||||
)(BaseModel);
|
)(BaseModel);
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@InjectModelMeta(SaleReceiptMeta)
|
@InjectModelMeta(SaleReceiptMeta)
|
||||||
@@ -58,6 +61,7 @@ export class SaleReceipt extends ExtendedModel {
|
|||||||
public customer!: Customer;
|
public customer!: Customer;
|
||||||
public entries!: ItemEntry[];
|
public entries!: ItemEntry[];
|
||||||
public transactions!: AccountTransaction[];
|
public transactions!: AccountTransaction[];
|
||||||
|
public attachments!: Document[];
|
||||||
public branch!: Branch;
|
public branch!: Branch;
|
||||||
public warehouse!: Warehouse;
|
public warehouse!: Warehouse;
|
||||||
|
|
||||||
|
|||||||
@@ -139,22 +139,22 @@ export class SaleReceiptTransformer extends Transformer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the entries of the credit note.
|
* Retrieves the entries of the sale receipt.
|
||||||
* @param {ISaleReceipt} credit
|
* @param {ISaleReceipt} receipt
|
||||||
* @returns {}
|
* @returns {}
|
||||||
*/
|
*/
|
||||||
// protected entries = (receipt: SaleReceipt) => {
|
protected entries = (receipt: SaleReceipt) => {
|
||||||
// return this.item(receipt.entries, new ItemEntryTransformer(), {
|
return this.item(receipt.entries, new ItemEntryTransformer(), {
|
||||||
// currencyCode: receipt.currencyCode,
|
currencyCode: receipt.currencyCode,
|
||||||
// });
|
});
|
||||||
// };
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the sale receipt attachments.
|
* Retrieves the sale receipt attachments.
|
||||||
* @param {SaleReceipt} receipt
|
* @param {SaleReceipt} receipt
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
// protected attachments = (receipt: SaleReceipt) => {
|
protected attachments = (receipt: SaleReceipt) => {
|
||||||
// return this.item(receipt.attachments, new AttachmentTransformer());
|
return this.item(receipt.attachments, new AttachmentTransformer());
|
||||||
// };
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/Inje
|
|||||||
import { VendorCreditMeta } from './VendorCredit.meta';
|
import { VendorCreditMeta } from './VendorCredit.meta';
|
||||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||||
import { VendorCreditDefaultViews } from '../constants';
|
import { VendorCreditDefaultViews } from '../constants';
|
||||||
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
|
||||||
|
@InjectAttachable()
|
||||||
@ExportableModel()
|
@ExportableModel()
|
||||||
@ImportableModel()
|
@ImportableModel()
|
||||||
@InjectModelMeta(VendorCreditMeta)
|
@InjectModelMeta(VendorCreditMeta)
|
||||||
|
|||||||
@@ -213,17 +213,17 @@ export const currenciesFieldShouldUpdate = (newProps, oldProps) => {
|
|||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useMakeJournalFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useMakeJournalFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useManualJournalCreditTotal = () => {
|
export const useManualJournalCreditTotal = () => {
|
||||||
|
|||||||
@@ -152,17 +152,17 @@ export const transformFormValuesToRequest = (values) => {
|
|||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useExpenseFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useExpenseFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -231,25 +231,25 @@ export const handleErrors = (errors, { setErrors }) => {
|
|||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useBillFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useBillFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSetPrimaryWarehouseToForm = () => {
|
export const useSetPrimaryWarehouseToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { warehouses, isWarehousesSuccess } = useBillFormContext();
|
const { warehouses, isWarehousesSuccess, isNewMode } = useBillFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isWarehousesSuccess) {
|
if (isWarehousesSuccess && isNewMode) {
|
||||||
const primaryWarehouse =
|
const primaryWarehouse =
|
||||||
warehouses.find((b) => b.primary) || first(warehouses);
|
warehouses.find((b) => b.primary) || first(warehouses);
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ export const useSetPrimaryWarehouseToForm = () => {
|
|||||||
setFieldValue('warehouse_id', primaryWarehouse.id);
|
setFieldValue('warehouse_id', primaryWarehouse.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
}, [isWarehousesSuccess, setFieldValue, warehouses, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -156,25 +156,25 @@ export const useObserveVendorCreditNoSettings = (prefix, nextNumber) => {
|
|||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useVendorCreditNoteFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useVendorCreditNoteFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSetPrimaryWarehouseToForm = () => {
|
export const useSetPrimaryWarehouseToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { warehouses, isWarehousesSuccess } = useVendorCreditNoteFormContext();
|
const { warehouses, isWarehousesSuccess, isNewMode } = useVendorCreditNoteFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isWarehousesSuccess) {
|
if (isWarehousesSuccess && isNewMode) {
|
||||||
const primaryWarehouse =
|
const primaryWarehouse =
|
||||||
warehouses.find((b) => b.primary) || first(warehouses);
|
warehouses.find((b) => b.primary) || first(warehouses);
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ export const useSetPrimaryWarehouseToForm = () => {
|
|||||||
setFieldValue('warehouse_id', primaryWarehouse.id);
|
setFieldValue('warehouse_id', primaryWarehouse.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
}, [isWarehousesSuccess, setFieldValue, warehouses, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -115,17 +115,17 @@ export const transformFormToRequest = (form) => {
|
|||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = usePaymentMadeFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = usePaymentMadeFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -148,25 +148,25 @@ export const entriesFieldShouldUpdate = (newProps, oldProps) => {
|
|||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useCreditNoteFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useCreditNoteFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSetPrimaryWarehouseToForm = () => {
|
export const useSetPrimaryWarehouseToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { warehouses, isWarehousesSuccess } = useCreditNoteFormContext();
|
const { warehouses, isWarehousesSuccess, isNewMode } = useCreditNoteFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isWarehousesSuccess) {
|
if (isWarehousesSuccess && isNewMode) {
|
||||||
const primaryWarehouse =
|
const primaryWarehouse =
|
||||||
warehouses.find((b) => b.primary) || first(warehouses);
|
warehouses.find((b) => b.primary) || first(warehouses);
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ export const useSetPrimaryWarehouseToForm = () => {
|
|||||||
setFieldValue('warehouse_id', primaryWarehouse.id);
|
setFieldValue('warehouse_id', primaryWarehouse.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
}, [isWarehousesSuccess, setFieldValue, warehouses, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -182,10 +182,10 @@ export const transfromsFormValuesToRequest = (values) => {
|
|||||||
|
|
||||||
export const useSetPrimaryWarehouseToForm = () => {
|
export const useSetPrimaryWarehouseToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { warehouses, isWarehousesSuccess } = useEstimateFormContext();
|
const { warehouses, isWarehousesSuccess, isNewMode } = useEstimateFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isWarehousesSuccess) {
|
if (isWarehousesSuccess && isNewMode) {
|
||||||
const primaryWarehouse =
|
const primaryWarehouse =
|
||||||
warehouses.find((b) => b.primary) || first(warehouses);
|
warehouses.find((b) => b.primary) || first(warehouses);
|
||||||
|
|
||||||
@@ -193,22 +193,22 @@ export const useSetPrimaryWarehouseToForm = () => {
|
|||||||
setFieldValue('warehouse_id', primaryWarehouse.id);
|
setFieldValue('warehouse_id', primaryWarehouse.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
}, [isWarehousesSuccess, setFieldValue, warehouses, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useEstimateFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useEstimateFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -264,10 +264,10 @@ const transformPaymentMethodsToForm = (
|
|||||||
|
|
||||||
export const useSetPrimaryWarehouseToForm = () => {
|
export const useSetPrimaryWarehouseToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { warehouses, isWarehousesSuccess } = useInvoiceFormContext();
|
const { warehouses, isWarehousesSuccess, isNewMode } = useInvoiceFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isWarehousesSuccess) {
|
if (isWarehousesSuccess && isNewMode) {
|
||||||
const primaryWarehouse =
|
const primaryWarehouse =
|
||||||
warehouses.find((b) => b.primary) || first(warehouses);
|
warehouses.find((b) => b.primary) || first(warehouses);
|
||||||
|
|
||||||
@@ -275,22 +275,22 @@ export const useSetPrimaryWarehouseToForm = () => {
|
|||||||
setFieldValue('warehouse_id', primaryWarehouse.id);
|
setFieldValue('warehouse_id', primaryWarehouse.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
}, [isWarehousesSuccess, setFieldValue, warehouses, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useInvoiceFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useInvoiceFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -177,17 +177,17 @@ export const transformFormToRequest = (form) => {
|
|||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = usePaymentReceiveFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = usePaymentReceiveFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -173,10 +173,10 @@ export const transformFormValuesToRequest = (values) => {
|
|||||||
|
|
||||||
export const useSetPrimaryWarehouseToForm = () => {
|
export const useSetPrimaryWarehouseToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { warehouses, isWarehousesSuccess } = useReceiptFormContext();
|
const { warehouses, isWarehousesSuccess, isNewMode } = useReceiptFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isWarehousesSuccess) {
|
if (isWarehousesSuccess && isNewMode) {
|
||||||
const primaryWarehouse =
|
const primaryWarehouse =
|
||||||
warehouses.find((b) => b.primary) || first(warehouses);
|
warehouses.find((b) => b.primary) || first(warehouses);
|
||||||
|
|
||||||
@@ -184,22 +184,22 @@ export const useSetPrimaryWarehouseToForm = () => {
|
|||||||
setFieldValue('warehouse_id', primaryWarehouse.id);
|
setFieldValue('warehouse_id', primaryWarehouse.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isWarehousesSuccess, setFieldValue, warehouses]);
|
}, [isWarehousesSuccess, setFieldValue, warehouses, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSetPrimaryBranchToForm = () => {
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
const { branches, isBranchesSuccess } = useReceiptFormContext();
|
const { branches, isBranchesSuccess, isNewMode } = useReceiptFormContext();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isBranchesSuccess) {
|
if (isBranchesSuccess && isNewMode) {
|
||||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
if (primaryBranch) {
|
if (primaryBranch) {
|
||||||
setFieldValue('branch_id', primaryBranch.id);
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user