mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
Merge pull request #1259 from frappe/fix-transfer-unit
fix: adjust quantity when transfer UOM is modified
This commit is contained in:
@@ -79,6 +79,7 @@ export abstract class Invoice extends Transactional {
|
|||||||
grandTotal?: Money;
|
grandTotal?: Money;
|
||||||
baseGrandTotal?: Money;
|
baseGrandTotal?: Money;
|
||||||
outstandingAmount?: Money;
|
outstandingAmount?: Money;
|
||||||
|
initialGrandTotal?: Money;
|
||||||
exchangeRate?: number;
|
exchangeRate?: number;
|
||||||
setDiscountAmount?: boolean;
|
setDiscountAmount?: boolean;
|
||||||
discountAmount?: Money;
|
discountAmount?: Money;
|
||||||
@@ -869,19 +870,18 @@ export abstract class Invoice extends Transactional {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getLPAddedBaseGrandTotal() {
|
async getLPAddedBaseGrandTotal() {
|
||||||
|
if (!this.initialGrandTotal) {
|
||||||
|
this.initialGrandTotal = this.grandTotal;
|
||||||
|
}
|
||||||
|
|
||||||
const totalLotaltyAmount = await getAddedLPWithGrandTotal(
|
const totalLotaltyAmount = await getAddedLPWithGrandTotal(
|
||||||
this.fyo,
|
this.fyo,
|
||||||
this.loyaltyProgram as string,
|
this.loyaltyProgram as string,
|
||||||
this.loyaltyPoints as number
|
this.loyaltyPoints as number
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.redeemLoyaltyPoints && (this.loyaltyPoints as number) > 0) {
|
return this.initialGrandTotal?.sub(totalLotaltyAmount);
|
||||||
this.grandTotal?.add(totalLotaltyAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.grandTotal?.sub(totalLotaltyAmount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formulas: FormulaMap = {
|
formulas: FormulaMap = {
|
||||||
account: {
|
account: {
|
||||||
formula: async () => {
|
formula: async () => {
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ export abstract class InvoiceItem extends Doc {
|
|||||||
if (!this.prule) {
|
if (!this.prule) {
|
||||||
return this.itemDiscountPercent;
|
return this.itemDiscountPercent;
|
||||||
} else {
|
} else {
|
||||||
return this.fyo.pesa(0);
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -470,11 +470,14 @@ export class Payment extends Transactional {
|
|||||||
|
|
||||||
for (const row of this.for ?? []) {
|
for (const row of this.for ?? []) {
|
||||||
if (!this.fyo.singles.AccountingSettings?.enablePartialPayment) {
|
if (!this.fyo.singles.AccountingSettings?.enablePartialPayment) {
|
||||||
const amount = this.amount as Money;
|
const amount = (this.writeoff as Money).isZero()
|
||||||
|
? (this.amount as Money)
|
||||||
|
: (this.amountPaid as Money);
|
||||||
|
|
||||||
const totalAmount = this.totalAmount as Money;
|
const totalAmount = this.totalAmount as Money;
|
||||||
if (amount.lt(totalAmount)) {
|
if (amount.lt(totalAmount)) {
|
||||||
if (this.writeoff?.isZero()) {
|
if (this.writeoff?.isZero()) {
|
||||||
this.amount = this.initialAmount;
|
this.amount = totalAmount;
|
||||||
row.amountPaid = this.fyo.pesa(0);
|
row.amountPaid = this.fyo.pesa(0);
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
this.fyo.t`Enable Partial payment to pay partial amount`
|
this.fyo.t`Enable Partial payment to pay partial amount`
|
||||||
|
|||||||
@@ -60,12 +60,6 @@
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "isMultiple",
|
|
||||||
"label": "Is Multiple",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "priority",
|
"fieldname": "priority",
|
||||||
"label": "Priority",
|
"label": "Priority",
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'availableQty',
|
fieldname: 'availableQty',
|
||||||
label: 'Available Qty',
|
label: 'Qty',
|
||||||
placeholder: 'Available Qty',
|
placeholder: 'Available Qty',
|
||||||
fieldtype: 'Float',
|
fieldtype: 'Float',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
|||||||
@@ -87,48 +87,6 @@
|
|||||||
|
|
||||||
<template v-if="isExapanded">
|
<template v-if="isExapanded">
|
||||||
<div class="px-4 pt-6 col-span-1">
|
<div class="px-4 pt-6 col-span-1">
|
||||||
<Float
|
|
||||||
:df="{
|
|
||||||
fieldname: 'quantity',
|
|
||||||
fieldtype: 'Float',
|
|
||||||
label: 'Quantity',
|
|
||||||
}"
|
|
||||||
size="medium"
|
|
||||||
:min="0"
|
|
||||||
:border="true"
|
|
||||||
:show-label="true"
|
|
||||||
:value="row.quantity"
|
|
||||||
@change="(value:number) => setQuantity(value)"
|
|
||||||
:read-only="isReadOnly"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="px-4 pt-6 col-span-2 flex">
|
|
||||||
<Link
|
|
||||||
v-if="isUOMConversionEnabled"
|
|
||||||
:df="{
|
|
||||||
fieldname: 'transferUnit',
|
|
||||||
fieldtype: 'Link',
|
|
||||||
target: 'UOM',
|
|
||||||
label: t`Transfer Unit`,
|
|
||||||
}"
|
|
||||||
class="flex-1"
|
|
||||||
:show-label="true"
|
|
||||||
:border="true"
|
|
||||||
:value="row.transferUnit"
|
|
||||||
@change="(value:string) => row.set('transferUnit', value)"
|
|
||||||
:read-only="isReadOnly"
|
|
||||||
/>
|
|
||||||
<feather-icon
|
|
||||||
v-if="isUOMConversionEnabled"
|
|
||||||
name="refresh-ccw"
|
|
||||||
class="w-3.5 ml-2 mt-4 text-blue-500"
|
|
||||||
@click="row.transferUnit = row.unit"
|
|
||||||
:read-only="isReadOnly"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="px-4 pt-6 col-span-2">
|
|
||||||
<Int
|
<Int
|
||||||
v-if="isUOMConversionEnabled"
|
v-if="isUOMConversionEnabled"
|
||||||
:df="{
|
:df="{
|
||||||
@@ -145,10 +103,45 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="px-4 pt-6 col-span-2">
|
||||||
|
<Link
|
||||||
|
v-if="isUOMConversionEnabled"
|
||||||
|
:df="{
|
||||||
|
fieldname: 'transferUnit',
|
||||||
|
fieldtype: 'Link',
|
||||||
|
target: 'UOM',
|
||||||
|
label: t`Transfer Unit`,
|
||||||
|
}"
|
||||||
|
class="flex-1"
|
||||||
|
:show-label="true"
|
||||||
|
:border="true"
|
||||||
|
:value="row.transferUnit"
|
||||||
|
@change="(value:string) => row.set('transferUnit', value)"
|
||||||
|
:read-only="isReadOnly"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="px-4 pt-6 col-span-2">
|
||||||
|
<Float
|
||||||
|
:df="{
|
||||||
|
fieldname: 'quantity',
|
||||||
|
fieldtype: 'Float',
|
||||||
|
label: 'Quantity',
|
||||||
|
}"
|
||||||
|
size="medium"
|
||||||
|
:min="0"
|
||||||
|
:border="true"
|
||||||
|
:show-label="true"
|
||||||
|
:value="row.quantity"
|
||||||
|
@change="(value:number) => setQuantity(value)"
|
||||||
|
:read-only="isUOMConversionEnabled"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|
||||||
<div class="px-4 pt-6 flex">
|
<div class="px-4 pt-6">
|
||||||
<Currency
|
<Currency
|
||||||
:df="{
|
:df="{
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
@@ -162,12 +155,6 @@
|
|||||||
:read-only="isRateReadOnly()"
|
:read-only="isRateReadOnly()"
|
||||||
@change="(value:Money) => setRate((row.rate = value))"
|
@change="(value:Money) => setRate((row.rate = value))"
|
||||||
/>
|
/>
|
||||||
<feather-icon
|
|
||||||
name="refresh-ccw"
|
|
||||||
class="w-3.5 ml-2 mt-5 text-blue-500 flex-none"
|
|
||||||
@click="row.rate= (defaultRate as Money)"
|
|
||||||
:disabled="isRateReadOnly()"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="px-6 pt-6 col-span-2">
|
<div class="px-6 pt-6 col-span-2">
|
||||||
<Currency
|
<Currency
|
||||||
|
|||||||
Reference in New Issue
Block a user