mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-25 00:59:50 +00:00
Compare commits
1 Commits
abouhuolia
...
abouhuolia
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ad1d3677c |
@@ -9,6 +9,7 @@ import events from '@/subscribers/events';
|
||||
import UnitOfWork from '@/services/UnitOfWork';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import { CommandExpenseValidator } from './CommandExpenseValidator';
|
||||
import { ExpenseCategory } from 'models';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
@@ -36,7 +37,7 @@ export class DeleteExpense {
|
||||
expenseId: number,
|
||||
authorizedUser: ISystemUser
|
||||
): Promise<void> => {
|
||||
const { Expense, ExpenseCategory } = this.tenancy.models(tenantId);
|
||||
const { Expense } = this.tenancy.models(tenantId);
|
||||
|
||||
// Retrieves the expense transaction with associated entries or
|
||||
// throw not found error.
|
||||
@@ -59,7 +60,7 @@ export class DeleteExpense {
|
||||
} as IExpenseDeletingPayload);
|
||||
|
||||
// Deletes expense associated entries.
|
||||
await ExpenseCategory.query(trx).where('expenseId', expenseId).delete();
|
||||
await ExpenseCategory.query(trx).findById(expenseId).delete();
|
||||
|
||||
// Deletes expense transactions.
|
||||
await Expense.query(trx).findById(expenseId).delete();
|
||||
|
||||
@@ -46,7 +46,7 @@ export class ExpenseGLEntries {
|
||||
...commonEntry,
|
||||
credit: expense.localAmount,
|
||||
accountId: expense.paymentAccountId,
|
||||
accountNormal: AccountNormal.DEBIT,
|
||||
accountNormal: AccountNormal.CREDIT,
|
||||
index: 1,
|
||||
};
|
||||
};
|
||||
|
||||
7
packages/webapp/src/constants/adjustmentType.tsx
Normal file
7
packages/webapp/src/constants/adjustmentType.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
export default [
|
||||
{ name: intl.get('decrement'), value: 'decrement' },
|
||||
{ name: intl.get('increment'), value: 'increment' },
|
||||
]
|
||||
@@ -4,6 +4,7 @@ export * from './tableStyle';
|
||||
export * from './features';
|
||||
export * from './cellTypes';
|
||||
export * from './classes';
|
||||
export * from './adjustmentType';
|
||||
export * from './cashflowOptions';
|
||||
|
||||
export const Align = { Left: 'left', Right: 'right', Center: 'center' };
|
||||
|
||||
@@ -34,17 +34,16 @@ import {
|
||||
toSafeNumber,
|
||||
} from '@/utils';
|
||||
import { Features, CLASSES } from '@/constants';
|
||||
import adjustmentType from '@/constants/adjustmentType';
|
||||
|
||||
import { useInventoryAdjContext } from './InventoryAdjustmentFormProvider';
|
||||
import { useFeatureCan } from '@/hooks/state';
|
||||
|
||||
import InventoryAdjustmentQuantityFields from './InventoryAdjustmentQuantityFields';
|
||||
import {
|
||||
diffQuantity,
|
||||
useSetPrimaryBranchToForm,
|
||||
useSetPrimaryWarehouseToForm,
|
||||
useGetAdjustmentTypeOptions,
|
||||
} from './utils';
|
||||
import { useFeatureCan } from '@/hooks/state';
|
||||
import InventoryAdjustmentQuantityFields from './InventoryAdjustmentQuantityFields';
|
||||
|
||||
/**
|
||||
* Inventory adjustment form dialogs fields.
|
||||
@@ -53,9 +52,6 @@ export default function InventoryAdjustmentFormDialogFields() {
|
||||
// Features guard.
|
||||
const { featureCan } = useFeatureCan();
|
||||
|
||||
// Retrieves memorized adjustment types options.
|
||||
const adjustmentTypes = useGetAdjustmentTypeOptions();
|
||||
|
||||
const dateFieldRef = useAutofocus();
|
||||
|
||||
// Inventory adjustment dialog context.
|
||||
@@ -153,7 +149,7 @@ export default function InventoryAdjustmentFormDialogFields() {
|
||||
className={classNames(CLASSES.FILL, 'form-group--type')}
|
||||
>
|
||||
<ListSelect
|
||||
items={adjustmentTypes}
|
||||
items={adjustmentType}
|
||||
onItemSelect={(type) => {
|
||||
const result = diffQuantity(
|
||||
toSafeNumber(values.quantity),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import React, { useMemo } from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { useInventoryAdjContext } from './InventoryAdjustmentFormProvider';
|
||||
import { first } from 'lodash';
|
||||
@@ -49,12 +48,3 @@ export const useSetPrimaryBranchToForm = () => {
|
||||
}
|
||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
||||
};
|
||||
|
||||
export const getAdjustmentTypeOptions = () => [
|
||||
{ name: intl.get('decrement'), value: 'decrement' },
|
||||
{ name: intl.get('increment'), value: 'increment' },
|
||||
];
|
||||
|
||||
export const useGetAdjustmentTypeOptions = () => {
|
||||
return useMemo(() => getAdjustmentTypeOptions(), []);
|
||||
};
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
FormattedMessage as T,
|
||||
Can,
|
||||
} from '@/components';
|
||||
import { ItemDetailActionsMoreBtn } from './ItemDetailActionsMoreBtn';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
|
||||
@@ -72,7 +71,6 @@ function ItemDetailActionsBar({
|
||||
onClick={handleDeleteItem}
|
||||
/>
|
||||
</Can>
|
||||
<ItemDetailActionsMoreBtn />
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import { Can, Icon, T } from '@/components';
|
||||
import {
|
||||
Button,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Popover,
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
} from '@blueprintjs/core';
|
||||
import {
|
||||
AbilitySubject,
|
||||
InventoryAdjustmentAction,
|
||||
} from '@/constants/abilityOption';
|
||||
import { useItemDetailDrawerContext } from './ItemDetailDrawerProvider';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
/**
|
||||
* Invoice details more actions menu.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export const ItemDetailActionsMoreBtn = R.compose(withDialogActions)(
|
||||
({
|
||||
//#withDialogActions,
|
||||
openDialog,
|
||||
}) => {
|
||||
const { itemId, item } = useItemDetailDrawerContext();
|
||||
|
||||
// Cannot continue if the item type is not inventory.
|
||||
if (item.type !== 'inventory') return null;
|
||||
|
||||
const handleInventoryAdjustment = () => {
|
||||
openDialog('inventory-adjustment', { itemId });
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
modifiers={{
|
||||
offset: { offset: '0, 4' },
|
||||
}}
|
||||
content={
|
||||
<Menu>
|
||||
<Can
|
||||
I={InventoryAdjustmentAction.Edit}
|
||||
a={AbilitySubject.InventoryAdjustment}
|
||||
>
|
||||
<MenuItem
|
||||
text={<T id={'item.view_drawer.make_adjustment'} />}
|
||||
onClick={handleInventoryAdjustment}
|
||||
/>
|
||||
</Can>
|
||||
</Menu>
|
||||
}
|
||||
>
|
||||
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
||||
</Popover>
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
|
||||
import PaymentMadesEmptyStatus from './PaymentMadesEmptyStatus';
|
||||
|
||||
import withPaymentMade from './withPaymentMade';
|
||||
import withPaymentMadeActions from './withPaymentMadeActions';
|
||||
import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization';
|
||||
|
||||
@@ -24,6 +23,7 @@ import withSettings from '@/containers/Settings/withSettings';
|
||||
import { usePaymentMadesTableColumns, ActionsMenu } from './components';
|
||||
import { usePaymentMadesListContext } from './PaymentMadesListProvider';
|
||||
import { useMemorizedColumnsWidths } from '@/hooks';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
|
||||
/**
|
||||
* Payment made datatable transactions.
|
||||
@@ -32,9 +32,6 @@ function PaymentMadesTable({
|
||||
// #withPaymentMadeActions
|
||||
setPaymentMadesTableState,
|
||||
|
||||
// #withPaymentMade
|
||||
paymentMadesTableState,
|
||||
|
||||
// #withAlerts
|
||||
openAlert,
|
||||
|
||||
@@ -71,12 +68,12 @@ function PaymentMadesTable({
|
||||
|
||||
// Handle view detail payment made.
|
||||
const handleViewDetailPaymentMade = ({ id }) => {
|
||||
openDrawer('payment-made-detail-drawer', { paymentMadeId: id });
|
||||
openDrawer(DRAWERS.PAYMENT_MADE, { paymentMadeId: id });
|
||||
};
|
||||
|
||||
// Handle cell click.
|
||||
const handleCellClick = (cell, event) => {
|
||||
openDrawer('payment-made-detail-drawer', {
|
||||
openDrawer(DRAWERS.PAYMENT_MADE, {
|
||||
paymentMadeId: cell.row.original.id,
|
||||
});
|
||||
};
|
||||
@@ -134,7 +131,6 @@ function PaymentMadesTable({
|
||||
|
||||
export default compose(
|
||||
withPaymentMadeActions,
|
||||
withPaymentMade(({ paymentMadesTableState }) => ({ paymentMadesTableState })),
|
||||
withAlertsActions,
|
||||
withDrawerActions,
|
||||
withCurrentOrganization(),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// @ts-nocheck
|
||||
|
||||
export default {
|
||||
INVENTORY_ADJUSTMENTS_TABLE_STATE_SET:
|
||||
'INVENTORY_ADJUSTMENTS/TABLE_STATE_SET',
|
||||
};
|
||||
INVENTORY_ADJUSTMENTS_TABLE_STATE_SET: 'INVENTORY_ADJUSTMENTS/TABLE_STATE_SET',
|
||||
};
|
||||
Reference in New Issue
Block a user